aaaa
aaaa

Reputation: 57

back to previous page gui

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

Answers (1)

David Kroukamp
David Kroukamp

Reputation: 36423

1) The use of multiple JFrames 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 JPanels 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

Related Questions