It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

TextFields related question

TextFields related question

Postby newcomer on Mon May 14, 2007 7:56 am

Hello

I m new to java world. I have a problem with GUI.

I have two classes class Main and class winframe .WinFrame class extends JFRAME and there are two instance variable in winframe class with two textfields.
i instanciate the winframe class in Main class. and call show() method of winframe class.

Can anybody please explain how can i get the value of textfields of WINFRAME class in Main class.

Thank you
newcomer
 
Posts: 2
Joined: Mon May 14, 2007 4:53 am

Postby ggomez on Mon May 21, 2007 4:45 am

if you have the instance in Main class, you can put some usefull methods in the winframe class so you can use it in Main class.

something like setTextFielValue(Object o)
ggomez
 
Posts: 45
Joined: Tue Apr 17, 2007 3:30 am
Location: !!!!!MéXiCo¡¡¡¡¡¡

Postby newcomer on Mon May 21, 2007 8:56 am

I tried this but problem is where should i use that method. I tried this as below

// method in Main class to instanciate WinFrame class

public void showWin()
{
WinFrame wn = new WinFrame()
wn.setVisible(true) ;

wn.setTextFielValue( this )

println( first text ) ;
println( second text) ;

}
but the problem is program pointer immediately call setTextFieldValue after calling setVisible method. so the both the text variable remain null when i try to print them. It should wait untill i put some texts into both the textfield of WinFrame class and any OK button then Main should call the setText method so that it can return some value.

Can anybody please help me with this
newcomer
 
Posts: 2
Joined: Mon May 14, 2007 4:53 am


Who is online

Users browsing this forum: No registered users and 1 guest