Popup doesn't show up

I want to monitor the progress of a time consuming task in java 1.5.

I found class Popup, and wrote the following test. The label doesn't show in the popup, its just empty.

What's wrong?

Btw, I sent a good deal of time searching for examples.

Does anyone know of good, complete code examples with more "perifer" (?) swing classes like Popup?

Or a good book on the subject?

THANKS!

Jonas E.

Here's the code:

import javax.swing.*;

import java.awt.event.*;

import java.awt.*;

public class PopupTest

{

public static void main (String [] args)

{

final JFrame f = new JFrame ();

f.setLocation (400, 200);

final JPanel pane = new JPanel (true);

JButton b = new JButton ("Popup");

pane.add (b);

final JTextField label = new JTextField ("a label...");

label.setColumns (20);

label.setBorder (BorderFactory.createTitledBorder ("The field..."));

b.addActionListener (new ActionListener (){

public void actionPerformed (ActionEvent ae){

PopupFactory pf = PopupFactory.getSharedInstance ();

Point p = f.getLocationOnScreen ();

//Et.dis ("point: " + p);

int x = (int) p.getX ();

int y = (int) p.getY ();

Popup pu = pf.getPopup (null, label, x, y);

pu.show ();

for (int i = 0; i < 6; i++){

label.setText ("update " + i);

try {Thread.currentThread ().sleep (500);}

catch (Exception ignore){}

}

pu.hide ();

// to check that label really is "showable"

pane.add (label);

f.pack ();

}

});

f.setContentPane (pane);

f.pack ();

f.setVisible (true);

}

}

[1733 byte] By [Jonas.Edlunda] at [2007-11-26 21:51:42]
# 1
I suggest you look into javax.swing.ProgressMonitor.#
duckbilla at 2007-7-10 3:45:17 > top of Java-index,Desktop,Core GUI APIs...
# 2
Don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the posted code retains its original formatting.[url http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html]How to Use Progress Bars[/url]
camickra at 2007-7-10 3:45:17 > top of Java-index,Desktop,Core GUI APIs...