I have created 2 menus using JForms.

I have two buttons in the 1st menu (menu1.java)

I want to go to the second menu (GUI of menu2.java) whenever I press button 1 in menu1.java.

How can I do that. What should I write in the actionListener func for button1?

i'll say that the best method is to add menu2 to menu1 just like you will add a button to a menu Example:

import javax.swing.*;

public class MenuTestFrame extends JFrame{
public MenuTestFrame(){
setSize(300, 300);

JMenuBar theBar = new JMenuBar();

JMenu menu1 = new JMenu("Menu1");
JMenu menu2 = new JMenu("Menu2");
menu2.add(new JMenuItem("Item1"));
menu2.add(new JMenuItem("Item2"));

menu1.add(new JMenuItem("AnItem"));

public static void main(String[] args){
new MenuTestFrame().setVisible(true);

One of my friends gave me another method....change the main method of 2nd menu to some normal function.
Call this function in the actionListener event for the button for which you want to call this 2nd menu in the 1st menu. :)

This question has already been answered. Start a new discussion instead.