• 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

JPanel.add() method error

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JPanel menuPanel = new JPanel();
ImageIcon statImage = new ImageIcon("images/java/sleepinghead.jpeg");
Image image = statImage.getImage();
JLabel myLabel = new JLabel("Doggy",image,JLabel.CENTER);
menuPanel.add(myLabel);

gives this error
<identifier> expected
menuPanel.add(myLabel);
^
can somebody tell me something
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import javax.swing.*;

class demo1
{

public static void main(String[] args)
{
JFrame frame = new JFrame();

frame.setSize(500,500);

frame.setVisible(true);

JPanel mypanel = new JPanel();

ImageIcon ic = new ImageIcon("C:/Documents and Settings/rajaramesh/Desktop/independence-wing.jpg");

//Image i = ic.getImage();

JLabel l = new JLabel("India",ic,JLabel.CENTER);

mypanel.add(l);

frame.getContentPane().add(mypanel);

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