"Transparent JWindow" What's the solution?

Hello:

I'm trying to develope a Java GUI application. In my program, a Jframe is shown and, when I press a button, I make some long opperation with data. I would like that, during I operate with the data, a JWindow is shown.

However, I have had a problem. When I try to set visible the JWindow, it appears "transparent". Why does it happen? Could you please solve this problem?

Here you can find some code:

Wait w =new Wait(this, 1000000);

// Operate with the data

w.setVisible(false);

w.dispose();

And the code for the Wait class is:

public Wait(java.awt.Frame parent,int waitTime)

{

super(parent);

initComponents();

setSize(540, 220);

setVisible(true);

final Runnable closeRunner =new Runnable()

{

publicvoid run()

{

}

};

Runnable waitRunner =new Runnable()

{

publicvoid run()

{

try

{

}

catch(Exception e)

{

Toolkit.getDefaultToolkit().beep();

}

}

};

}

privatevoid initComponents(){

jPanel1 =new javax.swing.JPanel();

jLabel2 =new javax.swing.JLabel();

jLabel3 =new javax.swing.JLabel();

jLabel4 =new javax.swing.JLabel();

barra =new javax.swing.JProgressBar();

getContentPane().setLayout(null);

setCursor(new java.awt.Cursor(java.awt.Cursor.WAIT_CURSOR));

jPanel1.setLayout(null);

jPanel1.setBackground(new java.awt.Color(255, 255, 102));

jPanel1.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 51, 255), 4,true));

jLabel2.setFont(new java.awt.Font("Arial Black", 1, 24));

jLabel2.setForeground(new java.awt.Color(0, 0, 204));

jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

jLabel2.setText("S'ESTAN RECOPILANT DADES...");

jPanel1.add(jLabel2);

jLabel2.setBounds(10, 10, 520, 35);

jLabel3.setFont(new java.awt.Font("Arial Black", 1, 24));

jLabel3.setForeground(new java.awt.Color(0, 51, 204));

jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

jLabel3.setText("AQUEST PROC\u00c9S POT");

jPanel1.add(jLabel3);

jLabel3.setBounds(0, 70, 540, 35);

jLabel4.setFont(new java.awt.Font("Arial Black", 1, 24));

jLabel4.setForeground(new java.awt.Color(0, 0, 204));

jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

jLabel4.setText("TARDAR ALGUNS MINUTS");

jPanel1.add(jLabel4);

jLabel4.setBounds(60, 110, 366, 35);

jPanel1.add(barra);

barra.setBounds(40, 170, 470, 18);

getContentPane().add(jPanel1);

jPanel1.setBounds(-2, 0, 540, 220);

pack();

}

/**

* @param args the command line arguments

*/

// Variables declaration - do not modify

private javax.swing.JProgressBar barra;

private javax.swing.JLabel jLabel2;

private javax.swing.JLabel jLabel3;

private javax.swing.JLabel jLabel4;

private javax.swing.JPanel jPanel1;

// End of variables declaration

[5148 byte] By [pujolsa] at [2007-10-3 9:47:28]
# 1

sounds like you're using the EDT for your

"I make some long opperation with data"

the EDT also handles painting, so, while it is busy doing your long operation,

it cannot paint the window until the process is finished, and then you probably

dispose the window anyway.

the fix is to do your "I make some long opperation with data" in a separate thread

Michael_Dunna at 2007-7-15 5:04:26 > top of Java-index,Desktop,Core GUI APIs...