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
SCJD 1.4<br />SCJP 1.4<br />-----------------------------------<br />"With regard to excellence, it is not enough to know, but we must try to have and use it.<br />" Aristotle
posted 11 years ago
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);