14.59 设置表格焦点 JTable.setFocusable

来源:互联网 发布:三星网络电视60寸价格 编辑:程序博客网 时间:2024/05/29 07:26

 

 

import java.awt.FlowLayout;import javax.swing.JFrame;import javax.swing.JScrollPane;import javax.swing.JTable;import javax.swing.ListSelectionModel;public class ExtendSelection {  public static void main(String[] argv) throws Exception {    int rows = 10;    int cols = 5;    JTable table = new JTable(rows, cols);    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);    table.setColumnSelectionAllowed(true);    table.setRowSelectionAllowed(true);        //将此 Component 的焦点状态设置为指定值。    table.setFocusable(true);    table.setCellSelectionEnabled(false);    JFrame jfrm = new JFrame("JTable Demo");    jfrm.setLayout(new FlowLayout());    jfrm.setSize(460, 180);    jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);    JScrollPane jscrlp = new JScrollPane(table);    jfrm.add(jscrlp);    jfrm.setVisible(true);  }}


 

原创粉丝点击