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
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