Mercurial > hg > jslab
comparison examples/gui/awt/LightS.java @ 1:5df24c91468d
Oh my what a mess.
author | samer |
---|---|
date | Fri, 05 Apr 2019 16:26:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:bf79fb79ee13 | 1:5df24c91468d |
---|---|
1 // program to test lightweight components (Swing version) | |
2 package test.awt; | |
3 | |
4 import java.awt.*; | |
5 import java.awt.event.*; | |
6 import javax.swing.*; | |
7 | |
8 // this is a lightweight component | |
9 | |
10 | |
11 public class LightS extends JApplet | |
12 { | |
13 public static void run(Container c) | |
14 { | |
15 JButton b = new JButton("Hello!"); | |
16 | |
17 c.setLayout(new FlowLayout()); | |
18 c.add( b); | |
19 c.add( new Lightweight(Color.green,"harpo")); | |
20 c.add( new Lightweight(Color.blue,"groucho")); | |
21 c.add( new Lightweight(Color.red,"zeppo")); | |
22 c.validate(); | |
23 } | |
24 | |
25 public static void main(String[] args) | |
26 { | |
27 JFrame fr=new JFrame("Lightweight test"); | |
28 fr.addWindowListener(new WindowAdapter() { | |
29 public void windowClosing(WindowEvent e) { | |
30 System.exit(0); | |
31 } | |
32 } ); | |
33 fr.setSize(400,100); | |
34 fr.show(); | |
35 run(fr.getContentPane()); | |
36 } | |
37 | |
38 public void init() | |
39 { | |
40 getParent().setBackground( Color.red); | |
41 run(getContentPane()); | |
42 } | |
43 } |