• 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

Icon and JManuBar

 
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi:
I want to place an image in the manu bar of a frame. Similar to the one in the top right cornder of internet explorer.
I used the followin code with no luck:

ImageIcon icon = new ImageIcon("", Constants.CONNECT_IMAGE);
JLabel iconLabel = new JLabel("icon", icon, SwingConstants.CENTER);
add(iconLabel, BorderLayout.EAST);

The label appears, but the image doesn't. Also, it doesn't appear in the east corner.
Any help is appreciated
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Try this one out , it seems u didnt give the relative path to the
image.
1) The first argument to the ImageIcon constructor specifies the file
to load, relative to the directory containing the application's class
file.
2) The second argument provides a description of the icon.

ImageIcon icon = new ImageIcon("images/middle.gif",
"Inam Reyi ");
label1 = new JLabel("some text", icon, JLabel.CENTER);


I hope this solves ur prob.


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic