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

  • Home
  • SEARCH
  • 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 7856197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:37:47+00:00 2026-06-02T20:37:47+00:00

So im making a game, and i want a jbutton to pop up in

  • 0

So im making a game, and i want a jbutton to pop up in the window and when you click it you can log in. the problem is that when i start the game, it doesnt always pop up, which is kind of annoying. the only think would be the problem is the order im doing things. here is the code:

public static void createWindow() {
    ImagePanel panel = new ImagePanel(
            new ImageIcon(backgroundFile).getImage()); //used for the background


    JButton login = new JButton(new AbstractAction("Login") {
        public void actionPerformed(ActionEvent e) {
            Login.createWindow();
        }
    });
    login.setBounds(300, 300, 100, 100);


    frame.getContentPane().add(panel); //sets the background to a pic
    frame.setJMenuBar(MenuBar.menuBarCreator()); creates the menu bar
    frame.pack();
    frame.setResizable(false);
    frame.setTitle("*Game Title* Beta 0.0.1 ADMINISTRATOR VERSION");
    frame.setSize(ImagePanel.img.getWidth(null),
            ImagePanel.img.getHeight(null));
    frame.setLocation(Monitor.setLocationHeight(),
            Monitor.setLocationWidth());
    frame.setVisible(true);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    StreamingLineSound.start(soundFile); //starts a music file
    frame.add(login);

}

any help would be fantastic. so basically all i want is an idea why it doesnt pop up all the time. thanks

  • 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-02T20:37:49+00:00Added an answer on June 2, 2026 at 8:37 pm

    Code line frame.setVisible(true); must be last line in the public static void createWindow() {, because you display JFrame and thenafter add frame.add(login);

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

Sidebar

Related Questions

I m making a Shooting game, in that I want an array of ImageViews
I am making a game that I want compatible for all older devices to
Here is the problem, lets say we are making a video game and want
I am making a game, so I want the JFrame to start maximized, but
I'm planning on making a game and want the window to have 3 different
I'm making a game which has multiple planets. Now I want to randomly generate
I am making a game and want to talk to all the clients at
I'm making a game and I want to check collision between player and block,
I am making a game in java and I want to create a simulation
I'm making a game and in the menu I want to display the text

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.