Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting and setting values from JTable  RSS feed

 
padma patil
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I hava JTable1 which is in first pane of JTabbedPane. In JTable1 user enters data and I wanted to pass and set this data into second Table which is in Pane2 of JTabbedPane.
I am new to JTables . Can anybody please put some lights on this ?
Code is somethig like this,
public class TabbedPaneDemo extends JPanel {

Object[][] data = new Object[10][24];
public TabbedPaneDemo() {
JTabbedPane tabbedPane = new JTabbedPane();

Component panel1 = makePanel1("Blah");
tabbedPane.addTab("Data", panel1);
tabbedPane.setSelectedIndex(0);

Component panel2 = makePanel2("Blah");
tabbedPane.addTab("Sample", panel2);
tabbedPane.setSelectedIndex(1);



//Add the tabbed pane to this panel.
setLayout(new BorderLayout());
add(tabbedPane,BorderLayout.CENTER);
}
protected Component makePanel1(String text) {

DataPanel1 dp = new DataPanel1();
JPanel panelA= dp.initComponents();
return panelA;
}
protected Component makePanel2(String text) {

SamplePanel sp = new SamplePanel();
JPanel panelB = sp.initComponents();
return panelB;

}

public static void main(String[] args) {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
frame.getContentPane().add(new TabbedPaneDemo(),
BorderLayout.CENTER);
frame.setSize(400, 125);
frame.setVisible(true);
}
}

SamplePanel and DataPanel are two different classes , which has tables.
DataPanel has JTable in which user enters data and this data has to be passed to JTable in SamplePanel class when Sample tabbedPane is clicked.
Thanks,
Padmashree
[ May 14, 2002: Message edited by: padma patil ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the following Sun tutorials on TbaleModels. This is the underlying data within a JTable. It is through this class that you will access and change the data.
Tutorial for TableModel
Table Model Listener Tutorial
Hope that helps point you in the right direction.
Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!