Java Reference
In-Depth Information
the other one. It is important to copy the drawing and not to use an assignment of
references such as drawing1 = drawing2 .Inthat case the two drawings would be
identified; only one drawing would exist with two references to it. See Section B.1
for a more detailed explanation.
File: its/GraphicsUpdate/GoodUpdateFrame.java
1. package its.GraphicsUpdate;
2.
3. import javax.swing.JFrame;
4. import its.SimpleFrame.SimpleFrame;
5.
6.
7. public class GoodUpdateFrame extends SimpleFrame{
8.
9.
private UpdatePanel uppane;
10.
private Drawing drawing1, drawing2;
11.
12.
public GoodUpdateFrame(){
13.
drawing1 = new Drawing();
14.
drawing2 = new Drawing();
15.
uppane = new UpdatePanel(drawing1);
16.
getContentPane().add(uppane);
17.
pack();
18.
}
19.
20.
public void goodDemo(){
21.
uppane.repaint();
22.
drawing2.flipLines();
23.
uppane.setDrawing(drawing2);
24.
uppane.repaint();
25.
drawing1.copy(drawing2);
26.
drawing1.flipLines();
27.
uppane.setDrawing(drawing1);
28.
uppane.repaint ();
29.
}
30.
31.
public static void main(String[] args){
32.
GoodUpdateFrame goodFrame = new GoodUpdateFrame();
33.
goodFrame.showIt("Good Update"); // The drawing contains
34.
goodFrame.goodDemo();
35.
}
36.
37.
38. }
Search WWH ::




Custom Search