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