Connecting JFrames in Netbeans

  • Follow


Hi Everyone,
                     I am using NetBeans to do a project and i was
wondering whether i could do the follows:

have 2 files :
one.java ----------> has JFrame1 -----------> has button1,textbox1
two.java ----------> has JFrame2

and when button1 in JFrame1 is clicked JFrame2 should appear and the
value entered in textbox1 is to be sent to two.java so JFrame2 can use
it. Is this possible if so plz help me ASAP thanks for your help in
advance. Any other suggestion arround this problem would be greatly
appreciated as well.

0
Reply mithil.mohan (25) 11/16/2006 6:58:47 PM

Mithil wrote:
> Hi Everyone,
>                      I am using NetBeans to do a project and i was
> wondering whether i could do the follows:
>
> have 2 files :
> one.java ----------> has JFrame1 -----------> has button1,textbox1
> two.java ----------> has JFrame2
>
> and when button1 in JFrame1 is clicked JFrame2 should appear and the
> value entered in textbox1 is to be sent to two.java so JFrame2 can use
> it. Is this possible if so plz help me ASAP thanks for your help in
> advance. Any other suggestion arround this problem would be greatly
> appreciated as well.

I suggest obtaining a beginning Java text and working through that.
This is pretty elementary. I started with a book called Head First Java
and it got me up and running in just a couple weeks.

In the routine that is called by the button click, you would have the
lines:
JFrame2.setVisible();
JFrame2.setYourValue(textbox1.getText());

and in JFrame2 you would have a routine:
public void setYourValue(String s) {
....do whatever you wanted with the string that was in the textbox...
}

1
Reply Jeff 11/16/2006 10:06:55 PM


Hi Jeff,
               Thanks for your reply but i still have one small problem
how would one.java file's class know about JFrame2 which is in two.java
?

1
Reply Mithil 11/17/2006 9:01:45 AM

Mithil wrote:
...
> how would one.java file's class know about JFrame2 which is in two.java
> ?

If it is in a package with appropriate access rights,
import it.
If not in a package, it could be loaded by reflection,
but don't - put it in a package.

(And if those terms are mysterious, search on them
or ask on c.l.j.hlp - but still search on them first..)

Andrew T.

1
Reply Andrew 11/17/2006 9:24:37 AM

Andrew Thompson wrote:
> Mithil wrote:
> ..
> > how would one.java file's class know about JFrame2 which is in two.java
> > ?
>
> If it is in a package with appropriate access rights,
> import it.
> If not in a package, it could be loaded by reflection,
> but don't - put it in a package.
>
> (And if those terms are mysterious, search on them
> or ask on c.l.j.hlp - but still search on them first..)
>
> Andrew T.

Or, even better, if they are in the same package they automatically
know about each other.

1
Reply Jeff 11/17/2006 12:22:11 PM

hey thanks everyone i actually didn't even need to create a package
since it is in the same folder thanks a lot Jeff and Andrew.

-1
Reply Mithil 11/19/2006 4:32:27 PM

5 Replies
2937 Views

(page loaded in 0.068 seconds)

Similiar Articles:





7/19/2012 7:07:41 PM


Reply: