Java Reference
In-Depth Information
39.
//
and draw the rectangle
40.
41.
g.fillRect(upperLeftX,upperLeftY,blackWidth,blackHeight);
42.
43.
}
44.
45.
46.
}
File:
its/ResizeJumpDisplay/DirectionPanel.java
package
its.ResizeJumpDisplay;
1.
2.
3.
import
java.awt.GridLayout;
import
javax.swing.JButton;
4.
import
javax.swing.JPanel;
5.
6.
7.
public class
DirectionPanel
extends
JPanel {
8.
9.
public
DirectionPanel(PositionModel posMod, ResizeJumpFrame parent) {
10.
GridLayout gLayout =
new
GridLayout(1,4);
11.
this
.setLayout(gLayout);
12.
JButton upBut
=
new
JButton("Up");
13.
JButton downBut =
new
JButton("Down");
14.
JButton rightBut =
new
JButton("Right");
15.
JButton leftBut =
new
JButton("Left");
16.
this
.add(upBut);
17.
this
.add(leftBut);
18.
this
.add(rightBut);
19.
this
.add(downBut);
20.
21.
DirectionListener dirList =
new
DirectionListener(posMod,parent);
22.
upBut.addActionListener(dirList);
downBut.addActionListener(dirList);
23.
rightBut.addActionListener(dirList);
24.
leftBut.addActionListener(dirList);
25.
26.
27.
}
28.
29.
}
Search WWH ::
Custom Search