Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: use multiple gui displays

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default use multiple gui displays

    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 as separate classes. Some guidance here would be great. Thanks


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: use multiple gui displays

    Ok, so lets say you created a GUI that extends JFrame named NewMovieFrame. The code to allow the JButton to open the frame would look like this:
    //Our Button that will open the new JFrame
    JButton openFrame = new JButton("Open Frame");
    //We add an actionListener to the JButton
    openFrame.addActionListener(new ActionListener(){
    	public void actionPerformed(ActionEvent e)
    	{
    		/* If the constructor of the NewMovieFrame JFrame
    		 * sets itself visible, we just need to construct
    		 * the NewMovieFrame JFrame like this:
    		 */
    		new NewMovieFrame(...);
     
    		/* If however the NewMovieFrame JFrame does not set
    		 * itself visible in the constructor, we need to do
    		 * this:
    		 */
    		NewMovieFrame temp = new NewMovieFrame(...);
    		temp.setVisible(true);
    	}
    });
    //Assume we add the openFrame JButton to our main GUI

    If you show the code you have, I can help you more directly, instead of just using the example above.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

Similar Threads

  1. Multiple Multishuffles
    By dino2dy in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 10th, 2010, 01:36 PM
  2. multiple tcp connection?
    By nasser in forum Java Networking
    Replies: 4
    Last Post: July 31st, 2010, 07:35 AM
  3. Multiple JFrames
    By Scottj996 in forum AWT / Java Swing
    Replies: 1
    Last Post: April 15th, 2010, 05:24 AM
  4. Multiple Queues
    By fh84 in forum Threads
    Replies: 1
    Last Post: December 3rd, 2009, 02:28 PM
  5. Which interface gives more control on serialization of an object?
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 16th, 2009, 10:17 AM