7 Replies - 13721 Views - Last Post: 29 December 2010 - 10:53 AM Rate Topic: -----

#1 neemamahmoodi  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 30-November 10

Connecting Two JFrames

Posted 29 December 2010 - 05:43 AM

I have two JFrames one has three buttons, login, create account and quit

When I click login i want it to go to another frame that you enter your password and username, how can i connect the two frames
Is This A Good Question/Topic? 0
  • +

Replies To: Connecting Two JFrames

#2 Paars  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 39
  • Joined: 11-October 10

Re: Connecting Two JFrames

Posted 29 December 2010 - 05:55 AM

You could just change the buttons on your first JFrame and JTextFields, else you could just open a new JFrame.(Where you could send the paramaters gotten from the first JFrame.
Was This Post Helpful? 0
  • +
  • -

#3 neemamahmoodi  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 30-November 10

Re: Connecting Two JFrames

Posted 29 December 2010 - 05:57 AM

View PostPaars, on 29 December 2010 - 04:55 AM, said:

You could just change the buttons on your first JFrame and JTextFields, else you could just open a new JFrame.(Where you could send the paramaters gotten from the first JFrame.


So I create a second JFrame and then what do I type in code to make it when I click the login button it goes to that second JFrame
Was This Post Helpful? 0
  • +
  • -

#4 Paars  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 39
  • Joined: 11-October 10

Re: Connecting Two JFrames

Posted 29 December 2010 - 06:01 AM

You create the second JFrame after you click the login button.
Or you could change your original JFrame into what it has to be after you click in login.

All is done in your MouseListener functions.
Was This Post Helpful? 0
  • +
  • -

#5 japanir  Icon User is offline

  • jaVanir
  • member icon

Reputation: 1010
  • View blog
  • Posts: 3,025
  • Joined: 20-August 09

Re: Connecting Two JFrames

Posted 29 December 2010 - 06:04 AM

hmm.. Why different Frames? why not using one JFrame as the "window", and implement each screen (login, create acount etc) as JPanels?
You can use a Card Layout.
However if you still want to use JFrames, you can switch between the Frames by using setVisible(boolean B) method.
set the previous active Frame to setVisible(false), and the current active frame should be setVisible(true).
Was This Post Helpful? 0
  • +
  • -

#6 neemamahmoodi  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 21
  • Joined: 30-November 10

Re: Connecting Two JFrames

Posted 29 December 2010 - 06:04 AM

View PostPaars, on 29 December 2010 - 05:01 AM, said:

You create the second JFrame after you click the login button.
Or you could change your original JFrame into what it has to be after you click in login.

All is done in your MouseListener functions.


I am a noob how do i do that? I have this:

 private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {
        // TODO add your handling code here:
    }


What do i put in the handling code area
Was This Post Helpful? 0
  • +
  • -

#7 Paars  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 39
  • Joined: 11-October 10

Re: Connecting Two JFrames

Posted 29 December 2010 - 06:10 AM

JFrame jFrame1,jFrame2; // somewhere at start

private void jButton1MouseClicked(java.awt.event.MouseEvent evt) 
{  
    
  jFrame2 = new JFrame() // and add the rest of the stuff here to jFrame2
  // or, change all buttons used in jFrame1 and don't use a second jFrame at all
} 





This post has been edited by Paars: 29 December 2010 - 06:11 AM

Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8334
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Connecting Two JFrames

Posted 29 December 2010 - 10:53 AM

Asked so many times... I wrote a Snippet about it

http://www.dreaminco...snippet4460.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1