Reputation: 57
if i have add a number and i print it in a new page(JFrame). now, i want to get back to
previous page to add another number.
how to write the code? because i want to keep thw new page open and back to previous page. the
new page is to display what the number that have been added by the user. totally no idea with
it.
i've try this
first frame called 'frame1'
second frame called 'frame2'
public static boolean isClicked = true;
if(btnOK.equals(isClicked))
{
frame2.setVisible(true);
frame1.setVisible(false);
}
Upvotes: 0
Views: 894
Reputation: 36423
1) The use of multiple JFrame
s in Java is a bad practice see here:
2) I would suggest using a LayoutManager
like CardLayout
which allows you to flip between containers like JPanel
s on a single JFrame
:
3) You might also want to substitute your initial JFrame
for a JDialog
/JOptionPane
, but that would depend on the usage of the initial JFrame
.
Upvotes: 3