1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Java trouble shooting(GUI specifically)

Discussion in 'Software/Coding' started by NanoNet, Jun 22, 2015.

  1. NanoNet

    NanoNet Member

    Joined:
    May 23, 2014
    Messages:
    1,044
    Likes Received:
    345
    Trophy Points:
    83
    Gender:
    Male
    Location:
    IKEA
    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

    Joined:
    May 23, 2014
    Messages:
    1,044
    Likes Received:
    345
    Trophy Points:
    83
    Gender:
    Male
    Location:
    IKEA
  3. olsyboy

    olsyboy Member

    Joined:
    Jun 13, 2015
    Messages:
    215
    Likes Received:
    56
    Trophy Points:
    28
    Gender:
    Male
    Occupation:
    Student
  4. olsyboy

    olsyboy Member

    Joined:
    Jun 13, 2015
    Messages:
    215
    Likes Received:
    56
    Trophy Points:
    28
    Gender:
    Male
    Occupation:
    Student
    Also android uses Java
     
  5. NanoNet

    NanoNet Member

    Joined:
    May 23, 2014
    Messages:
    1,044
    Likes Received:
    345
    Trophy Points:
    83
    Gender:
    Male
    Location:
    IKEA
    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

    Joined:
    Jun 13, 2015
    Messages:
    215
    Likes Received:
    56
    Trophy Points:
    28
    Gender:
    Male
    Occupation:
    Student
    It does not matter, use the same principle
     
  7. alyphen

    alyphen Member

    Joined:
    Jan 4, 2014
    Messages:
    101
    Likes Received:
    96
    Trophy Points:
    28
    Gender:
    Male
    Occupation:
    Technical Consultant
    Location:
    127.0.0.1
    Home Page:
    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

    Joined:
    May 23, 2014
    Messages:
    1,044
    Likes Received:
    345
    Trophy Points:
    83
    Gender:
    Male
    Location:
    IKEA
    I learn something new from you every time, thanks!