• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jtable help

 
keiyia jackson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Need help getting a row in the table to open another window.
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in which way u want to be done, in selection of the row or through mouse right click popupmenu.
 
keiyia jackson
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far I have code that selects a row and code to right mouse click. I need both ways.
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delare these statement in init method of main frame
detailFrame = new JFrame();
detailPanel = new detailContentPanel();
detailFrame.add("Center",detailPanel);

declare the statement in ActionCommand of popmenu.
int selectedRow = tableView.getSelectedRow();
int colCount = getColumnCount();
Vector data = new Vector();
For(int count =0;count<colCount;count++)>
{
data.add(table.getValueAt(selectedRow,count));
}

detailPanel.initValues(data);
detailFrame.pack();
detailFrame.setVisible(true);
Declare a new panel class so that you can customize the values passed from the frame.
public class detailContentPanel extends Panel
{
detailContentPanel()
{


}

protected void initValues(Vector vec)
{


}
}
On selection of a row can also be done using the same as above. U have to add the same on mouse click to perform the same when the row is selected.


 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For(int count=0;count is less than colCount;count++)
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change the for statement in ealier code which is incomplete.
for(int count=0;count less than colCount;c++)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic