?? e930. copying cell values to the clipboard from a jtable component.txt
字號(hào):
Given the cell values in the example code below, typing control-c in a table component while all cells have been selected causes the following text to be copied to the clipboard. In particular, the cell values are formatted as an HTML table.
Note: Control-c only works if the selected cells do not contain a null value.
<html>
<table>
<tr>
<th id=0>A
<th id=1>B
<th id=2>C
<tr id=0>
<td>A1
<td>B1
<td>C1
<tr id=1>
<td>A2
<td>B2
<td>C2
<tr id=2>
<td>A3
<td>B3
<td>C3
</table>
</html>
Here is the example code with initial cell values.
JTable table = new JTable();
// Add data
DefaultTableModel model = (DefaultTableModel)table.getModel();
model.addColumn("A");
model.addColumn("B");
model.addColumn("C");
model.addRow(new Object[]{"A1", "B1", "C1"});
model.addRow(new Object[]{"A2", "B2", "C2"});
model.addRow(new Object[]{"A3", "B3", "C3"});
Related Examples
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -