当我按下STime等于的JOptionPane.showInputDialog窗口上的取消按钮时,如何在此代码中阻止NullPointerException?(它位于'>>'标志)
我的代码:
insertTableF.addActionListener(new ActionListener () {
public void actionPerformed(ActionEvent e)
{
int wayPoint1 = 0;
int wayPoint2 = 0;
int PassTime = 0;
Statement statementR;
if (loggedIn == 1)
{
while(passedR ==0)
{
try
{
if (wayPoint1==0)
{
sTagR =JOptionPane.showInputDialog("Please enter the Rhino Tag number:");
iTagR = Integer.parseInt(sTagR);
wayPoint1 =1;
}
if (wayPoint2==0)
{
sGPSX = JOptionPane.showInputDialog("Please enter the horizontal GPS Grid Numbers(eg.3123):");
iGPS = Integer.parseInt(sGPSX);
wayPoint2 = 1;
}
sGPSY = JOptionPane.showInputDialog("Please enter the vertical GPS Grid Letters(eg.XXYY:");
while …Run Code Online (Sandbox Code Playgroud)