how can i fill the JTree form database? please help
Dear all
my database is MS Access
I have two tables
-Countries table contain country_id and country_desc
- cities table contain city_id,city_desc,country_id
i need to make a tree with countries and cities
my class as follow:
--
public class SystemFrame extends JFrame {
private JPanel panelCenter = new JPanel();
private JLabel statusBar = new JLabel();
private JTree systemTree = new JTree();
// constructor
public SystemFrame() {
try {
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout( layoutMain );
panelCenter.setLayout( null );
this.setSize( new Dimension(400, 300) );
this.setTitle( "Country Menu" );
statusBar.setText( "staus bar" );
systemTree.setAutoscrolls(true);
systemTree.setBorder(BorderFactory.createTitledBorder("CountryMenue"));
systemTree.setForeground(Color.red);
systemTree.setToolTipText("Select desired city");
this.getContentPane().add( statusBar, BorderLayout.SOUTH );
this.getContentPane().add( panelCenter, BorderLayout.NORTH);
this.getContentPane().add(systemTree, BorderLayout.CENTER);
this.setVisible(true);
}
public static void main(String args[]) {
SystemFrame frm = new SystemFrame();
}
}
i need to fill my JTree with data in tables. I do not know how
Please help

