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 9113635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:00:31+00:00 2026-06-17T04:00:31+00:00

I have a relatively small class called LoadingWindow this class has a constructor that

  • 0

I have a relatively small class called “LoadingWindow” this class has a constructor that calls a Initialize function to setup the frame. Not I was testing some things to try to solve why it would not update. While testing I added “this.removeAll();” to the head of the initialize method. Turns out, I cant add anything after that. Anything I add, simply will not show.

Here is a slightly trimmed down version of the class:

public class LoadingWindow extends JFrame{

public JPanel panel;

public JProgressBar bar;

private JLabel label;

public LoadingWindow()
{

    this.Initialize();

}

public void Initialize()
{
    this.removeAll();

    this.setSize(300, 150);

    panel = new JPanel(new BorderLayout());
    bar = new JProgressBar(0,100);
    label = new JLabel("Please remain calm, we're just loading...");

    panel.add(bar,BorderLayout.CENTER);
    panel.add(label,BorderLayout.SOUTH);

    this.add(panel);

    this.validate();
    this.repaint();
    this.setVisible(true);
}
}

The window itself does pop up properly, with a title. However the window itself is completely blank.

I implement this class statically so that four other objects can access it in the EditorPanel class. Its defined as:

public static LoadingWindow loadingWindow;

and initialized in the constructor with:

loadingWindow = new LoadingWindow();

There is then a double check within the functions that use it to show it if it is hidden.

if(!EditorPanel.loadingWindow.isVisible()){EditorPanel.loadingWindow.Initialize();}

Overall I’m a bit confused as to why no content is showing, and I am very interested in any questions asked, and am willing to provide any info necessary. Google didn’t provide a whole lot, and every answer I found I had already implemented “such as repaint and validate”.

I look forward to hearing from you!

~Travis

  • 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-17T04:00:32+00:00Added an answer on June 17, 2026 at 4:00 am

    removeAll() as said by @TomHawtintackline (+1 to him), is not forwarded to the JFrames contentPane; like add(), remove() or setLayout() is.

    Thus when you do JFrame#removeAll() it removes the root pane of JFrame. See How to Use Root Panes for an interesting read and may prove fruitful for future endeavors.

    You should do:

    getContentPane().removeAll();// will make sure we remove all
    components from the contentPane

    • Also dont extend JFrame unnecessarily (unless adding functionality beyond its current capability) rather just create an instance of JFrame and use that

    • Dont call setSize rather use an appropriate LayoutManager and/or override getPreferredSize() of JPanel and return dimensions which fit drawings, thus you can call pack() on JFrame before setting it visible.

    • I see no need for validate() and repaint() these should only be called when a component is added to a visible container. Even than rather do revalidate() which will work for adding and removing a component (it inturn calls validate())

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

Sidebar

Related Questions

I have a relatively small database that I would like to generate a diagram
I have a relatively small app that Im building using vb.net 2.0, and nant.
I have a relatively simple class which deletes a post: function delete_post($postid, $reason){ //Stuff
I have a relatively small Java library that implements a few dozen beans (no
I have a small static method mymethod inside a relatively big (library) class com.package.pirulo
I have a django model which has a load of relatively small fields and
I have an class that extends ExpandableListActivity. To fill the data for this list,
I have a set of relatively simple electrical circuits. Small ones involving just resistors,
I have a relatively simple HTML / JavaScript form. Such as this: <form method='POST'
I have a relatively simple object with a method that makes an HTTP request.

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.