KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > decompiler > Applet


1 /* Applet Copyright (C) 1999-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; see the file COPYING.LESSER. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: Applet.java,v 4.3.2.1 2002/05/28 17:34:03 hoenicke Exp $
18  */

19
20 package jode.decompiler;
21 import java.awt.Color JavaDoc;
22 import java.awt.Dimension JavaDoc;
23 import java.awt.Graphics JavaDoc;
24 import java.awt.Insets JavaDoc;
25
26 public class Applet extends java.applet.Applet JavaDoc {
27     private final int BORDER = 10;
28     private final int BEVEL = 2;
29     private Window jodeWin = new Window(this);
30     private Insets JavaDoc myInsets;
31     private Color JavaDoc pageColor;
32
33 ///#ifdef AWT10
34
/// public boolean action(Event e, Object arg) {
35
/// jodeWin.action(e, arg);
36
/// return true;
37
/// }
38
///
39
/// public Insets insets() {
40
/// if (myInsets == null) {
41
/// Insets appInsets = super.insets();
42
///#else
43
public Insets JavaDoc getInsets() {
44     if (myInsets == null) {
45         Insets JavaDoc appInsets = super.getInsets();
46 ///#endif
47
myInsets = new Insets JavaDoc
48         (appInsets.top+BORDER, appInsets.left+BORDER,
49          appInsets.bottom+BORDER, appInsets.right+BORDER);
50     }
51     return myInsets;
52     }
53
54     public void paint(Graphics JavaDoc g) {
55     super.paint(g);
56     Color JavaDoc back = getBackground();
57     Color JavaDoc bright = back.brighter();
58     Color JavaDoc dark = back.darker();
59 ///#ifdef AWT10
60
/// Dimension size = size();
61
///#else
62
Dimension JavaDoc size = getSize();
63 ///#endif
64

65     // Fill corners with page color:
66
g.setColor(pageColor);
67     g.fillRect(0 , 0 , BORDER, BORDER);
68     g.fillRect(size.width - BORDER, 0 , BORDER, BORDER);
69     g.fillRect(size.width - BORDER, size.height - BORDER, BORDER, BORDER);
70     g.fillRect(0 , size.height - BORDER, BORDER, BORDER);
71
72     // put filled arcs into corners with highlight color
73
g.setColor(bright);
74     g.fillArc(0, 0,
75           2*BORDER, 2*BORDER, 90, 90);
76     g.fillArc(size.width - 2*BORDER, 0,
77           2*BORDER, 2*BORDER, 45, 45);
78     g.fillArc(0, size.height - 2*BORDER,
79           2*BORDER, 2*BORDER, 180, 45);
80
81     // draw highlighted edges
82
g.fillRect(BORDER, 0, size.width - 2*BORDER, BEVEL);
83     g.fillRect(0, BORDER, BEVEL, size.height - 2*BORDER);
84
85     // The same as above on the other side with dark color.
86
g.setColor(dark);
87     g.fillArc(size.width - 2*BORDER, 0,
88           2*BORDER, 2*BORDER, 0, 45);
89     g.fillArc(0, size.height - 2*BORDER,
90           2*BORDER, 2*BORDER, 225, 45);
91     g.fillArc(size.width - 2*BORDER, size.height - 2*BORDER,
92           2*BORDER, 2*BORDER, -90, 90);
93     g.fillRect(BORDER, size.height - BEVEL, size.width - 2*BORDER, BEVEL);
94     g.fillRect(size.width - BEVEL, BORDER, BEVEL, size.height - 2*BORDER);
95
96     // Finally fill the corners with background color again.
97
g.setColor(back);
98     g.fillArc(BEVEL, BEVEL,
99           2*(BORDER-BEVEL), 2*(BORDER-BEVEL), 90, 90);
100     g.fillArc(size.width - (2*BORDER-BEVEL), BEVEL,
101           2*(BORDER-BEVEL), 2*(BORDER-BEVEL), 0, 90);
102     g.fillArc(BEVEL, size.height - 2*BORDER + BEVEL,
103           2*(BORDER-BEVEL), 2*(BORDER-BEVEL), 180, 90);
104     g.fillArc(size.width - (2*BORDER-BEVEL),
105           size.height - (2*BORDER-BEVEL),
106           2*(BORDER-BEVEL), 2*(BORDER-BEVEL), -90, 90);
107     }
108         
109     public void init() {
110     String JavaDoc colorstr = getParameter("pagecolor");
111     if (colorstr == null)
112         colorstr = "ffffff";
113     this.pageColor = new Color JavaDoc(Integer.parseInt(colorstr, 16));
114     colorstr = getParameter("bgcolor");
115     if (colorstr != null)
116         setBackground(new Color JavaDoc(Integer.parseInt(colorstr, 16)));
117     String JavaDoc cp = getParameter("classpath");
118     if (cp != null)
119         jodeWin.setClassPath(cp);
120     String JavaDoc cls = getParameter("class");
121     if (cls != null)
122         jodeWin.setClass(cls);
123     }
124 }
125
Popular Tags