I have in my code the following method:
public String a(){
String answer = null;
JFrame frame = new JFrame();
frame.setBounds(150, 150, 600, 600);
JPanel p = new JPanel();
p.setBackground(Color.red);
JButton button = new JButton("button");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
answer = "answer";
}
});
p.add(button);
frame.add(p);
frame.setVisible(true);
while(answer == null){
Thread.sleep(10);
}
return answer;
}
When I call this method from the main thread, everything shows normally, and the method works. But when I call it from the AWT_Thread
the frame comes out completely blank.