0
這裏是我的代碼:的JOptionPane找不到方法
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 a time"));
break;
}
time = time * 1000;
String str = JOptionPane.showInputdialog("Enter the 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 is not Connected", "Alert", JOption.ERROR_MESSAGE);
}
}
catch (Exception e)
{}
}
}
這裏是我得到的錯誤:
icmp.java:23: error: cannot find symbol
String str = JOptionPane.showInputdialog("Enter the IP address");
^
symbol: method showInputdialog(String)
location: class JOptionPane
icmp.java:34: error: cannot find symbol
JOption.showMessageDialog(null,str+ "Host is not Connected","Alert",JOption.ERROR_MESSAGE);
^
symbol: variable JOption
location: class icmp
icmp.java:34: error: cannot find symbol
JOption.showMessageDialog(null,str+ "Host is not Connected","Alert",JOption.ERROR_MESSAGE);
^
symbol: variable JOption
location: class icmp
3 errors