Hi

i've class project with textfilds id,name.no...

when i click ok here another window (another class) opens with same fields but not editable.
and when i submit here data goes to db.

then how to get values of textfields in project class into current class which i've to send to db..


plz reply..

Recommended Answers

All 8 Replies

I am sorry for not speaking Martian. That's why I don't understand what you are saying. Try to post again your question. With more details and better explanation

is that Martian? I was sure it was Gibberish.

Thks for reply
sending detail

I am using java swing to develop an application..

class1- which contain some TextFields, TextAreas and buttons. here is a ok button. when i click on the ok, another window opents which is another class-class2 developed using swing having all same fields in prev class1 but should not be editable. and here in class2 i m having submit button which submits data into db..

now what i want is--
want to access the fields in the class1 with their valus into next class2 so that i can send them to db.

so how should i do that..

reply..

Here some commands from the API

JTextField text=new JTextField ();
String s = text.getText();
text.setText("someString");

Try to 'get' the values from class1 and pass them as arguments when you call class2
Then 'set' those values to the fields of class2
Then when you want to save them in the DB 'get' them again
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/package-summary.html

i m writting in simple English

How should i pass them as arguments ..
can u give me example

Don't you know how to create constructors or methods with arguments.
Just create a method that takes its arguments and sets them as values in the text fields of your class2. Or when you call class2 give those values in the constructor of class2

Why on earth would you have two separate classes for that? Why does the first class not submit to the database?
Post the code that you have written also. You do have some, yes?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.