Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Creating Menus

  Asked By: Nisha    Date: Jul 03    Category: Java    Views: 822
  

iam trying to create a simple menu.Iam getting an error in the
createMenu function.Though i have declared mnuCount as integer it 's
been recognized as an menu.Cansomebody help

------------------------------
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.io.*;

public class Student extends Frame
{
private static MenuBar mnuBar;
private Menu mnuName ;
private static int mnuCount = 0;

private String regMenu[]={ "Add/Drop","LookUp","-","View
Schedule","Course Info"};
private String accMenu[]={ "Account Summary","Fee
Deadline","-","Refund Status"};
private String recMenu[]={ "Check Holds","-","View
Grades","Transfer Credit"};
private String pinMenu[]={ "Change Address","Change
Telephone No","Change Password"};
private String exMenu[]={ "Logout"};

public Student()
{
super("Student Interface");
inits();
createMenu ("Registeration",regMenu);
createMenu ("Student Accounts",accMenu);
createMenu ("Student Records",recMenu);
createMenu ("Personal Information Menu",pinMenu);
createMenu ("Exit",exMenu);
show();
setBounds(0,0,800,600);
}

private void inits()
{
//mnuBar = new MenuBar();
//setMenuBar(mnuBar);
show();
setBounds(0,0,800,600);

}
private void createMenu(String mnuTmpName,String mnuTmpItem
[])
{
MenuItem m;
mnuBar.add(mnuName [mnuCount]= new Menu(mnuTmpName));
for(int i=0;i<mnuTmpItem.length;i++)
{
mnuName [mnuCount].add(m=new MenuItem
(mnuTmpItem[i]));
}
mnuCount++;
}
}

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Sophia Campbell     Answered On: Jul 03

//mnuName is not an array, but mnuTmpName is...
mnuBar.add(mnuName [mnuCount]= new Menu(mnuTmpName));

//try...
mnuBar.add(mnuName = new Menu(mnuTmpName[mnuCount]));

 
Didn't find what you were looking for? Find more on Creating Menus Or get search suggestion and latest updates.




Tagged: