Results 1 to 7 of 7
  1. #1
    adjit is offline Senior Member
    Join Date
    Mar 2011
    Posts
    171
    Rep Power
    0

    Default Java swing - help with GUI

    A basic idea of creating a game. Here is how I want it to go:

    When my program runs a JFrame pops up with a few labels and buttons etc. Initially what I had was when one of those buttons was pressed a new JFrame pops up with whatever it has in it. What I want to do is have it so instead of a new JFrame appearing when the button is pressed, it appears in the same window. Its as simple as that. Once I have that down I guess it would be easier to create a "back" button that would return me to the previous screen.

    The next thing that I wanted to do was create a game timer. To make it a bit clearer here is what I would like my layout to be.

    - A home page with the game name and 3 Buttons
    Button 1 - Instructions (Here I want to add a short video showing someone how to play the game)
    Button 2 - High Scores (Here I want to store the persons high scores from previous times of playing the game. So even if they exit out of the program their score is still saved)
    Button 3 - New Game (Here I want the user to start a new game. Once the game starts I want to have a 30 second timer for the player to answer each problem that is displayed. If they get it right they get 1 point, if they get it wrong, no points, obviously.)

    The instructions shouldn't be too hard. It would just display an animation that I created. I will obviously need some help with that.
    High Scores... I have no idea how to do that. I know how I would be able to save the users high score for 1 session, but I have no idea how I would go about saving the score of multiple sessions.
    The New Game part I am going to need quite a bit of help with. I already have the algorithm for the game it-self, my problem now is turning it into a 'game' and having the timer in it as well as having a button to say 'YES' and a box to type in the answer, to the question, if it is 'NO'

    Any help would be appreciated.
    Thanks
    Last edited by adjit; 03-16-2012 at 11:33 PM.

  2. #2
    adjit is offline Senior Member
    Join Date
    Mar 2011
    Posts
    171
    Rep Power
    0

    Default Re: Java swing - help with GUI

    Any help?

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,762
    Blog Entries
    7
    Rep Power
    21

    Default Re: Java swing - help with GUI

    Quote Originally Posted by adjit View Post
    Was trying to figure out how when a button in the JFrame was pressed I had it set to open a new frame etc. I want to know how to have it so it opens in the same window. So it clears what is already there and puts in the new stuff that I tell it to. Then also have like a 'back' button to return it back to its previous state.

    There is one other thing, how would I add a timer to a game. Like give the user 30 seconds to answer a question otherwise they get it wrong.
    Erm, if those sentences represent your train of thoughts, you should seriously work on them ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    adjit is offline Senior Member
    Join Date
    Mar 2011
    Posts
    171
    Rep Power
    0

    Default Re: Java swing - help with GUI

    Hey JosAH, no need to be so condescending, you can just say it doesn't make sense to me can you explain it more. It makes sense if you think about it for a second.

    When my program runs a JFrame pops up with a few labels and buttons etc. Initially what I had was when one of those buttons was pressed a new JFrame pops up with whatever it has in it. What I want to do is have it so instead of a new JFrame appearing when the button is pressed, it appears in the same window. Its as simple as that. Once I have that down I guess it would be easier to create a "back" button that would return me to the previous screen.

    The next thing that I wanted to do was create a game timer. To make it a bit clearer here is what I would like my layout to be.

    - A home page with the game name and 3 Buttons
    Button 1 - Instructions (Here I want to add a short video showing someone how to play the game)
    Button 2 - High Scores (Here I want to store the persons high scores from previous times of playing the game. So even if they exit out of the program their score is still saved)
    Button 3 - New Game (Here I want the user to start a new game. Once the game starts I want to have a 30 second timer for the player to answer each problem that is displayed. If they get it right they get 1 point, if they get it wrong, no points, obviously.)

    The instructions shouldn't be too hard. It would just display an animation that I created. I will obviously need some help with that.
    High Scores... I have no idea how to do that. I know how I would be able to save the users high score for 1 session, but I have no idea how I would go about saving the score of multiple sessions.
    The New Game part I am going to need quite a bit of help with. I already have the algorithm for the game it-self, my problem now is turning it into a 'game' and having the timer in it as well as having a button to say 'YES' and a box to type in the answer, to the question, if it is 'NO'

    How is that for some clarity?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,458
    Rep Power
    20

    Default Re: Java swing - help with GUI

    Quote Originally Posted by adjit View Post
    Hey JosAH, no need to be so condescending, you can just say it doesn't make sense to me can you explain it more. It makes sense if you think about it for a second.
    What's biting you? Jos wasn't being condescending, he was saying that you have a train of thought; now start implementing it.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java swing - help with GUI

    Look into using a CardLayout to swap views on command, such as swapping JPanels each holding a complex collection of components if need be.

  7. #7
    adjit is offline Senior Member
    Join Date
    Mar 2011
    Posts
    171
    Rep Power
    0

    Default Re: Java swing - help with GUI

    @db - That's not what I gathered from that statement.

    @Fubarable - I checked that out, but it doesn't accomplish what I would like it to.
    I don't want those other options to be visible (either by pull down menu or tabs)

    When those buttons are pressed I want it stay in the same window, but display the information from that specific button.

Similar Threads

  1. java swing help
    By zoheb.siddiqui in forum AWT / Swing
    Replies: 1
    Last Post: 02-28-2011, 10:06 AM
  2. Is this right!! Java Swing
    By Nifras in forum AWT / Swing
    Replies: 4
    Last Post: 05-28-2010, 08:20 PM
  3. [swing] Java and sql
    By ezee in forum AWT / Swing
    Replies: 1
    Last Post: 03-27-2009, 06:55 PM
  4. Java Swing
    By RAMYA in forum New To Java
    Replies: 3
    Last Post: 11-12-2008, 08:00 AM
  5. Java Swing
    By JavaBean in forum Java Tutorial
    Replies: 0
    Last Post: 09-22-2007, 09:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •