spetrowitsch
asked on
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().setL ayout(vert icalFlowLa yout1);
this.setResizable(false);
jProgressBar1.setMaximumSi ze(new Dimension(150, 16));
jProgressBar1.setMinimumSi ze(new Dimension(150, 16));
jProgressBar1.setMaximum(1 00);
jProgressBar1.setMinimum(0 );
jLabel1.setMaximumSize(new Dimension(374, 32));
jLabel1.setMinimumSize(new Dimension(187, 16));
jLabel1.setPreferredSize(n ew Dimension(187, 16));
jLabel1.setHorizontalAlign ment(Swing Constants. CENTER);
jLabel1.setText("Patienten daten werden geladen ...");
jLabel1.setVerticalAlignme nt(SwingCo nstants.TO P);
this.getContentPane().add( jLabel1, null);
this.getContentPane().add( jProgressB ar1, 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(nPr ozent);
}
}
I call this from my super-class like this:
Fortschrittsanzeige jFortschrittFrame = new Fortschrittsanzeige();
Dimension dlgSize = jFortschrittFrame.getPrefe rredSize() ;
Dimension frmSize = getSize();
Point loc = getLocation();
jFortschrittFrame.setLocat ion((frmSi ze.width - dlgSize.width) / 2 +
loc.x,
(frmSize.height - dlgSize.height) / 2 +
loc.y);
jFortschrittFrame.setVisib le(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.
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().setL
this.setResizable(false);
jProgressBar1.setMaximumSi
jProgressBar1.setMinimumSi
jProgressBar1.setMaximum(1
jProgressBar1.setMinimum(0
jLabel1.setMaximumSize(new
jLabel1.setMinimumSize(new
jLabel1.setPreferredSize(n
jLabel1.setHorizontalAlign
jLabel1.setText("Patienten
jLabel1.setVerticalAlignme
this.getContentPane().add(
this.getContentPane().add(
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(nPr
}
}
I call this from my super-class like this:
Fortschrittsanzeige jFortschrittFrame = new Fortschrittsanzeige();
Dimension dlgSize = jFortschrittFrame.getPrefe
Dimension frmSize = getSize();
Point loc = getLocation();
jFortschrittFrame.setLocat
loc.x,
(frmSize.height - dlgSize.height) / 2 +
loc.y);
jFortschrittFrame.setVisib
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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.
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.
ASKER
I call several times the method
jFortschrittFrame.SetValue
Shouldn´t that be o.k.?