samer@1
|
1 /*
|
samer@1
|
2 * AppletBorders.java
|
samer@1
|
3 *
|
samer@1
|
4 * Copyright (c) 2000, Samer Abdallah, King's College London.
|
samer@1
|
5 * All rights reserved.
|
samer@1
|
6 *
|
samer@1
|
7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
|
samer@1
|
8 * without even the implied warranty of MERCHANTABILITY or
|
samer@1
|
9 * FITNESS FOR A PARTICULAR PURPOSE.
|
samer@1
|
10 */
|
samer@1
|
11 package test;
|
samer@1
|
12 import samer.core.*;
|
samer@1
|
13 import samer.core.util.*;
|
samer@1
|
14 import samer.core.util.heavy.*;
|
samer@1
|
15 import samer.core.util.heavy.Borders.*;
|
samer@1
|
16 import samer.core.util.Tools;
|
samer@1
|
17 import java.awt.*;
|
samer@1
|
18
|
samer@1
|
19 public class tester
|
samer@1
|
20 {
|
samer@1
|
21 public static void main(String args[])
|
samer@1
|
22 {
|
samer@1
|
23 new samer.core.shells.AppShell();
|
samer@1
|
24
|
samer@1
|
25 final Shell.Window win=Shell.getWindow("tester");
|
samer@1
|
26
|
samer@1
|
27 win.container().setBackground(Color.white);
|
samer@1
|
28 // win.container().setForeground(Color.white);
|
samer@1
|
29
|
samer@1
|
30 win.container().setLayout(new StackLayout(0));
|
samer@1
|
31 win.container().add(Shell.createLabel("hmmm..."));
|
samer@1
|
32 win.container().add(createBlock(new Color(200,160,180), "the world"));
|
samer@1
|
33 win.container().add(createBlock(new Color(200,180,160), "welcome to"));
|
samer@1
|
34 win.container().add(createBlock(new Color(180,200,160), "i like"));
|
samer@1
|
35 win.container().add(createBlock(new Color(160,200,180), "of borders"));
|
samer@1
|
36 win.container().add(createBlock(new Color(160,180,200), "these colours"));
|
samer@1
|
37 win.container().add(createBlock(new Color(180,160,200), "hello there!"));
|
samer@1
|
38 win.expose();
|
samer@1
|
39
|
samer@1
|
40 Agent agent=new Agent() {
|
samer@1
|
41 public void getCommands(Agent.Registry r) { r.add("repaint"); }
|
samer@1
|
42 public void execute(String cmd, Environment env) {
|
samer@1
|
43 if (cmd.equals("repaint")) {
|
samer@1
|
44 win.container().repaint();
|
samer@1
|
45 }
|
samer@1
|
46 }
|
samer@1
|
47 };
|
samer@1
|
48 Shell.exposeCommands(agent);
|
samer@1
|
49 Shell.registerAgent(agent);
|
samer@1
|
50 }
|
samer@1
|
51
|
samer@1
|
52 static Border.Interface border = new CompoundBorder(
|
samer@1
|
53 new ParentBgBorder(12),
|
samer@1
|
54 new RoundedBorder(3,26,3) {
|
samer@1
|
55 protected Color getDefaultColor(Component c) {
|
samer@1
|
56 return c.getBackground().darker(); // brighter();
|
samer@1
|
57 }
|
samer@1
|
58 }
|
samer@1
|
59 );
|
samer@1
|
60
|
samer@1
|
61 static Component createBlock(Color bg, String msg)
|
samer@1
|
62 {
|
samer@1
|
63 JPanel p1=new JPanel(border);
|
samer@1
|
64 p1.setLayout(new FlowLayout());
|
samer@1
|
65 p1.setBackground(bg);
|
samer@1
|
66 p1.setForeground(bg.darker().darker().darker());
|
samer@1
|
67 p1.add(Shell.createLabel(msg));
|
samer@1
|
68 return p1;
|
samer@1
|
69 }
|
samer@1
|
70 } |