Results 1 to 4 of 4
Thread: Can anyone help? image prob
- 04-20-2012, 05:46 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
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!
-
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.
- 04-20-2012, 05:54 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 2
- Rep Power
- 0
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
-
Re: Can anyone help? image prob
Please have a look at this tutorial that discusses use of import: The Java Tutorials: Using Package Members
Similar Threads
-
Lil prob
By imu09 in forum CLDC and MIDPReplies: 8Last Post: 04-28-2011, 05:30 PM -
for each prob
By kusumathatavarthi in forum New To JavaReplies: 7Last Post: 05-21-2008, 01:00 PM -
Threading prob..
By banie in forum Java AppletsReplies: 0Last Post: 02-05-2008, 06:30 AM -
having prob with Exception
By eva in forum New To JavaReplies: 1Last Post: 01-04-2008, 05:44 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks