• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can not refresh the content of the JTable /MVC / Adapters

 
Max Chernikov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm implementig MVC with adapters... everething works fine (events),
but I can not refresh (change) the content of the JTable.
Please see my JTableView class...
Do i need to
getConent().delete(jTable);
getConent().add(jTable);
or call refresh?
I have about 10 Java book but have not find the answer yet.
Thank you in advance,
Max

JButton button
ButtonToTableAdapter implements ActionListener
public ButtonToTableAdaptor(JButton c, TableModel m)
public void actionPerformed(ActionEvent e)
model.setOrigin (n);

TableModel
public void setOrigin (String o)
public void setDestination (String d)
public MyTableModel find(String f)

TableToViewAdapter
public TableToViewAdaptor(TableModel m, JTableView v)
view.changed(model.find(String f)

class JTableView extends JPanel
{
MyTableModel atm = null;
static JTable t;
public JTableView()
{
super();
setLayout(new FlowLayout ());
t = new JTable (atm);
add(t);
}

public JTbView(MyTableModel at)
{
super();
atm=at;
setLayout(new FlowLayout ());
t = new JTable (atm);
add(t);
}

public void changed (MyTableModel a)
{
System.err.println("Changing the JTable");
t = new JTable (a);
c.updateUI();

}
}

 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3817
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are going in a wrong direction. Just look at the Sun's Java Tutorial trail for using JTable. Read it carefully and write a small program to see how it works. You'll know what's wrong here.
-Paul.

------------------
SCJP2 Resources, Free Question A Day, Mock Exam Results and More!
www.jdiscuss.com
Get Certified, Guaranteed!
www.enthuware.com/jqplus

Your guide to SCJD exam!
www.enthuware.com/jdevplus
 
Max Chernikov
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul, thank you. It helped me a lot. Max
Originally posted by Paul Anil:
You are going in a wrong direction. Just look at the Sun's Java Tutorial trail for using JTable. Read it carefully and write a small program to see how it works. You'll know what's wrong here.
-Paul.


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic