popupMenu = new JPopupMenu();
resizablePopupItem = new JCheckBoxMenuItem("Resizable", false);
JMenuItem exitPopupItem = new JMenuItem("Exit");
popupMenu.add(resizablePopupItem);

popupMenu.addSeparator();
popupMenu.add(exitPopupItem);

resizablePopupItem.addActionListener(this);
exitPopupItem.addActionListener(this);
getContentPane().addMouseListener(
	new MouseAdapter() {
	public void mouseReleased(MouseEvent e) {
	  if (e.isPopupTrigger()) {
	    popupMenu.show(e.getComponent(), e.getX(), e.getY());
	    }
	   }
	 }
);

codeLabel = new JLabel("Code: ");
titleLabel = new JLabel ("Title: ");
priceLabel = new JLabel ("Price: ");
codeField = new JTextField("", 10);
titleField = new JTextField("", 20);
priceField = new JTextField("", 10);

updatePanel = new JPanel();
addButton = new JButton("Add");
updateButton = new JButton("Update");
findButton = new JButton("Find");
deleteButton = new JButton("Delete");
exitButton = new JButton("Exit");
updatePanel.add(addButton);
updatePanel.add(updateButton);
updatePanel.add(findButton);
updatePanel.add(deleteButton);
updatePanel.add(exitButton);

navigationPanel = new JPanel();
firstButton = new JButton("First");
previousButton = new JButton("Prev");
nextButton = new JButton("Next");
lastButton = new JButton("Last");

navigationPanel.add(firstButton);
navigationPanel.add(previousButton);
navigationPanel.add(nextButton);
navigationPanel.add(lastButton);

codeField.addActionListener(this);
titleField.addActionListener(this);
priceField.addActionListener(this);
addButton.addActionListener(this);
updateButton.addActionListener(this);
findButton.addActionListener(this);
deleteButton.addActionListener(this);
exitButton.addActionListener(this);
firstButton.addActionListener(this);
previousButton.addActionListener(this);
nextButton.addActionListener(this);
lastButton.addActionListener(this);

constraints = new GridBagConstraints();
constraints.weightx = 1.0;
constraints.weighty = 1.0;

constraints.anchor = GridBagConstraints.EAST;
addComponent(codeLabel, 0, 0, 1, 1);
addComponent(titleLabel, 1, 0, 1, 1);
addComponent(priceLabel, 2, 0, 1, 1);

constraints.anchor = GridBagConstraints.WEST;
addComponent(codeField, 0, 1, 2, 1);
addComponent(titleField, 1, 1, 2, 1);
addComponent(priceField, 2, 1, 2, 1);

constraints.anchor = GridBagConstraints.CENTER;;
addComponent(updatePanel, 3, 0, 4, 1);
addComponent(navigationPanel, 4, 0, 4, 1);

enableButtons(true);

}

public static void main(String [] args) {
CdDatabase cdDatabase = new CdDatabase();
cdDatabase.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
cdDatabase.setVisible( true );
}

public void actionPerformed(ActionEvent e) {
Object source = e.getSource();

if(source instanceof JMenuItem) {

    Source: geocities.com/hk/alexmai00/APMfile

               ( geocities.com/hk/alexmai00)                   ( geocities.com/hk)