File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
sources/net.sf.j2s.java.core/src/test Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ package test ;
2+
3+ import java .applet .Applet ;
4+ import java .awt .Button ;
5+ import java .awt .Color ;
6+ import java .awt .Dimension ;
7+ import java .awt .Graphics ;
8+ import java .awt .Image ;
9+ import java .awt .event .ActionEvent ;
10+ import java .awt .event .ActionListener ;
11+
12+ public class TApp6 extends Applet {
13+ Color col = Color .red ;
14+ private Image img ;
15+ // never keep local copies of a Graphics
16+ // private Graphics imggc;
17+
18+ public void init () {
19+ Dimension d =size ();
20+ img =createImage (d .width ,d .height );
21+ // imggc=img.getGraphics();
22+ setLayout (null );
23+ Button bt = new Button ("Press" );
24+ bt .addActionListener (new ActionListener () {
25+
26+ @ Override
27+ public void actionPerformed (ActionEvent e ) {
28+ Graphics imggc = img .getGraphics ();
29+ /**
30+ * @j2sNative
31+ * imggc.setAntialias$Z(false);
32+ */
33+ if (col == Color .red )
34+ col = Color .white ;
35+ else
36+ col = Color .red ;
37+ imggc .setColor (col );
38+ for (int i = 0 ; i < 100 ; ++i ) {
39+ for (int j = 0 ; j < 100 ; ++j ) {
40+ imggc .fillRect (2 * i , 2 * j , 1 , 1 );
41+ }
42+ }
43+ // must dispose
44+ imggc .dispose ();
45+ repaint ();
46+ }
47+ });
48+ bt .setBounds (0 , 0 , 200 , 100 );
49+ add (bt );
50+ }
51+
52+ public void paint (Graphics gc ) {
53+ /**
54+ * @j2sNative
55+ *
56+ * gc.setAntialias$Z(false);
57+ */
58+ if (img !=null ) gc .drawImage (img ,0 ,0 ,this );
59+ }
60+ }
You can’t perform that action at this time.
0 commit comments