I guess i know what you want to do.
But the dialog is modal so you wont be able to capture the clicks.
I was wondering if you can do it by making another frame instead of the dialog
& turning it always-on-top(only in Tiger).
A very raw example :
import javax.swing.*;
import javax.swing.DefaultComboBoxModel;
import java.awt.event.*;
class H
{
public static void main(
String[] args)
{
JFrame frame = new JFrame();
JFrame iframe = new JFrame();
final JLabel lbl = new JLabel("Hello");
iframe.getContentPane().add(lbl);
String[] petStrings = { "Bird", "Cat", "Dog", "Rab@bit", "Pig" };
try{
iframe.setAlwaysOnTop(true); // only in 1.5
}catch(Exception e){e.printStackTrace();}
//Create the combo box, select item at index 4.
//Indices start at 0, so 4 specifies the pig.
JComboBox petList = new JComboBox(new DefaultComboBoxModel(petStrings));
petList.addItemListener(new ItemListener(){
public void itemStateChanged(ItemEvent e){
lbl.setText(e.paramString());
}
});
petList.setSelectedIndex(3);
frame.getContentPane().add(petList);
frame.pack();
frame.setVisible(true);
iframe.pack();
iframe.setVisible(true);
}
}
[ January 08, 2007: Message edited by: Vishal Mungi ]