samer@1: /* samer@1: * AppletBorders.java samer@1: * samer@1: * Copyright (c) 2000, Samer Abdallah, King's College London. samer@1: * All rights reserved. samer@1: * samer@1: * This software is provided AS iS and WITHOUT ANY WARRANTY; samer@1: * without even the implied warranty of MERCHANTABILITY or samer@1: * FITNESS FOR A PARTICULAR PURPOSE. samer@1: */ samer@1: package test; samer@1: import samer.core.*; samer@1: import samer.core.util.*; samer@1: import samer.core.util.heavy.*; samer@1: import samer.core.util.heavy.Borders.*; samer@1: import samer.core.util.Tools; samer@1: import java.awt.*; samer@1: samer@1: public class tester samer@1: { samer@1: public static void main(String args[]) samer@1: { samer@1: new samer.core.shells.AppShell(); samer@1: samer@1: final Shell.Window win=Shell.getWindow("tester"); samer@1: samer@1: win.container().setBackground(Color.white); samer@1: // win.container().setForeground(Color.white); samer@1: samer@1: win.container().setLayout(new StackLayout(0)); samer@1: win.container().add(Shell.createLabel("hmmm...")); samer@1: win.container().add(createBlock(new Color(200,160,180), "the world")); samer@1: win.container().add(createBlock(new Color(200,180,160), "welcome to")); samer@1: win.container().add(createBlock(new Color(180,200,160), "i like")); samer@1: win.container().add(createBlock(new Color(160,200,180), "of borders")); samer@1: win.container().add(createBlock(new Color(160,180,200), "these colours")); samer@1: win.container().add(createBlock(new Color(180,160,200), "hello there!")); samer@1: win.expose(); samer@1: samer@1: Agent agent=new Agent() { samer@1: public void getCommands(Agent.Registry r) { r.add("repaint"); } samer@1: public void execute(String cmd, Environment env) { samer@1: if (cmd.equals("repaint")) { samer@1: win.container().repaint(); samer@1: } samer@1: } samer@1: }; samer@1: Shell.exposeCommands(agent); samer@1: Shell.registerAgent(agent); samer@1: } samer@1: samer@1: static Border.Interface border = new CompoundBorder( samer@1: new ParentBgBorder(12), samer@1: new RoundedBorder(3,26,3) { samer@1: protected Color getDefaultColor(Component c) { samer@1: return c.getBackground().darker(); // brighter(); samer@1: } samer@1: } samer@1: ); samer@1: samer@1: static Component createBlock(Color bg, String msg) samer@1: { samer@1: JPanel p1=new JPanel(border); samer@1: p1.setLayout(new FlowLayout()); samer@1: p1.setBackground(bg); samer@1: p1.setForeground(bg.darker().darker().darker()); samer@1: p1.add(Shell.createLabel(msg)); samer@1: return p1; samer@1: } samer@1: }