Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
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();

}
}

 
Enthuware Software Support
Posts: 4450
41
  • 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.


 
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic