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

    Default how to use Multiple GUI pages

    I have a noob question here.

    Im creating a program to keep track of my dvd collection. When it starts up it has a page with two Jbuttons. One listed to create a new record and one to view the titles currently owned. My question is how do i link this gui's page with an action so that when i click on the "New Movie" button for example it brings up the gui i created that allows me to enter in the information for the movie.

    I used javafx to create the guis and they are each currently in their own separate JFrame form. Some guidance here would be great. Thanks

  2. #2
    Reshi is offline Member
    Join Date
    Dec 2010
    Posts
    4
    Rep Power
    0

    Default

    You can do it by creating a new JForm and initialising it inside the button method(this creates a new window). Let me explain.
    You have created two buttons for example "jButton1" and "jButton2", and they are inside the window "WindowA"
    You have ActionEvent, if jButton1 is clicked (action performed) something happens. The thing that has to happen is that inside the method of the action performed of the button you create a new instance of new JFrame("WindowB").
    Ex. code:

    WindowA (with buttons)
    Java Code:
    public class WindowA extends javax.swing.JFrame {
        
    public WindowA(){
        initComponents();
        }
    
    private void jButton1ActionPerformed (java.awt.event.ActionEvent evt){
         new WindowB().setVisible(true);
    
    ..... 
    .....
    WindowB (that you want to show by clicking the button)

    Java Code:
    public class WindowB extends javax.swing.JFrame {
    
        public WindowB{
            initComponents();
        }
    
    etc etc
    Hope it helps :) This is code that is without all initialisations because i wrote it from the NetBeans JFrame designer but the main thing i wanted to tell you is there :)

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

    Default

    You can do it by creating a new JForm and initialising it inside the button method(this creates a new window).
    1. There's no such class as JFrom.
    2. Using more than one JFrame in an application is usually a bad idea.

    db

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

    Default

    how do i link this gui's page with an action so that when i click on the "New Movie" button for example it brings up the gui i created
    One of two may suit:
    a) Use a JOptionPane / modal JDialog
    OR
    b) Set a CardLayout and swap the cards.

    db

Similar Threads

  1. Running multiple threads on multiple CPU cores?
    By Dosta in forum Threads and Synchronization
    Replies: 2
    Last Post: 09-19-2010, 04:48 PM
  2. can i process two web pages at once?
    By saurabh208 in forum Java Servlet
    Replies: 2
    Last Post: 08-25-2010, 10:11 AM
  3. Replies: 0
    Last Post: 02-12-2008, 06:05 PM
  4. Printing Swing components in multiple pages
    By Rajeswari in forum New To Java
    Replies: 1
    Last Post: 07-27-2007, 06:49 PM
  5. Printing Swing components in multiple pages
    By Rajeswari in forum AWT / Swing
    Replies: 0
    Last Post: 07-27-2007, 06:01 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
  •