This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

to add image in prog

 
mandeep singh
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import javax.swing.*;
import java.awt.*;
class gf
{
JFrame f1;
JPanel p1;
JLabel pic;
JButton b1;
public gf()
{
f1=new JFrame("Yahoo.com");
f1.setSize(200,200);
f1.setVisible(true);
p1=new JPanel();
f1.getContentPane().add(p1);
Icon g1=new ImageIcon;
Icon g1=new ImageIcon("c:\\honey.JPEG");
pic=new JLabel(g1);
p1.add(pic);
b1=new JButton("accepted");
}
public static void main(String jj[])
{
gf d1=new gf();
}
}

Dear my friends i am learning java ..In my this programme i am unable to add image..2 errorscar.java:17: g1 is already defined in car()
Icon g1=new ImageIcon("c:\\honey.JPEG");and other is { or ] expected..... how it can be solve
 
Ted Smyth
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mandeep singh:


Dear my friends i am learning java ..In my this programme i am unable to add image..2 errorscar.java:17: g1 is already defined in car()
Icon g1=new ImageIcon("c:\\honey.JPEG");and other is { or ] expected..... how it can be solve


Use code tags please!

You declare the variable g1 twice in row. There's no need to call 2 constructors on one object.

Remove this line:


And just use this:
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic