Tweet
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/*
<applet code="JCheckBoxdemo" width =400 height=50>
</applet>
*/
public class JCheckBoxDemo extends JApplet implements ItemListener
{
JTextField jtf;
public void init()
{
Container contentPane=getContentPane();
contentPane.setLayout(new FlowLayout());
ImageIcon normal=new ImageIcon("normal.gif");
ImageIcon rollover=new ImageIcon("rollover.gif");
ImageIcon selected=new ImageIcon("selected.gif");
JCheckBox cb=new JCheckBox("C",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
cb=new JCheckBox("Java",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
cb=new JCheckBox("C++",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
cb=new JCheckBox("Perl",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
cb=new JCheckBox("PHP",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
cb=new JCheckBox("HTML",normal);
cb.setRolloverIcon(rollover);
cb.setSelectedIcon(selected);
cb.addItemListener(this);
contentPane.add(cb);
jtf=new JTextField(15);
contentPane.add(jtf);
}
public void itemStateChanged(ItemEvent ie)
{
JCheckBox cb=(JCheckBox)ie.getItem();
jtf.setText(cb.getText());
}
}
Java Check Boxes using applet
Posted by
LAHAUL SETH
~
Java Check Boxes using applet
2012-01-05T10:48:00+05:30
LAHAUL SETH
Java
|
Java Applet
|
Comments
Java Check Boxes using applet
2012-01-05T10:48:00+05:30
LAHAUL SETH
Java
|
Java Applet
|