这是我的代码,问题是当它运行时 JOptionPane 出现问题。
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
public class MoveTyper extends JFrame
{
int Location[] = {40, 40};
public static void main (String args[])
{
new MoveTyper();
}
public MoveTyper()
{
super("typetomove");
setSize(800, 450);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public void paint(Graphics g)
{
System.out.println("poop");
g.setColor(Color.BLUE);
g.fillRect(Location[0], Location[1], 20, 20);
String Axis = JOptionPane.showInputDialog("Move by X or by Y? If you would like to quit, type cancel");
int Movement = Integer.parseInt(JOptionPane.showInputDialog("How Many would you like to move up from"));
if(Axis.equalsIgnoreCase("X"))
{
Location[0] = Location[0] + Movement;
}
else if(Axis.equalsIgnoreCase("cancel"))
{
}
else
{
Location[1] = Location[1] + Movement;
}
JOptionPane.showMessageDialog(null, "You have quit. GOOD JOB. YOU SMELL");
}
当它运行时,JOptionPane 继续弹出(一个在另一个之上),好像在一个循环中,你们能帮我找出问题吗?我似乎找不到问题所在。