I wrote a program to display a JLabel and 2 JComboBoxes.
It is compiling correctly but not diisplaying either of them.
Unable to find the bug in my code.Previously I wrote small programs to display JButtons,JradioButtons,JTextFileds,JLabels and now moved on to JComboBox.
here my code goes
import javax.swing.*;
import java.awt.*;
public class comboDemo extends JFrame
{
private JLabel expiryLabel;
private JComboBox yearBox,monthBox;
public static void main(
String ar[])
{
comboDemo obj1 = new comboDemo();
}
public comboDemo()
{
JFrame frame1 = new JFrame();
frame1.setVisible(true);
frame1.setTitle("Combo Demo");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.setLayout(new FlowLayout());
expiryLabel = new JLabel("Expiration Date");
c.add(expiryLabel);
monthBox= new JComboBox();
yearBox= new JComboBox();
for(int i=1;i<13;i++)
monthBox.addItem(" " +i);//adding month number to first JComboBox.
for(int i=2008;i<2012;i++)
yearBox.addItem(" "+i);//adding year to second JComboBox
c.add(monthBox); //adding first JComboBox to container
c.add(yearBox); //adding second JcomboBox to container.
}
}
Can anybody please point out where iam going wrong in displaying?