i have jtable filed with data. i want to create java code for Action of the Jbutton. My requirement is when i click the button, then copy all the content of jtable to clip board. how can i do that.
String[] columnNames={"DATE","Steet"};
String[][] cells=new String[ar.size()][2];
for(int i=0;i<ar.size();i++){
cells[i][0]=((PRIvariable)ar.get(i)).incDate;
cells[i][1]=((PRIvariable)ar.get(i)).selectedSteer;
}
table = new JTable(cells,columnNames);
table.setVisible(true);
table.setSize(400, 400);
js=new JScrollPane();
js.setViewportView(table);
js.setBounds(10, 230,500, 215);
js.setVisible(true);
add(js,java.awt.BorderLayout.CENTER);
- in this code ar is my arraylist.
- how can i write the code witch can copy the content of this Jtable.
When I needed to do this in the past I started with the code here:
http://www.javaworld.com/javatips/jw-javatip77.html
And modified to create an action for a button that would copy the data and the column headings from a table to the clipboard.