1.
The
JButton
, JTextField
, and JComponent
classes are defined in the package.JButton
, JTextField
, and JComponent
classes are defined in the package.JButton
, an will automatically be generated.ActionEvent
s are and . JButton
s, JTextField
s, and JLabel
s are all subclasses of .JFrame
class is a subclass of .ActionEvent
s, it must implement the interface.ActionEvent
and an ActionListener()
method.JButton
class on Oracle’s Web site: https://docs.oracle.com/javase/8/docs/api/javax/swing/JButton.html. List the signatures of all its constructors.JTextField
. What method should we use and where is this method defined? JTextField
JButton
have an init()
method? Explain.JButton
have an add()
method? Explain.JButton
named button
. Describe what happens, in terms of Java’s event handling model, when the user clicks the button.JButton
s, initially labeled, “Me first!” and “Me next!” Each time the user clicks either button, the labels on both buttons should be exchanged. JButton
s, initially labeled “First,” “Second,” and “Third.” Each time the user clicks one of the buttons, the labels on the buttons should be rotated. Second should get first’s label, third should get second’s, and first should get third’s label.JTextField
and two JButton
s, initially labeled “Left” and “Right.” Each time the user clicks a button, display its label in the JTextField
. A JButton()
’s label can be gotten with the getText()
method.JFrame
by using the setSize(int h, int v)
method, where h and v give its horizontal and vertical dimensions pixels. Write a GUI application that contains two JButton
s, labeled “Big” and “Small.” Whenever the user clicks on small, set the JFrame's
dimensions to 200 × 100, and whenever the user clicks on big, set the dimensions to 300 × 200.JButton
is labeled “Big,” clicking it should give the JFrame
its big dimensions.JFrame
’s background color to one of three choices, indicated by buttons. Like all other Java Component
s, JFrame
’s have an associated background color, which can be set by the following commands: setBackground(Color.red);
setBackground(Color.yellow);
setBackground()
method is defined in the Component
class, and 13 primary colors—black
, blue
, cyan
, darkGray
, gray
, green
, lightGray
, magenta
, orange
, pink
, red
, white
, yellow
—are defined in the java.awt.Color
class.