JFrame as MessageBox doesn´t show it´s controls

Hi,
 
I want to show the progress of loading records from a database into my JTree and a label in a JFrame. But - the label and the progressbar doesn´t appear in my JFrame-window.

I added the following class:


package DokViewer;

import java.awt.*;
import java.awt.Color;
import javax.swing.*;
import com.borland.jbcl.layout.*;

public class Fortschrittsanzeige extends JFrame
{
  JLabel jLabel1;
  JProgressBar jProgressBar1;
  VerticalFlowLayout verticalFlowLayout1;

  public Fortschrittsanzeige()
  {
    try
    {
      jbInit();
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }

  public void Close()
  {
    this.setVisible(false);
    // finalize(); // not necessary?
  }

  private void jbInit() throws Exception
  {
    jLabel1 = new JLabel();
    jProgressBar1 = new JProgressBar();
    verticalFlowLayout1 = new VerticalFlowLayout();

     
    this.getContentPane().setLayout(verticalFlowLayout1);
    this.setResizable(false);
    jProgressBar1.setMaximumSize(new Dimension(150, 16));
    jProgressBar1.setMinimumSize(new Dimension(150, 16));
    jProgressBar1.setMaximum(100);
    jProgressBar1.setMinimum(0);
    jLabel1.setMaximumSize(new Dimension(374, 32));
    jLabel1.setMinimumSize(new Dimension(187, 16));
    jLabel1.setPreferredSize(new Dimension(187, 16));
    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel1.setText("Patientendaten werden geladen ...");
    jLabel1.setVerticalAlignment(SwingConstants.TOP);
    this.getContentPane().add(jLabel1, null);
    this.getContentPane().add(jProgressBar1, null);
    jLabel1.setVisible(true);
    // Kein Menü in diesem Frame
    this.setMenuBar(null);
    // Größe setzen, sonst gibt´s nur den Überschriftsbalken als Anzeige
    this.setSize(250, 70);
  }

  public void SetValue(int nProzent)
  { jProgressBar1.setValue(nProzent);
  }
}

I call this from my super-class like this:



Fortschrittsanzeige jFortschrittFrame = new Fortschrittsanzeige();
       
Dimension dlgSize = jFortschrittFrame.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
jFortschrittFrame.setLocation((frmSize.width - dlgSize.width) / 2 +
 loc.x,
 (frmSize.height - dlgSize.height) / 2 +
 loc.y);
jFortschrittFrame.setVisible(true);
jFortschrittFrame.show();

... but: the text and the ProgressBar doesn´t appear in my window. There is only a white background (and this is set to LightGray with the properties in my JBuilder-design-window.)

Thank´s in advance for your help.
spetrowitschAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

momlalCommented:
Hi,
First of all the loading of records from a database you must make from a thread. If you don't then the application/applet will not process  events until the loading continues. This is the reason for the window to appear with white background and without components.
The frame source is OK.
Momchil
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
spetrowitschAuthor Commented:
Hi momlal,

I call several times the method
jFortschrittFrame.SetValue(...);

Shouldn´t that be o.k.?
0
momlalCommented:
HI spetrowitsch,
The problem is not howmany times you call "setValue" but that the frame doesn't receive paint events.
One solution is loading from the database in Thread the other is calling repaint() method of the frame from time to time.
0
momlalCommented:
HI spetrowitsch,
The problem is not howmany times you call "setValue" but that the frame doesn't receive paint events.
One solution is loading from the database in Thread the other is calling repaint() method of the frame from time to time.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.