PDA

View Full Version : accessing a jtable from another class


vorl
03-06-2006, 03:49 AM
Hi
Could someone please help me. basically ive got a app which is like a address book. i have one class which is the main window with a jtable. i then have another class which is a window with fields. when i click the add button on the main window the other window appears. i then am able to add data to the fields of which when I press the update button it should add a row to the main windows jtable.
the only problem im having is to access the jtable in the main window (1st class) from the 2nd window (2nd class); could someone tell me how to do this?

Tell me if im not clear enough!!:)

Thanks
vorl

Melon00
03-07-2006, 06:07 AM
You should have a member variable that you use to call the 2nd dialog. Then all you have to to is create member variables for the edit boxes, then call a function that gets the string out of that edit box.

For instance in C++, you could have something like this

// in dialog pop up class
DDX_TEXT(pDX, ID_FOR_EDIT_BOX, m_EditBox1);

// in main window class
CDialogClass m_DialogPopUp;
m_DialogPopUp.DoModal();// opens window
CString PassVariable;

// further down in the code

PassVariable = m_DialogPopUp.m_EditBox1.GetBuffer(0); // gets line out of pop up box

I am not sure about any other language except C# so let me know if you need more help