• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting and setting values from JTable

padma patil
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);

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

//Add the tabbed pane to this panel.
setLayout(new BorderLayout());
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(),
frame.setSize(400, 125);

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.
[ May 14, 2002: Message edited by: padma patil ]
Mark Spritzler
Posts: 17278
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic