PHP/MySQL,HTML,JavaScript,Java Programming examples. Free Software, Earn Money Online.
Color Pallet in Swing
public class MovingBannerColors extends JApplet implements Runnable,ChangeListener
{
/*<Applet code="MovingBannerColors.class" height=400 width=400>
</Applet>
*/
String s;
JLabel lbl;
JColorChooser palete;
public void init()
{
Container frame = getContentPane();
lbl = new JLabel("Welcome to My Blog -*- ");
frame.setLayout(new BorderLayout());
palete=new JColorChooser();
lbl.setFont(new Font("Helvetica", Font.BOLD, 30));
lbl.setForeground(Color.blue);
frame.add(lbl, BorderLayout.NORTH);
frame.add(palete,BorderLayout.SOUTH);
s= "Welcome to My Blog -*- ";
palete.getSelectionModel().addChangeListener(this);
}
public void stateChanged(ChangeEvent e)
{
lbl.setForeground(palete.getColor());
}
public void start()
{
Thread t=new Thread(this);
t.start();
}
public void run()
{
for(;;)
{
try{
char c=s.charAt(0);
s=s.substring(1)+c;
lbl.setText(s);
Thread.sleep(200);
}
catch(InterruptedException e)
{}
}
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thanks for visiting my Blog!