Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9174825
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:48:56+00:00 2026-06-17T16:48:56+00:00

I have two different programs MenuWindow.java and SettingsWindow.java both GUIs, made using Swing. Is

  • 0

I have two different programs MenuWindow.java and SettingsWindow.java
both GUIs, made using Swing.
Is it possible to open SettingsWindow.java by clicking a button in MenuWindow.java?

Here are two codes:

MenuWindow.java

import java.awt.*;
import javax.swing.*;




public class MenuWindow
{
JFrame f ;
JMenuBar m ;
JMenu File , Settings , Timer , Programs , Store , Run , Help ;
JMenuItem m1 , m2 , m3 , m4 , m5 , m6 , m7 , m8 , m9 , m10 , m11 , m12 ;
JButton jb1, jb2, jb3 , jb4 , jb5 , jb6;


public MenuWindow() 
{

    f = new JFrame("Reflow") ;
    f.setSize(600, 600) ;
    m = new JMenuBar() ;
    File = new JMenu("File") ;
    Settings = new JMenu("Settings") ;
    Timer = new JMenu("Timer") ;
    Programs = new JMenu("Programs") ;
    Store = new JMenu("Store");
    Run = new JMenu("Run");
    Help = new JMenu("Help");
    m1 = new JMenuItem("Exit") ;
    m2 = new JMenuItem("Temperature") ;
    m3 = new JMenuItem("Clock") ;
    m4 = new JMenuItem("Profile") ;
    m5 = new JMenuItem(" Weekly Timer") ;
    m6 = new JMenuItem("Preset Programs") ;
    m7 = new JMenuItem("Errors") ;
    m8 = new JMenuItem("Profile") ;
    m9 = new JMenuItem("Auto Run") ;
    m10 = new JMenuItem("Profile Run") ;
    m11 = new JMenuItem("Manual Run") ;
    m12 = new JMenuItem("About");


    ImageIcon SettingsIc = new ImageIcon("settings.png");
    jb1 = new JButton(SettingsIc);
    jb1.setFocusPainted( false );
    //jb1.setBorderPainted(false); 
    jb1.setContentAreaFilled(false); 

    ImageIcon TimerIc = new ImageIcon("clock.png");
    jb2 = new JButton(TimerIc);
    jb2.setFocusPainted( false );
    //jb2.setBorderPainted(false); 
    jb2.setContentAreaFilled(false); 

    ImageIcon ProgramsIc = new ImageIcon("programs.png");
    jb3 = new JButton(ProgramsIc);
    jb3.setFocusPainted( false );
    //jb3.setBorderPainted(false); 
    jb3.setContentAreaFilled(false); 

    ImageIcon StoreIc = new ImageIcon("store.png");
    jb4 = new JButton(StoreIc);
    jb4.setFocusPainted( false );
    //jb4.setBorderPainted(false); 
    jb4.setContentAreaFilled(false); 

    ImageIcon RunIc = new ImageIcon("run.png");
    jb5 = new JButton(RunIc);
    jb5.setFocusPainted( false );
    //jb5.setBorderPainted(false); 
    jb5.setContentAreaFilled(false); 

    ImageIcon ConnectIc = new ImageIcon("connect.png");
    jb6 = new JButton(ConnectIc);
    jb6.setFocusPainted( false );
    //jb6.setBorderPainted(false); 
    jb6.setContentAreaFilled(false); 

    File.add(m1) ;
    Settings.add(m2) ;
    Settings.add(m3) ;
    Settings.add(m4) ;
    Timer.add(m5) ;
    Programs.add(m6) ;
    Store.add(m7);
    Store.add(m8);
    Run.add(m9);
    Run.add(m10);
    Run.add(m11);
    Help.add(m12);
    m.add(File) ;
    m.add(Settings) ;
    m.add(Timer) ;
    m.add(Programs) ;
    m.add(Store) ;
    m.add(Run) ;
    m.add(Help) ;
    f.add(m) ;
    f.add(jb1);
    f.add(jb2);
    f.add(jb3);
    f.add(jb4);
    f.add(jb5);
    f.add(jb6);

    jb1.setToolTipText("Settings");
    jb2.setToolTipText("Weekly Timer");
    jb3.setToolTipText("Program List");
    jb4.setToolTipText("Store");
    jb5.setToolTipText("Run");
    jb6.setToolTipText("Connect");

    System.out.println(System.getProperty("user.dir"));

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setJMenuBar(m);
    f.setLayout(new FlowLayout()) ;
    f.setVisible(true) ;

}


public static void main(String[] arg)
{
        MenuWindow w = new MenuWindow() ;

}

}

