Java Reference
In-Depth Information
public void
windowDeiconified(WindowEvent e)
{}
public void
windowActivated(WindowEvent e)
{}
public void
windowDeactivated(WindowEvent e)
{}
}
5.
JButton magicButton =
new
JButton("Magic Button"
);
ImageIcon wizardIcon =
new
ImageIcon("wizard.gif");
magicButton.setIcon(wizardIcon);
There are a number of other ways to accomplish the same thing. Below are two
of a number of valid alternatives:
JButton magicButton =
new
JButton("Magic Button");
magicButton.setIcon(
new
ImageIcon("wizard.gif"));
ImageIcon wizardIcon =
new
ImageIcon("wizard.gif");
JButton magicButton =
new
JButton("Magic Button", wizardIcon);
6.
ImageIcon wizardIcon =
new
ImageIcon(
"
wizard.gif");
JLabel wizardPicture =
new
JLabel(wizardIcon);
picturePanel.add(wizardPicture);
There are a number of other ways to accomplish the same thing. Below is one
valid alternative:
picturePanel.add(
new
JLabel(
new
ImageIcon("wizard.gif")));
7.
ImageIcon wizardIcon =
new
ImageIcon("wizard.gif");
JButton magicButton =
new
JButton(wizardIcon);
magicButton.setActionCommand("Kazam");
There are a number of other ways to accomplish the same thing. Below is one
valid alternative:
JButton magicButton =
new
JButton(
new
ImageIcon("wizard.gif"));
magicButton.setActionCommand("Kazam");
8.
No. You can invoke none, one, or both methods.
9.
No. The class
JTextArea
is a descendent class of the class
Component
. So, every
JTextArea
is also a
Component
.