hi,
I basically have 2 problems now. Firstly the image doesnt appear on the Panel unless I resize the window, and when i move the dialog box off the screen, the image gets erased. similar to the eraser in paintbrush. I have tried doing repaint() and nothing.
And finally, the functionality is lost in the main frame when i close the dialog box
please help!!
thanks
This is a code snippet from the JFRAME that calles the dialog
class ButtonActionListener
implements ActionListener {
public void actionPerformed(ActionEvent event) {
DialogBox dialog = new DialogBox (frame, true);
dialog.setSize(100,100);
dialogsetVisible(true);
}
}
This is a snippet of the dialog. I have called this class DialogBox
private void buildGui() {
GridBagConstraints gc = new GridBagConstraints();
Container c = this.getContentPane();
c.setLayout(new GridBagLayout());
this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
ImageIcon image;
String image= getPic(1);
ImageIcon icon = new ImageIcon(getClass().getResource(image));
JLabel iconLabel;
iconLabel = new JLabel(icon);
JPanel panel = new JPanel();
panel .add(iconLabel, BorderLayout.NORTH);
JButton button = new JButton("Answer");
gc.gridx = 0;
gc.gridy = 0;
c.add(panel , gc);
gc.gridx = 0;
gc.gridy = 1;
gc.ipady = 0;
c.add(button, gc);
this.pack();
}