Mercurial > hg > jslab
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:bf79fb79ee13 | 1:5df24c91468d |
---|---|
1 // program to test lightweight components | |
2 package test.awt; | |
3 import java.awt.*; | |
4 | |
5 // this is a lightweight component | |
6 | |
7 public class Lightweight extends Component | |
8 { | |
9 Color col; | |
10 String text; | |
11 | |
12 Lightweight(Color color, String label) { | |
13 text=label; col=color; | |
14 setBackground(Color.getHSBColor(0.3F,0.4F,0.7F)); | |
15 } | |
16 | |
17 public void paint(Graphics g) | |
18 { | |
19 Dimension d=getSize(); | |
20 g.setColor(getBackground()); | |
21 g.fillRect(0,0,getWidth(),getHeight()); | |
22 g.setColor(getForeground()); | |
23 g.drawString(text,10,16); | |
24 } | |
25 | |
26 public boolean isOpaque() { return true; } | |
27 public Dimension getPreferredSize() | |
28 { | |
29 return new Dimension(80,20); | |
30 } | |
31 } | |
32 |