• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

SWING - Changing java cup to my gif

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This works:

public void go() {
JFrame frame = new JFrame("DARS Data Loader");
JPanel panel = new JPanel();
panel.setBorder(new EtchedBorder(EtchedBorder.RAISED));
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

ImageIcon image = new ImageIcon("WizardTiny.GIF");
frame.setIconImage(image.getImage());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


This does not:

public class SwingSerial extends JDialog {

public SwingSerial(JFrame frame) {
super(frame, true);
setTitle( "DARS Serialize D/B" );
ImageIcon image = new ImageIcon("WizardTiny.GIF");
setIconImage(image.getImage());
setSize(500, 300);



The Title works, but I can't get the image to replace the cup. I anticipate my approach to be wrong, but what would be the "recommended" method?
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ensure the logo has changed on the JFrame,
then pass the JFrame to the dialog

 
Carty Ellis
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I use this code:

public class SwingSerial extends JDialog {

public SwingSerial(JFrame frame) {

super(frame, true);
ImageIcon image = new ImageIcon("WizardTiny.GIF");
frame.setIconImage(image.getImage());
setTitle( "DARS Serialize D/B" );


The Title in the frame is changed, and the default (java cup) icon is gone. No errors are thrown. There is just no WizardTiny.GIF on the frame. If I comment out the ImageIcon line and the frame.setIconImage lines I get the java cup.

If I comment out just the ImageIcon line it wants an image defined.

If I comment out just the frame.setIconImage I get the java cup.

Where is the disconnect in what I am doing?

java 1.5.0_04
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say that you aren't loading the image correctly. Where is the image in relation to your class files?

ImageIcon image = new ImageIcon("WizardTiny.GIF");

And is your filename correct with caps and all?
 
Carty Ellis
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops!

Was in wrong directory. Thanks. It works now.

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic