- All Superinterfaces:
- EventListener
- All Known Implementing Classes:
- AWTEventMulticaster, BasicComboBoxUI.ItemHandler, BasicComboPopup.ItemHandler, Checkbox.AccessibleAWTCheckbox, DefaultCellEditor.EditorDelegate, JCheckBox.AccessibleJCheckBox, JRadioButton.AccessibleJRadioButton, JToggleButton.AccessibleJToggleButton, List.AccessibleAWTList
- See Also:
- Top Examples, Source Code,
ItemSelectable
,
ItemEvent
void itemStateChanged(ItemEvent e)
- Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1412]JCheckBox Demo
By vikas, gupta_vikas25 { at } yahoo { dot } com on 2005/05/04 11:33:49 Rate
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ItemEvent;
import java.applet.*;
import javax.swing.*;
public class JCheckBoxDemo extends JApplet
implements ItemListener {
JTextField jtf;
public void init ( ) {
// Get content pane
Container contentPane=getContentPane ( ) ;
contentPane.setLayout ( new FlowLayout ( ) ) ;
//Create Icons
ImageIcon normal=new ImageIcon ( "normal.gif" ) ;
ImageIcon rollover=new ImageIcon ( "rollover.gif" ) ;
ImageIcon selected=new ImageIcon ( "selected.gif" ) ;
//Add Check boxes to the content pane
JCheckBox cb=new JCheckBox ( "C", 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 ( "Java",normal ) ;
cb.setRolloverIcon ( rollover ) ;
cb.setSelectedIcon ( selected ) ;
cb.addItemListener ( this ) ;
contentPane.add ( cb ) ;
// Add text field to content pane
jtf=new JTextField ( 15 ) ;
contentPane.add ( jtf ) ;
}
public void ItemStateChanged ( ItemEvent ie ) {
JCheckBox cb= ( JCheckBox ) ie.getItem ( ) ;
jtf.setText ( cb.getText ( ) ) ;
}
}
after compilation i got this erroe message:
E:\J2sdk1.4.2_07\bin\Projava\Aplt\JCheckBoxDemo\JCheckBoxDemo.java:11: JCheckBoxDemo is not abstract and does not override abstract method itemStateChanged ( java.awt.event.ItemEvent ) in java.awt.event.ItemListener
public class JCheckBoxDemo extends JApplet