SettingsWindow.java

import java.awt.*;
import javax.swing.*;

public class SettingsWindow 
{

JFrame f;
JButton b1, b2, b3; 

public SettingsWindow() 
{
    f = new JFrame ("Settings") ;
    f.setSize(400, 400) ;

    ImageIcon TempuratureIc = new ImageIcon("heat.png");
    b1 = new JButton(TempuratureIc);
    b1.setFocusPainted(false);
    //b1.setBorderPainted(false);
    b1.setContentAreaFilled(false);

    ImageIcon TimeIc = new ImageIcon("timetable.png");
    b2 = new JButton(TimeIc);
    b2.setFocusPainted(false);
    //b2.setBorderPainted(false);
    b2.setContentAreaFilled(false);

    ImageIcon ProfileIc = new ImageIcon("graph.png");
    b3 = new JButton(ProfileIc);
    b3.setFocusPainted(false);
    //b3.setBorderPainted(false);
    b3.setContentAreaFilled(false);

    f.add(b1);
    f.add(b2);
    f.add(b3);

    b1.setToolTipText("Temperature Settings");
    b2.setToolTipText("Time Settings");
    b3.setToolTipText("Profile Settings");

    System.out.println(System.getProperty("user.dir"));

    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new FlowLayout());
    f.setVisible(true);

}

public static void main(String[] arg)
{
    SettingsWindow w = new SettingsWindow() ;
}

}

Can anyone please explain in detail? I am very new to Java.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T16:48:56+00:00Added an answer on June 17, 2026 at 4:48 pm

    Pass the reference of the SettingWindow object to MenuWindow. And use setVisible method when clicked on the button action in the MenuWindow class.

    UPDATE – 1:

    Add ActionListener to the jb1 (I assumed that this is the button that calls SettingsWindow) and call the SettingWindow when clicked on the button.

     jb1.addActionListener(new ActionListener() {
    
        @Override
        public void actionPerformed(ActionEvent arg0) {
            new SettingWindow();
        }
    });
    

    Also remove main from the SettingWindow class. It is not required.

    UPDATE – 2:

    Here in your code you have added a button like the following code:

    ImageIcon SettingsIc = new ImageIcon("settings.png");
    jb1 = new JButton(SettingsIc);
    jb1.setFocusPainted(false);
    jb1.setContentAreaFilled(false);
    jb1.addActionListener(new ActionListener() {
    
      @Override
      public void actionPerformed(ActionEvent arg0) {
         new SettingWindow();
      }
     });
    

    So you have added a button. When the button is clicked an action should be called. Write an ActionListener to this button such that it pops up the corresponding window. Similarly make different windows and call them by writing ActionListener to all the buttons like I states above. Also read about How to write ActionListener

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need an XML-serializable dictionary. Actually, I now have two quite different programs that
I've got a table recording views of programs. Each program can have two different
I have two different buttons on my page. I want them both to be
I have two different-sized monitors, connected together using (I believe) TwinView. I tried System.out.println(Toolkit.getDefaultToolkit().getScreenSize());
I have seen programs exporting to Excel in two different ways. Opening Excel and
I expose my context : I have two Java programs that run on a
I have two programs written in C++ that use Winsock. They both accept TCP
I have two programs: Score.java set to do the following: read scores from the
I have a unit which I want to use in two different programs, to
I have recently been put in charge of debugging two different programs which will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.