Skip to main content

Problem with java program

1 reply [Last post]
mick463
Offline
Joined: 2009-03-19
Points: 0

Hi don't know if i am in the right place so sorry if i am in the wrong one .

Hi this program i wrote works right up untill i put in the line

if (i1 > 60 || i2 > 60) {

JOptionPane.showMessageDialog(null,i1, i2 +" Is Not In Vaild Range must be less than 60 ", "ERROR!" , JOptionPane.ERROR_MESSAGE);

}
else {

Then i get the error message when i compile

micks.java:27:cannot find symbol.

symbol : method showMessageDialog<,int,java.lang.String,java.lang.String,int)

location : class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null,i1, i2 +" Is Not In Vaild Range must be less than 60 ", "ERROR!" , JOptionPane.ERROR_MESSAGE);

There is an arrow under the first " next to the "ERROR" ^
1 error

Here is the whole code

import javax.swing.JOptionPane;

public class micks {

public static void main (String [] args) {

while (true){
String one = JOptionPane.showInputDialog(null,"Please enter your start hours and minutes" ,"Convertor",JOptionPane.QUESTION_MESSAGE );

String two = JOptionPane.showInputDialog(null,"Please enter your finnish hours and minutes","Convertor",JOptionPane.QUESTION_MESSAGE);

int i1 = Integer.parseInt(one);

int i2 = Integer.parseInt(two);

if (i1 > 60 || i2 > 60) { //if this line is wrong how do i fix it please i am at a loss
JOptionPane.showMessageDialog(null,i1, i2 +" Is Not In Vaild Range must be less than 60 ", "ERROR!" , JOptionPane.ERROR_MESSAGE);

}

//If you comment out from the if statement to the else statement and one of the last curly brackets the program works it is a little rough but it works out the difference between two times
else {
int mincalc = (i2 - i1);
int hourscalc = (i2 - i1);

if (mincalc < 0) {
hourscalc = hourscalc -1;
mincalc = 60 + mincalc;
}
JOptionPane.showMessageDialog(null," Hour min" + mincalc );
System.exit(0);
}
} }

}

Please can any one help i have only done 6 lessons of java and this has driven me mad?????????????????????????????? Thank you.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barajas
Offline
Joined: 2009-09-02
Points: 0

Hi,

You use too many params in function:
1. showMessageDialog(Component parentComponent, Object message)
2. showMessageDialog(Component parentComponent, Object message, String title, int messageType)
3. showMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon)

---------------------------------------------
[url=http://www.softsea.com/review/Java-Desktop-SMS.html]java desktop sms[/url]