Java Reference
In-Depth Information
34.
this .getContentPane().add(blueBut);
35.
this .getContentPane().add(redBut);
36.
this .getContentPane().add(yellowBut);
37.
this .getContentPane().add(colPanel);
38.
39.
40.
this .setVisible( true );
41.
42.
43.
}
44.
45.
// internal class
46.
class ColorListener implements ActionListener{
47.
public void actionPerformed (ActionEvent evt)
{
48.
49.
50.
String actComm = evt.getActionCommand();
System.out.println(""+actComm);
51.
if (actComm.equals("blue")){
52.
colPanel.setBackground(Color.blue);
53.
} else if (actComm.equals("red")){
54.
colPanel.setBackground(Color.red);
55.
56.
} else if (actComm.equals("yellow")){
57.
colPanel.setBackground(Color.yellow);
58.
}
59.
}// method
60.
}
61.
public static void main(String[] args) {
62.
ColorSelectionFrame colorSelectionFrame1 = new ColorSelectionFrame();
63.
}
64.
}
A.3
Chapter 13
A.3.1
13.1
The following listings of the package its.ResizeJumpDisplay contain the code
of a model-view implementation.
File: its/ResizeJumpDisplay/PositionModel.java
package its.ResizeJumpDisplay;
1.
2.
3.
4.
public class PositionModel {
// We allow the positions for the upper
5.
Search WWH ::




Custom Search