Results 1 to 4 of 4
  1. #1
    SeaStorm is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Unhappy Help with two java forms

    Hello, I've found this forum after exhaustive search on the internet...

    I'm trying to make two forms with the Netbeans editor. One that contains an introduction to the game and another that has the game itself. Both forms are created with the Drag/Drop features of Netbeans, with auto-generation of code. The problem is I want the program to close Display.java and open Choice.java when the user clicks on Label1 ...

    I'm beginner to java and I don't know how swing works in depth .. It has been two nights for me to find out the code to do this ... can any one help me in this specific task ?

    thanks

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

    Default

    To learn about Swing coding, you need to read the Swing tutorials which you can find here:

    Lesson: Using Swing Components (The Java™ Tutorials > Creating a GUI With JFC/Swing)

    As you're finding out, there's a lot more to it than dragging and dropping.

    If you want to do an action on clicking a JLable, then you'll want to add a MouseListener to that JLabel whose mousePressed method does the desired action. If you read the tutorial section on MouseListeners, you'll know what I'm talking about. Much luck!

  3. #3
    SeaStorm is offline Member
    Join Date
    May 2010
    Posts
    2
    Rep Power
    0

    Default

    Thanks .. Now that is done using automated code ...
    Java Code:
    private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {                                     
    }
    The Problem is what is to put in the function .. I'm obviously noob in java .. but my project depends on this thing

    waiting for your reply !

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

    Default

    Again I refer you to the tutorials so you can learn how to code in Swing and how to do this specifically. We're not going to write this for you.

    edit: Look into disposing your current JFrame or JDialog and displaying the new JFrame. Methods that can help include setVisible(boolean visible), dispose(), etc...
    Last edited by Fubarable; 05-03-2010 at 02:16 AM.

Similar Threads

  1. Issues with a particular website (Java + forms)
    By aromes in forum Advanced Java
    Replies: 1
    Last Post: 04-13-2009, 04:16 AM
  2. Replies: 2
    Last Post: 04-28-2008, 11:56 AM
  3. Full Forms of Java Tech
    By Gajesh Tripathi in forum New To Java
    Replies: 1
    Last Post: 10-18-2007, 10:59 AM
  4. Creating Sub forms in java netbeans 5.0
    By java_newbie in forum NetBeans
    Replies: 14
    Last Post: 08-06-2007, 08:19 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
  •