Results 1 to 5 of 5
  1. #1
    Curtiz is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default Level Restart Button

    I've had good success following tutorials online but now i have come across a stumbling block.

    My project is a child's mathematical game.

    I want the user to be able to click "restart level" and the Frame reset all components and variables.

    I've come across repaint(); / revalidate(); and similar methods but i think the terminology escapes me.

    The code would be like this .

    If reload button is clicked.
    Repaint jframe.
    Return Variables to default.

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

    Default

    There's no magic that I know of here, but instead you're going to have to code this logic yourself. Best of luck.

  3. #3
    Curtiz is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default

    Quote Originally Posted by Fubarable View Post
    There's no magic that I know of here, but instead you're going to have to code this logic yourself. Best of luck.
    Magic? Sorry if your message got lost in translation but i don't understand you.

    I found the following methods and think these would be along the correct lines of what i am aiming for.

    public void reset()

    clearComponent(java.awt.Component comp)
    Method cleanPanel destroys any tasks that happen to live in this component.

  4. #4
    Curtiz is offline Member
    Join Date
    Mar 2010
    Posts
    6
    Rep Power
    0

    Default

    Solved it.

    Java Code:
    private void RestartActionPerformed(java.awt.event.ActionEvent evt) {
    
        score = 0 ;
        LevelProgress.setValue(score);
        Answer1.setText("");
        Answer2.setText("");
        Answer3.setText("");
        Answer4.setText("");
        Answer5.setText("");
    
        NumberSubmit1.setVisible(true);
        NumberSubmit2.setVisible(true);
        NumberSubmit3.setVisible(true);
        NumberSubmit4.setVisible(true);
        NumberSubmit5.setVisible(true);
        Answer1.setVisible(true);
        Answer2.setVisible(true);
        Answer3.setVisible(true);
        Answer4.setVisible(true);
        Answer5.setVisible(true);

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

Similar Threads

  1. Restart main
    By Syahrul in forum New To Java
    Replies: 3
    Last Post: 11-22-2009, 09:34 AM
  2. [SOLVED] Class-level vs Object-level method()
    By mfaizan24 in forum New To Java
    Replies: 7
    Last Post: 06-23-2009, 10:18 AM
  3. Make application restart itself
    By Singing Boyo in forum New To Java
    Replies: 1
    Last Post: 03-22-2009, 03:49 AM
  4. Application restart in tomcat.....
    By jithan in forum New To Java
    Replies: 1
    Last Post: 09-10-2008, 04:31 PM
  5. Restart a For loop and increment an Int value
    By dcnorman07 in forum New To Java
    Replies: 1
    Last Post: 07-12-2008, 01:24 AM

Posting Permissions

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