-2

I created a "application window" in a Eclipse and i used the following code to dispose 'frame' and open another jframe 'TableData' which worked as i expected.

frame.dispose();     //private JFrame frame;
TableData td = new TableData();
td.setVisible(true);

Now, my problem is, I want to create 'go back' button in 'TableData' class which dispose 'TableData' and open 'frame' again.

i tried many ways but non of those work as i thought.

How can I do it????

Nawa
  • 35
  • 3
  • 10
  • 4
    [Don't do that](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice) – Branislav Lazic Feb 12 '15 at 17:10
  • @BranislavLazic why???? – Nawa Feb 12 '15 at 17:11
  • 4
    If you want to irritate users of your program, then throw a bunch of JFrames at them. Much better though would be to swap JPanel views in a single JFrame using a [CardLayout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html). To know why @BranislavLazic posted what he did, please read [his link](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice). – Hovercraft Full Of Eels Feb 12 '15 at 17:11
  • @BranislavLazic if i should not have to do it then what else i can do??? – Nawa Feb 12 '15 at 17:12
  • Read his link. His whole comment is a [link](http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice). – Hovercraft Full Of Eels Feb 12 '15 at 17:12
  • @BranislavLazic let me make things clear, i am new to java and just trying to learn gui java, if you can give me a example it would be better for me. – Nawa Feb 12 '15 at 17:16
  • 3
    Just go to that link for name of god and look at the answer of Andrew Thompson. There are ton of links that lead to examples and demos. – Branislav Lazic Feb 12 '15 at 17:18
  • 1
    Use a CardLayout instead. If you need to prompt the user for small amount of information, use a modal dialog – MadProgrammer Feb 12 '15 at 20:54

1 Answers1

1

Just hide the frame as:

frame.setVisible(false);     
TableData td = new TableData();
td.setVisible(true);

and then in 'go back'

 frame.setVisible(true);