Mercurial > hg > jslab
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/gui/awt/tester.java Fri Apr 05 16:26:00 2019 +0100 @@ -0,0 +1,70 @@ +/* + * AppletBorders.java + * + * Copyright (c) 2000, Samer Abdallah, King's College London. + * All rights reserved. + * + * This software is provided AS iS and WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + */ +package test; +import samer.core.*; +import samer.core.util.*; +import samer.core.util.heavy.*; +import samer.core.util.heavy.Borders.*; +import samer.core.util.Tools; +import java.awt.*; + +public class tester +{ + public static void main(String args[]) + { + new samer.core.shells.AppShell(); + + final Shell.Window win=Shell.getWindow("tester"); + + win.container().setBackground(Color.white); + // win.container().setForeground(Color.white); + + win.container().setLayout(new StackLayout(0)); + win.container().add(Shell.createLabel("hmmm...")); + win.container().add(createBlock(new Color(200,160,180), "the world")); + win.container().add(createBlock(new Color(200,180,160), "welcome to")); + win.container().add(createBlock(new Color(180,200,160), "i like")); + win.container().add(createBlock(new Color(160,200,180), "of borders")); + win.container().add(createBlock(new Color(160,180,200), "these colours")); + win.container().add(createBlock(new Color(180,160,200), "hello there!")); + win.expose(); + + Agent agent=new Agent() { + public void getCommands(Agent.Registry r) { r.add("repaint"); } + public void execute(String cmd, Environment env) { + if (cmd.equals("repaint")) { + win.container().repaint(); + } + } + }; + Shell.exposeCommands(agent); + Shell.registerAgent(agent); + } + + static Border.Interface border = new CompoundBorder( + new ParentBgBorder(12), + new RoundedBorder(3,26,3) { + protected Color getDefaultColor(Component c) { + return c.getBackground().darker(); // brighter(); + } + } + ); + + static Component createBlock(Color bg, String msg) + { + JPanel p1=new JPanel(border); + p1.setLayout(new FlowLayout()); + p1.setBackground(bg); + p1.setForeground(bg.darker().darker().darker()); + p1.add(Shell.createLabel(msg)); + return p1; + } +} \ No newline at end of file