Hi,
Shown below is the whole program:
If i remove the comments , the program doesn't compile. I tried quite a bit to solve this on my own, but couldn't. Also, am i doing it right when i am defining the event handler as i have done here? All the code gets packed into the constructor and this class itself, i sense something awkward about it.

/* Creating a purchase order screen */
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
public class POFrame extends JFrame
{
public Panel leftPanel;
public Panel rightPanel;
public Panel topPanel;
public Panel paymentPanel;
public Panel submitCancelPanel;
// constructor
public POFrame()
{
super("Purchase Order");
setBounds(50,50,600,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(3,0));
leftPanel=new Panel();
rightPanel=new Panel();
topPanel=new Panel();
paymentPanel=new Panel();
submitCancelPanel=new Panel();
// Filling the TopPanel
leftPanel.setLayout(new GridLayout(4,1));
leftPanel.add(new Label("Date"));
Date today = new Date();
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG,Locale.US);
String prntDate = df.format(today);
TextField dateText = new TextField();
dateText.setText(prntDate);
leftPanel.add(dateText);
leftPanel.add(new Label("ITEM CATEGORY"));
Choice item_category = new Choice();
item_category.addItem("Hardware");
item_category.addItem("Software");
// CategoryListener cl = new CategoryListener();
//item_category.addItemListener(cl);
leftPanel.add(item_category);
rightPanel.setLayout(new GridLayout(4,1));
rightPanel.add(new Label("ITEM DESCRIPTION"));
rightPanel.add(new TextArea());
rightPanel.add(new Label("ITEM COMPONENT"));
CompList cList = new CompList("Hardware");
rightPanel.add(cList);
topPanel.setLayout(new GridLayout(1,2));
topPanel.add(leftPanel);
topPanel.add(rightPanel);
paymentPanel.setLayout(new GridLayout(4,1));
paymentPanel.add(new Label("PAYMENT METHOD"));
CheckboxGroup cbg=new CheckboxGroup();
Checkbox cbx1=new Checkbox("Visa",false,cbg);
Checkbox cbx2=new Checkbox("MasterCard",false,cbg);
Checkbox cbx3=new Checkbox("American Express",false,cbg);
// paymentPanel.add(cbg);
paymentPanel.add(cbx1);
paymentPanel.add(cbx2);
paymentPanel.add(cbx3);
// Filling the submitCancelPanel
// add Buttons
Button CancelButton = new Button("Cancel");
Button SubmitButton = new Button("Submit");
CancelButton.setBackground(Color.blue);
SubmitButton.setBackground(Color.red);
submitCancelPanel.add(CancelButton);
submitCancelPanel.add(SubmitButton);
getContentPane().add(topPanel);
getContentPane().add(paymentPanel);
getContentPane().add(submitCancelPanel);
setVisible(true);
}
}
/* class CategoryListener implements ItemListener
{
public void itemStateChanged(ItemEvent ie)
{
Choice catgList = (Choice)(ie.getSource());
String catgChosen = catgList.getSelectedItem();
if (catgChosen.equals("Hardware"))
{
rightPanel.removeAll();
rightPanel.add(new Label("ITEM COMPONENT"));
CompList cList = new CompList("Hardware");
rightPanel.add(cList);
}
else
{
rightPanel.removeAll();
rightPanel.add(new Label("ITEM COMPONENT"));
CompList cList = new CompList("Hardware");
rightPanel.add(cList);
}
}
} */
Also, the program that i run to create the Frame is just this:
/* Program to create a window */
import java.awt.*;
import javax.swing.*;
public class POCreate
{
public static void main(String[] args)
{
POFrame pof = new POFrame();
}
}