• Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel.add() method error

 
joseph okon
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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
 
raja ramesh
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • 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);

}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!