themanfalconar
Technical User
Hi there,
I've got a JTable from which I want to copy its entire contents to the clipboard.
When I use the mouse to select a range of cells and press CTRL+C, this works just fine.
However, I've created a button that automatically selects all cells (using the code below); when I press CTRL+C after pressing the button it does not copy to the clipboard.
Has anyone any idea how I can do this in this manner?
Cheers, Dan (code is below)
I've got a JTable from which I want to copy its entire contents to the clipboard.
When I use the mouse to select a range of cells and press CTRL+C, this works just fine.
However, I've created a button that automatically selects all cells (using the code below); when I press CTRL+C after pressing the button it does not copy to the clipboard.
Has anyone any idea how I can do this in this manner?
Cheers, Dan (code is below)
Code:
cornerButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
int row = 0;
int col = 0;
boolean toggle = false;
boolean extend = false;
resultsTable.changeSelection(row, col, toggle, extend);
row = rowNum; // rowNum is the number or rows
col = colNum; // colNum is the number of cols
toggle = false;
extend = true;
resultsTable.changeSelection(row, col, toggle, extend);
scroll.getViewport().setViewPosition(new Point(0,0)); // scroll is the JScrollPane that the table is in
}
}});