13 Replies - 1063 Views - Last Post: 19 June 2020 - 08:12 PM Rate Topic: -----

#1 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Pass value to another JFrame

Posted 02 June 2020 - 01:06 PM

Well what i'm trying to do is when i double click on a row from my JTable it opens a new JFrame in the new opened frame i have a centered Jlable that i want to take the value that is in the the first column of the selected row .
Any help would be appreciated , it thought of using observable and observers but failed bcs my class is already extending JFrame and i can't extend observable
Is This A Good Question/Topic? 0
  • +

Replies To: Pass value to another JFrame

#2 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: Pass value to another JFrame

Posted 02 June 2020 - 01:47 PM

Why does your code extend JFrame? It is usually better to have JFrame be as a member of a class.
Was This Post Helpful? 0
  • +
  • -

#3 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Re: Pass value to another JFrame

Posted 02 June 2020 - 01:50 PM

Itís autogenerated using netbeans i use the drag and drop to make my gui
Was This Post Helpful? 0
  • +
  • -

#4 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: Pass value to another JFrame

Posted 02 June 2020 - 01:52 PM

Tell Netbeans to not do it that way.
Was This Post Helpful? 0
  • +
  • -

#5 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Re: Pass value to another JFrame

Posted 02 June 2020 - 01:54 PM

Have no idea if thatís even possible you sure it could be done ?
Was This Post Helpful? 0
  • +
  • -

#6 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: Pass value to another JFrame

Posted 02 June 2020 - 01:57 PM

Quote

sure it could be done

Yes. Instead of using this to refer to the JFrame, you would use the JFrame's reference variable name.
Was This Post Helpful? 0
  • +
  • -

#7 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: Pass value to another JFrame

Posted 02 June 2020 - 04:45 PM

Only use one JFrame per app. Make the detail window a JDialog. You could also use JOptionPane

This post has been edited by g00se: 02 June 2020 - 04:46 PM
Reason for edit:: typo

Was This Post Helpful? 0
  • +
  • -

#8 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Re: Pass value to another JFrame

Posted 06 June 2020 - 09:57 AM

View PostNormR, on 02 June 2020 - 01:52 PM, said:

Tell Netbeans to not do it that way.



Is this possible ? if yes any idea on how it's done ?

View Postg00se, on 02 June 2020 - 04:45 PM, said:

Only use one JFrame per app. Make the detail window a JDialog. You could also use JOptionPane


The windows that i want is kind of big and it might have a jtable in it
Was This Post Helpful? 0
  • +
  • -

#9 NormR   User is online

  • D.I.C Lover
  • member icon

Reputation: 832
  • View blog
  • Posts: 6,392
  • Joined: 25-December 13

Re: Pass value to another JFrame

Posted 06 June 2020 - 10:00 AM

Quote

how it's done

Call a method and pass the value as an argument in the method.
  refToClassExtendingJFrame.theMethod(theValue);  // pass value to class

This post has been edited by NormR: 06 June 2020 - 10:01 AM

Was This Post Helpful? 1
  • +
  • -

#10 g00se   User is offline

  • D.I.C Lover
  • member icon

Reputation: 3698
  • View blog
  • Posts: 16,952
  • Joined: 20-September 08

Re: Pass value to another JFrame

Posted 06 June 2020 - 11:24 AM

Quote

The windows that i want is kind of big and it might have a jtable in it

That's not relevant. JDialog can fill your entire monitor if you want it to
Was This Post Helpful? 1
  • +
  • -

#11 blackeagle123   User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 124
  • Joined: 28-November 13

Re: Pass value to another JFrame

Posted 06 June 2020 - 11:27 AM

View Postg00se, on 06 June 2020 - 11:24 AM, said:

Quote

The windows that i want is kind of big and it might have a jtable in it

That's not relevant. JDialog can fill your entire monitor if you want it to

I guess i should learn more on how to customise it till now i only used it to pass a message to the user for example if he entered a wrong password

This post has been edited by blackeagle123: 06 June 2020 - 11:28 AM

Was This Post Helpful? 0
  • +
  • -

#12 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: Pass value to another JFrame

Posted 07 June 2020 - 09:10 PM

Absolutely gross misuse of a jframe you can get everything you want and more by configuring a JOptionPane
Was This Post Helpful? 0
  • +
  • -

#13 nicephotog   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 34
  • Joined: 06-June 20

Re: Pass value to another JFrame

Posted 10 June 2020 - 12:05 AM

If it has a table in it then use a modal dialog.
Was This Post Helpful? 0
  • +
  • -

#14 idlewild   User is online

  • New D.I.C Head

Reputation: 3
  • Posts: 35
  • Joined: 19-June 20

Re: Pass value to another JFrame

Posted 19 June 2020 - 08:12 PM

add an instance variable to the class that extends the JFrame,
then pass it to JFrame extending class' constructor that you will create as such
class X extends JFrame{
int x;
public X(int x){
this.x=x;
}

}

with new X(3); the value of 3 is passed to the class X

then in any non-static member of X you may use 3
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1