JTable - DefaultTableModel

P

pat270881

Hello,

I have a JTable with a DefaultTableModel. I have a search Methode which
searches in the database and displays the results in the JTable. Now I
want to extract the search from the class and put it in an extra class.
I have for both the JTable and the DefaultTableModel defined getters
and setters and now I want to write the following code in the
outsourced method:

Search.getTable().setVisible(true);
search.getModel().addRow(new Object[]{name,text});

Search is the class where the JTable and the DefaultTableModel is
defined. Both lines are in a loop of a Vector size and the data of the
vector are in the name and text parameters of the addRow Method. The
problem is that this does not work and the rows are not displayed when
I start my Java Application. When I put this code (without the Search
prefix and the get-Method) it works without problems.

Is it not possible to address the table and the model in that way from
another class?

lg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top