Modify the code to turn the text area background to the color YELLOW if you click an "x" (lower or uppercase)?


Replace your existing keyTyped() method code code with the one given below.
@Override
public void keyTyped(KeyEvent input) {
char key = input.getKeyChar();
if(key == 'x' || key == 'X') {
keyText.setBackground(Color.yellow);
}
}
Modify the code to turn the text area background to the color YELLOW if you click...
There 2 parts to complete: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Q4 extends JFrame { private int xPos, yPos; public Q4() { JPanel drawPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); // paint parent's background //complete this: } }; drawPanel.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { //complete this :- set the xPos, yPos } }); setContentPane(drawPanel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("Mouse-Click Demo"); setSize(400, 250); setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() {...
Basic button tracking
Deliverables
Updated files for
app6.java
myJFrame6.java
myJPanel6.java
student.java
Contents
You can start with the files available here.
public class app6
{
public static void main(String args[])
{
myJFrame6 mjf = new myJFrame6();
}
}
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class myJFrame6 extends JFrame
{
myJPanel6 p6;
public myJFrame6 ()
{
super ("My First Frame");
//------------------------------------------------------
// Create components: Jpanel, JLabel and JTextField
p6 = new myJPanel6();
//------------------------------------------------------...
tart from the following code, and add Action Listener to make it
functional to do the temperature conversion in the direction of the
arrow that is clicked.
. (Need about 10 lines)
Note:
import javax.swing.*;
import
java.awt.GridLayout;
import
java.awt.event.*;
import
java.text.DecimalFormat;
public class temperatureConverter extends JFrame {
public static void
main(String[] args) {
JFrame frame = new temperatureConverter();
frame.setTitle("Temp");
frame.setSize(200, 100);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
public
temperatureConverter() {
JLabel lblC = new...
Can someone modify my code so that I do not get this error: Exception in thread "main" java.lang.NullPointerException at java.awt.Container.addImpl(Container.java:1043) at java.awt.Container.add(Container.java:363) at RatePanel.<init>(RatePanel.java:64) at CurrencyConverter.main(CurrencyConverter.java:16) This code should get the amount of money in US dollars from user and then let them select which currency they are trying to convert to and then in the textfield print the amount //********************************************************************* //File name: RatePanel.java //Name: Brittany Hines //Purpose: Panel for a program that convers different currencyNamerencies to use dollars //*********************************************************************...
Program #2 Write a program to simulate showing an NBA Team on a Basketball court Here is an example of the screenshot when running the program: Tony Parker T. Splitter T. Duncan M. Gineb Player Kame: M Ginobil Player Age 2 Add A Player Ce An example of the JFrame subclass with main method is as follows import java.awt. import java.awt.event." import javax.swing. public class NBA Playoff extends JFrame private JTextField txtName: private JTextField txtAge: private NBATeam spurs private NBAcourtPanel...
Can you please fix the error. package com.IST240Apps; import java.awt.*; import java.awt.event.*; import java.io.*; import javax.swing.*; import java.net.*; public class LinkRotator extends JFrame implements Runnable, ActionListener { String[] pageTitle = new String[5]; URI[] pageLink = new URI[5]; int current = 0; Thread runner; JLabel siteLabel = new Jlabel(); public LinkRotator() { setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE); setSize(300, 100); FlowLayout flo = new Flowlayout(); setLayout(flo); add(siteLabel); pageTitle = new String[] { "Oracle Java Site", "Server Side", "JavaWorld", "Google", "Yahoo", "Penn State" }; pageLink[0] = getUR1("http://www.oracle.com/technetwork/java");...
Java question so right now this code is work perfectly the problem is I also want to know if possible to get the X and Y value outside the JFrame? import java.awt.FlowLayout; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JFrame; import javax.swing.JLabel; public class MouseEventDemo extends JFrame implements MouseListener { //It is a class which generate a JFrame and implements MouseListener interface //These all are text that show x , y coordinates on mouse click event JLabel lclick; JLabel lpressed; JLabel lreleased;...
Need some help fixing these compilation errors that start around line 20, thank you import javax.swing.*; public class PropertyTax1 extends JFrame { private static final int WIDTH = 400, HEIGHT = 300; public PropertyTax1() { setTitle("Calculation of Property Taxes"); setSize(WIDTH, HEIGHT); setVisible(true); setDefaultCloseOperation(EXIT_ON_CLOSE); } // end of the constructor method public static void main(String[] args) { PropertyTax1 proptax = new PropertyTax1(); ...
PLEASE HELP DEBUG. IN JAVA! // Beverage selector // Milk and cola are $3 // all other drinks are $2 import javax.swing.*; import java.awt.*; import java.awt.event.*; public class DebugFourteen4 extends JFrame uses ItemListener { FlowLayout flow = new FlowLayout(); String title = new String("Beverage Selector"); Font bigFont = new Font("Arial", Font.PLAIN, 24); ButtonGroup drinkGrp = new ButtonGroup(); JCheckBox cola = new JCheckBox("Cola",false); JCheckBox lemon = new JCheckBox("Lemonade",false); JCheckBox tea = new JCheckBox("Iced tea"); JCheckBox milk = new JCheckBox("Milk"); JCheckBox coffee...
I want to make the JText area scrollable.. but my result doesn't work in that way. help me plz. package m5; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class TextAnalyzer extends JFrame implements ActionListener { //Initializes component variables for the frame //For text typing area JLabel type = new JLabel("Type sentences in the box below.", JLabel.CENTER); JTextArea txt = new JTextArea(10, 10); JPanel txt1 = new JPanel(); //For Statistic data...