java - JOptionPane Method Not found -
here's code:
import javax.swing.joptionpane; import javax.swing.*; import java.net.*; import java.*; public class icmp { public static void main(string args[]) { try { uimanager.setlookandfeel(uimanager.getsystemlookandfeelclassname()); } catch (exception e) {} int time = 0; while (true) { time = integer.parseint(joptionpane.showinputdialog("enter time")); break; } time = time * 1000; string str = joptionpane.showinputdialog("enter ip address"); try { inetaddress addr = inetaddress.getbyname(str); boolean test = addr.isreachable(time); if (test) { joptionpane.showmessagedialog(null, str + " host isconnected", "alert", joptionpane.error_message); } else { joption.showmessagedialog(null, str + "host not connected", "alert", joption.error_message); } } catch (exception e) {} } }
and here errors i'm getting:
icmp.java:23: error: cannot find symbol string str = joptionpane.showinputdialog("enter ip address"); ^ symbol: method showinputdialog(string) location: class joptionpane icmp.java:34: error: cannot find symbol joption.showmessagedialog(null,str+ "host not connected","alert",joption.error_message); ^ symbol: variable joption location: class icmp icmp.java:34: error: cannot find symbol joption.showmessagedialog(null,str+ "host not connected","alert",joption.error_message); ^ symbol: variable joption location: class icmp 3 errors
what compiler says following.
- there no
showinputdialog
method injoptionpane
class. it's namedshowinputdialog
(notice capital 'd'). found in line 23 of program. - it (the compiler) cannot find
joption
class, calledjoptionpane
. found in line 34 of program.
also, silently swallowing exceptions in code, bad practice. try avoid that.
hope helps.
Comments
Post a Comment