I only get one compilation error on the line where I declare the private Menu variables. JCreator reports "cannot access Menu" and stops. I can't eve find that error message on Google except as it has to do with hacking the software on cell phones. Code: /* File Name: Menu.java Assignment 5 COSC 3134 Andy Moon */ import java.awt.*; import java.awt.event.*; import javax.swing.*; class HouseholdInformationMenu extends Frame implements ActionListener { private MenuBar bar; private Menu systemMenu, householdMenu, processMenu; private MenuItem loadData, exit, inquireInfo, processPoverty; public HouseholdInformationMenu() { super("Household Information System"); setSize(200,100); //Create Menu Bar bar=new MenuBar(); //Create System menu systemMenu = new Menu("System"); //Create Household Information menu householdMenu = new Menu("Household Information"); //Create Process menu processMenu = new Menu("Process"); //Create System menu items loadData = new MenuItem("Load Household Data"); loadData.addActionListener(this); systemMenu.add(loadData); exit = new MenuItem("Exit"); exit.addActionListener(this); systemMenu.add(exit); //Create Household Information menu item inquireInfo = new MenuItem("Inquire Household Information"); inquireInfo.addActionListener(this); householdMenu.add(inquireInfo); //Create Process menu item processPoverty = new MenuItem("Process Poverty Information"); processPoverty.addActionListener(this); householdMenu.add(processPoverty); bar.add(systemMenu); bar.add(householdMenu); bar.add(processMenu); setMenuBar(bar); setVisible(true); } }
Can you still edit that post above? If so, use the Code: tags, please... you forgot :D. Should you really do the * when importing?? Isn't that dangerous? :eek:
Assuming the filename is Menu.java, the filename does not match the class name. Either change the filename from Menu.java to HouseholdInformationMenu.java, or change the name of the class (and its constructor) to Menu. Also, since you are implementing ActionListener, the class needs to have a concrete implementation of the method actionPerformed( ActionEvent evt ).
Actually, the part above is a pretty bad idea since Menu is a pre-existing Java class. You could rename the class to Menu, but then you'd have to fully qualify the class name (Menu) every time you mean the existing Java class and not the class you are currently defining. For example, every place you see "Menu" (except for the class name and the constructor name), you'd instead have to say "java.awt.Menu". To avoid all that, just change the file name to match the class name you have (Householdxxxxx...) .