I get error on the code below:
Could not find or load main class swing.ComboDemo Caused by:
java.lang.ClassNotFoundException: swing.ComboDemo
package swing;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ComboDemo extends JFrame implements ItemListener{
JComboBox<String> box;
JLabel lbl;
ComboDemo(){
Container c = getContentPane();
c.setLayout(null);
box=new JComboBox<String>();
box.addItem("India");
box.addItem("America");
box.addItem("Pakistan");
box.addItem("Uk");
box.setBounds(300,300,40,60);
c.add(box);
lbl = new JLabel();
lbl.setBounds(300, 500, 70, 30);
c.add(lbl);
box.addItemListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void itemStateChanged(ItemEvent ie) {
String str = (String)box.getSelectedItem();
lbl.setText(str);
}
public static void main(String[] args) {
ComboDemo demo = new ComboDemo();
demo.setSize(600,600);
demo.setVisible(true);
}
}