• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

panel and image problem

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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();

}
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
alun groome
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply, I tried your code out, and i am still having the exact same problem???

cheers
 
reply
    Bookmark Topic Watch Topic
  • New Topic