本文整理匯總了Java中javax.swing.JTable.setFocusable方法的典型用法代碼示例。如果您正苦於以下問題:Java JTable.setFocusable方法的具體用法?Java JTable.setFocusable怎麽用?Java JTable.setFocusable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setFocusable方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: initComponents
import javax.swing.JTable; //導入方法依賴的package包/類
private void initComponents() {
JTable impl = new JTable(new DefaultTableModel(new Object[] { "" }, 0)); // NOI18N
TableColumnModel colMod = impl.getColumnModel();
final TableColumn col = colMod.getColumn(0);
impl.setFocusable(false);
header = new Header(colMod);
impl.setTableHeader(header);
header.setResizingAllowed(false);
header.setReorderingAllowed(false);
final TableCellRenderer renderer = header.getDefaultRenderer();
header.setDefaultRenderer(new TableCellRenderer() {
public Component getTableCellRendererComponent(
JTable table, Object value, boolean isSelected, boolean hasFocus,
int row, int column) {
Component component = renderer.getTableCellRendererComponent(
table, getRendererValue(), isSelected(),
isSelected(), row, processMouseEvents() ? 0 : 1);
setupRenderer(component);
col.setWidth(header.getWidth());
return component;
}
});
JScrollPane scroll = new JScrollPane(impl, JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
public Dimension getPreferredSize() { return header.getPreferredSize(); }
public void reshape(int x, int y, int width, int height) {
header.setPreferredSize(new Dimension(width, height));
super.reshape(x, y, width, height);
}
};
scroll.setBorder(BorderFactory.createEmptyBorder());
scroll.setViewportBorder(BorderFactory.createEmptyBorder());
setLayout(new OverlayLayout(this));
add(scroll);
}