view examples/gui/awt/Lightweight.java @ 5:b67a33c44de7

Remove some crap, etc
author samer
date Fri, 05 Apr 2019 21:34:25 +0100
parents 5df24c91468d
children
line wrap: on
line source
// 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);
	}
}