Java trouble shooting(GUI specifically)

Discussion in 'Plugins and Coding' started by NanoNet, Jun 22, 2015.

  1. NanoNet

    NanoNet Member

    Messages:
    1,044
    Likes Received:
    347
    Trophy Points:
    83
    As I was creating a very simple GUI, I wanted to create a JButton that when clicked(A "next" button), moves to a new "Page" or frame? So how would I go about doing this? Should I make it so when the button is clicked, the Current JFrame's visibility is false, and then set the new Frame to true? OR is there a better way to go about doing this?

    Thanks for taking your time to read this :)
     
  2. NanoNet

    NanoNet Member

    Messages:
    1,044
    Likes Received:
    347
    Trophy Points:
    83
  3. olsyboy

    olsyboy Member

    Messages:
    215
    Likes Received:
    57
    Trophy Points:
    28
  4. olsyboy

    olsyboy Member

    Messages:
    215
    Likes Received:
    57
    Trophy Points:
    28
    Also android uses Java
     
  5. NanoNet

    NanoNet Member

    Messages:
    1,044
    Likes Received:
    347
    Trophy Points:
    83
    I am not looking to make an app, I am making a GUI on my PC. I have no interest in making apps on phones.
     
  6. olsyboy

    olsyboy Member

    Messages:
    215
    Likes Received:
    57
    Trophy Points:
    28
    It does not matter, use the same principle
     
  7. alyphen

    alyphen Member

    Messages:
    101
    Likes Received:
    99
    Trophy Points:
    28
    As you're using JButton, I'm going to assume you're using Swing.
    Set the panel's layout to CardLayout. When you add each panel you want to switch between, you do so with add(myPanel, "stringIdentifierForPanel");
    Then, when the button is clicked, call layout.show(parentPanel, "stringIdentifierForPanel");
    That would achieve what you're looking for, I believe.
     
    NanoNet likes this.
  8. NanoNet

    NanoNet Member

    Messages:
    1,044
    Likes Received:
    347
    Trophy Points:
    83
    I learn something new from you every time, thanks!