Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Can anyone help? image prob

  1. #1
    Ritheal is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Can anyone help? image prob

    Im having a problem with the ImageIcon.
    When i run it says cannot find symbol
    Can anyone suggest a way to change it? or maybe tell what to add or change?

    Java Code:
    import javax.swing.JOptionPane;

    public class CLau2{

    public static void main(String args[]){
    String Firstnumber,Secondnumber,Thirdnumber,c;
    int number1,number2,number3,addition,difference,multip lication;


    ImageIcon welcome = new ImageIcon("C:\\DSE\\welcome.gif");
    ImageIcon wrong = new ImageIcon("C:\\DSE\\wrong.gif");
    ImageIcon smily = new ImageIcon("C:\\DSE\\smily.gif");
    JOptionPane.showMessageDialog(null,"Start the Lau Calculator System","Calculator System",JOptionPane.INFORMATION_MESSAGE, welcome);

    Firstnumber = JOptionPane.showInputDialog("Enter First Number.");
    Secondnumber = JOptionPane.showInputDialog("Enter Second Number.");
    Thirdnumber = JOptionPane.showInputDialog("Enter Third Number.");


    number1 = Integer.parseInt(Firstnumber);
    number2 = Integer.parseInt(Secondnumber);
    number3 = Integer.parseInt(Thirdnumber);

    c=JOptionPane.showInputDialog("Calculator System"+"\n"+"[A] Addition"+"\n"+"[B] Difference"
    +"\n"+"[C] Multiplication"+"\n"+"[D] Odd/Even Number");

    if (c.equals("A")||c.equals("a")){
    addition = number1+number2+number3;
    JOptionPane.showMessageDialog(null,"The sum of 3 numbers is "+addition,"Sum",JOptionPane.INFORMATION_MESSAGE,s mily);
    }else if(c.equals("B")||c.equals("b")){
    difference=number1-number2-number3;
    JOptionPane.showMessageDialog(null,"The difference of 3 numbers is "+difference,"Difference",JOptionPane.INFORMATION_ MESSAGE,smily);
    }else if(c.equals("C")||c.equals("c")){
    multiplication=number1*number2*number3;
    JOptionPane.showMessageDialog(null,"The multiplication of 3 numbers is "+multiplication,"Multiplication",JOptionPane.INFO RMATION_MESSAGE,smily);
    }else if(c.equals("D")||c.equals("d")){
    if((number1%2)==0){
    JOptionPane.showMessageDialog(null, "First number is an even number.","Even",JOptionPane.INFORMATION_MESSAGE,sm ily);
    }else{
    JOptionPane.showMessageDialog(null, "First number is an odd number.","Odd",JOptionPane.INFORMATION_MESSAGE,smi ly);
    }
    if((number2%2)==0){
    JOptionPane.showMessageDialog(null, "Second number is an even number.","Even",JOptionPane.INFORMATION_MESSAGE,sm ily);
    }else{
    JOptionPane.showMessageDialog(null, "Second number is an odd number.","Odd",JOptionPane.INFORMATION_MESSAGE,smi ly);
    }
    if((number3%2)==0){
    JOptionPane.showMessageDialog(null, "Third number is an even number.","Even",JOptionPane.INFORMATION_MESSAGE,sm ily);
    }else{
    JOptionPane.showMessageDialog(null, "Third number is an odd number.","Odd",JOptionPane.INFORMATION_MESSAGE,smi ly);
    }
    }else{
    JOptionPane.showMessageDialog(null,"Wrong message entered!","Error",JOptionPane.ERROR_MESSAGE,wrong) ;
    }
    System.exit(0);
    }
    }


    Error code example:

    symbol: class ImageIcon
    location: class CLau2
    CLau2.java:11 error: cannot find symbol
    ImageIcon wrong = new ImageIcon ("C:\\DSE\\smily.gif");

    Please help XD!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Can anyone help? image prob

    A stupid question, I know, but do you import the ImageIcon class?

    Also, welcome to our forum! Please when posting code, try to use [code] [/code]tags so that your code retains its formatting and is readable.

  3. #3
    Ritheal is offline Member
    Join Date
    Apr 2012
    Posts
    2
    Rep Power
    0

    Default Re: Can anyone help? image prob

    haha im entirely new to this java since im a student
    what do you mean by import ImageIcon class? can you show me an example maybe?

    P.S didnt know about the tags. will use it next time i post in codes

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

Similar Threads

  1. Lil prob
    By imu09 in forum CLDC and MIDP
    Replies: 8
    Last Post: 04-28-2011, 05:30 PM
  2. for each prob
    By kusumathatavarthi in forum New To Java
    Replies: 7
    Last Post: 05-21-2008, 01:00 PM
  3. Threading prob..
    By banie in forum Java Applets
    Replies: 0
    Last Post: 02-05-2008, 06:30 AM
  4. having prob with Exception
    By eva in forum New To Java
    Replies: 1
    Last Post: 01-04-2008, 05:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •