I'd need to handle an error condition with the help of a JFrame:
catch (FormatterException e) {
displayJFrame();
System.out.println("Execution continues");
}
Basically, within the JFrame I'd enter manually the data that failed in a textarea and click on a JButton (for brevity this is just the JFrame and JButton):
static void displayJFrame() {
JFrame frame = new JFrame("JFrame recovery window");
// create our jbutton
JButton showDialogButton = new JButton("Submit");
// add the listener to the jbutton to handle the "pressed" event
showDialogButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
}
});
// put the button on the frame
frame.getContentPane().setLayout(new FlowLayout());
frame.add(showDialogButton);
// set up the jframe, then display it
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(300, 200));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
I'd need that, when the Button is pressed, the frame is disposed and execution of the main thread continues. Unfortunately it doesn't work like that. The main thread prints the "execution continues" before the frame is disposed. Is there a way to achieve that in Swing/AWT API?
Thanks