I'm developing a JDialog with some components inside as JLabels, JButtons and so on... these stuff are filled in through a file. Ther's also a JComboBox that define which file should be read and every time this JComboBox is changed, I need to refresh my JDialog. Found this but I haven't understood how to deal with it.
This is what I'm doing now:
public class ConfDialog extends JDialog
{
public ConfDialog(JFrame parent, String title, int whidth, int eight)
{
super(parent, title, Dialog.ModalityType.APPLICATION_MODAL);
this.setSize(new Dimension(whidth, eight));
this.setLocation(200, 200);
this.setResizable(false);
this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
components();
}
public void components()
{
//JLabels, JButtons, ecc... declarations
final JComboBox<File> box = new JComboBox<File>(stuffInFolder);
box.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
validate();//<----
repaint(); //<----
}
});
//...something else...
}
@Override
public void repaint()
{
components();
super.repaint();
}
}