야구게임을 작성하고 있고 수동좌표 안잡고 그냥 돌리면 제대로 돌아가는데
수동좌표 설정하고 돌리니 계속
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
이런 오류가 뜨는군요;;
2시간째 해매고 있습니다 ㅠ
부탁드릴게요
아래는 코드입니다
package aasd;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class baseball extends Frame implements ActionListener{
Button btnPlay;
Button btnNewGame;
Label lblFirstNum;
Label lblSecondNum;
Label lblThirdNum;
int firstNum = 0;
int secondNum = 0;
int thirdNum = 0;
Label lblMessage;
Label lblstrike;
Label lblball;
Label lblout;
TextField num1 = new TextField(20);
TextField num2 = new TextField(20);
TextField num3 = new TextField(20);
public baseball(String str){
super(str);
setLayout(null);
lblstrike = new Label("strike :");
lblstrike.setBounds(20,200,60,20);
lblball = new Label("ball :");
lblball.setBounds(220,200,60,20);
lblout = new Label("out :");
lblout.setBounds(420,200,60,20);
TextField num1 = new TextField(20);
num1.setBounds(80,80,60,20);
TextField num2 = new TextField(20);
num2.setBounds(280,80,60,20);
TextField num3 = new TextField(20);
num3.setBounds(480,80,60,20);
Label lblnum1 = new Label("첫번째 수");
lblnum1.setBounds(20,80,60,20);
Label lblnum2 = new Label("두번째 수");
lblnum2.setBounds(220,80,60,20);
Label lblnum3 = new Label("세번째 수");
lblnum3.setBounds(420,80,60,20);
btnPlay = new Button("Play");
btnPlay.addActionListener(this);
btnPlay.setBounds(420, 120, 100, 30);
btnNewGame = new Button("New Game");
btnNewGame.addActionListener(this);
btnNewGame.setBounds(0,25,100,30);
lblFirstNum = new Label("First Num");
lblFirstNum.setBounds(20,180,100,20);
lblSecondNum = new Label("Second Num");
lblSecondNum.setBounds(200,180,100,20);
lblThirdNum = new Label("Third Num");
lblThirdNum.setBounds(400,180,100,20);
lblMessage = new Label("");
lblMessage.setBounds(220,260,100,30);
add(lblnum1); add(num1);
add(lblnum2); add(num2);
add(lblnum3); add(num3);
add(btnPlay);
add(btnNewGame);
add(lblFirstNum);
add(lblSecondNum);
add(lblThirdNum);
add(lblMessage);
add(lblstrike);
add(lblball);
add(lblout);
setSize(800,600);
addWindowListener(new WindowHandler());
setVisible(true);
}
public void actionPerformed(ActionEvent e){
Object obj = e.getSource();
if((Button)obj == btnNewGame){
Random R = new Random();
firstNum = 0;
secondNum = 0;
thirdNum = 0;
while((firstNum==secondNum)||(firstNum==thirdNum)||(secondNum==thirdNum)){
firstNum = Math.abs(R.nextInt(10));
secondNum = Math.abs(R.nextInt(10));
thirdNum = Math.abs(R.nextInt(10));
}
lblFirstNum.setText("FirstNum : " + String.valueOf(firstNum));
lblSecondNum.setText("SecondNum : " + String.valueOf(secondNum));
lblThirdNum.setText("ThirdNum : " + String.valueOf(thirdNum));
}
if((Button)obj == btnPlay){
int countStrike = 0;
int countBall = 0;
int num1int = Integer.parseInt(num1.getText());
int num2int = Integer.parseInt(num2.getText());
int num3int = Integer.parseInt(num3.getText());
if(num1int == firstNum){
countStrike++;
}
else if(num1int == secondNum || num1int == thirdNum){
countBall++;
}
if(num2int == secondNum){
countStrike++;
}else if(num2int == firstNum || num2int == thirdNum){
countBall++;
}
if(num3int == thirdNum){
countStrike++;
}else if(num3int == firstNum || num3int == secondNum){
countBall++;
}
lblstrike.setText("strike :" + String.valueOf(countStrike));
lblball.setText("ball :" + String.valueOf(countBall));
if(countStrike == 3){
lblout.setText("Out : 1");
lblMessage.setText("축하합니다. 아웃입니다.");
}else{
lblMessage.setText(String.valueOf(countStrike) + "스트라이크" + String.valueOf(countBall) + "볼 입니다.");
}
}
}
public static void main(String[] args)
{
new baseball("baseball");
}
}
class WindowHandler extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}