-1

I am a student who is trying to create a simple application using Leap motion controller API's.

So, what I have is a screen on which I am performing a circle gesture to go to next screen.

I have created a simple GUI implementing a circle gesture on both the screens. But, I am having trouble when I want to switch back to previous screen. The full code can be found here:

https://github.com/samarth003/codeGist

Please help me in this regard.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Samarth
  • 35
  • 1
  • 7
  • 2
    You should use different panels and switch between panels not jframes. Here you find other options: http://stackoverflow.com/questions/9554636/the-use-of-multiple-jframes-good-bad-practice – pL4Gu33 May 29 '14 at 08:50
  • 1
    See [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson May 29 '14 at 09:54

2 Answers2

0

I think it's better to design a swing GUI with one JFrame with multiple JPanel. If you want to switch the screen just

setContentPanel(yourPanel);

you can do it from an ActionLIstener from one panel to switch other panel. I have my own simple code to move screen with java swing.

startPanel.btnNewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setContentPane(menuPanel);
        }
    });
-1

You can remove a JFrame by calling the dispose() method on it or by setting its visibility using setVisible(false).

In your case, you can create your second JFrame and then dispose or set the previous JFrame to invisible and vice versa. However, it is rather strange to be using multiple JFrames in your case as pL4Gu33 has mentioned.

David Yee
  • 3,515
  • 25
  • 45