Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New file and open file code.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
dear all,
i want the code for opening the file which is already existed and in addition i need code for New File menu bar, using Java.

Hiren Delwadia.
 
Off the top of my head, here is some code for menus. I'll leave the Event handling to you. If you are using the swing package (GUI), then use JMenuBar, JMenu, and JMenuItem.

private MenuBar myMenuBar;
private Menu menuFile;
private MenuItem itemAbout;
private MenuItem itemExit;

// default constructor not used at this point.
// Must supply title
// for this About frame.
public AboutFrame(String title)
{
super(title);
thisFrame = this;
this.title = title;
this.setBackground(Color.white);

ActionHandler ActionHand = new ActionHandler();

this.setLayout(new BorderLayout());

// add menus
myMenuBar = new MenuBar();
menuFile = new Menu("File");
itemExit = new MenuItem("Exit");
menuFile.add(itemExit);
myMenuBar.add(menuFile);
this.setMenuBar(myMenuBar);

itemExit.addActionListener(ActionHand);

// rest code.
}

Good luck.
Brian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top