이 코드 세그먼트는 JFrame을 만들 때 호출되며 dispose() 행에 도달하면 닫히지 않습니다. 다른 JFrame이 열리기 때문에이 블록으로 들어간다는 것을 알고 있습니다. 유일한 문제는 닫히지 않는다는 것입니다. 왜 그런지 알아?JFrame이 닫히지 않을 때
public LogIn(String title)
{
super(title);
checker = new Open("");
deserializeOpen();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(300, 300);
getContentPane().setLayout(new BorderLayout());
getContentPane().setBackground(Color.orange);
Login = new JButton("Login");
Create = new JButton("New Profile");
Login.addActionListener(this);
Create.addActionListener(this);
buttons = new JPanel();
buttons.setBackground(Color.orange);
buttons.setLayout(new GridLayout(0,2));
buttons.add(Login);
buttons.add(Create);
Title = new JLabel("Scrambler");
Title.setFont(new Font("Times New Roman", Font.BOLD, 24));
Name = new JTextField(4);
name = new JLabel("Name:");
password = new JPasswordField(4);
pass = new JLabel("Password:");
Text = new JPanel();
Text.setLayout(new GridLayout(6,0));
Text.setBackground(Color.orange);
Text.add(Title);
Text.add(name);
Text.add(Name);
Text.add(pass);
Text.add(password);
getContentPane().add(Text, BorderLayout.CENTER);
getContentPane().add(buttons, BorderLayout.SOUTH);
show();
}
public void deserializeOpen()
{
try
{
FileInputStream door = null;
try
{
door = new FileInputStream("Check.ser");
}
catch (FileNotFoundException e)
{
new Activator();
dispose();
}
if(door!=null)
{
ObjectInputStream reader = new ObjectInputStream(door);
checker = (Open) reader.readObject();
}
}
catch (IOException e){e.printStackTrace();}
catch (ClassNotFoundException e){e.printStackTrace();}
}
이러한 코드의 두 세그먼트있다가, 몸은 내가 처분() 라인이라고 확신 문제
의 원인이되는 하나의 첫 번째 부분과 직렬화 하나입니다 내가 dispose()에 대해 System.out.print() 권한을 두어 인쇄했기 때문에 도달했습니다.
뭔가가 EDT를 차단하거나 프레임의 'DefaultCloseOperation'이'DO_NOTHING'으로 설정되었습니다 ... – MadProgrammer
그냥 확인합니다. DefaultCloseOpeation은 EXIT로 설정됩니다. EDT를 막는 무언가를 고치려면 어떻게해야할까요? 나는 완전한 초보자입니다. – Achi113s
코드 스 니펫에 따라 알기가 어렵습니다. [Concurrency in Swing] (http://docs.oracle.com/javase/tutorial/uiswing/concurrency/) – MadProgrammer