0
幫助IM沮喪的鍵盤輸入,不能找到用於joption窗格中輸入掃描方法。我需要從對話框中讀取用戶輸入,但是我的in = a.nextInt失敗。這要是以後(輸入= 1),一定的形狀會被吸引,什麼是掃描對話框中輸入誰能幫助塗料方法(joption窗格)
import java.awt.*;
import javax.swing.*;
import java.util.Scanner;
public class Paint extends JPanel {
public Paint() {
Scanner a = new Scanner(System.in);
in = a.nextInt(JOptionPane.showInputDialog("Please enter number: "));
setBackground(Color.WHITE);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
if(in == 1){
g.setColor(Color.BLACK);
g.drawLine(400, 400, 400, 350);
g.drawLine(400, 350, 350, 350);
}
}
}