Mercurial > hg > jslab
diff examples/gui/awt/Lightweight.java @ 1:5df24c91468d
Oh my what a mess.
author | samer |
---|---|
date | Fri, 05 Apr 2019 16:26:00 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/examples/gui/awt/Lightweight.java Fri Apr 05 16:26:00 2019 +0100 @@ -0,0 +1,32 @@ +// program to test lightweight components +package test.awt; +import java.awt.*; + +// this is a lightweight component + +public class Lightweight extends Component +{ + Color col; + String text; + + Lightweight(Color color, String label) { + text=label; col=color; + setBackground(Color.getHSBColor(0.3F,0.4F,0.7F)); + } + + public void paint(Graphics g) + { + Dimension d=getSize(); + g.setColor(getBackground()); + g.fillRect(0,0,getWidth(),getHeight()); + g.setColor(getForeground()); + g.drawString(text,10,16); + } + + public boolean isOpaque() { return true; } + public Dimension getPreferredSize() + { + return new Dimension(80,20); + } +} +