本文整理汇总了Java中javax.swing.JTable.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setOpaque方法的具体用法?Java JTable.setOpaque怎么用?Java JTable.setOpaque使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTable
的用法示例。
在下文中一共展示了JTable.setOpaque方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame("Library Book Loan System - Notifications");
frame.setResizable(false);
frame.setBounds(100, 100, 438, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.getContentPane().add(panel, BorderLayout.CENTER);
panel.setLayout(null);
JLabel lblNotifications = new JLabel("Notifications");
lblNotifications.setHorizontalAlignment(SwingConstants.CENTER);
lblNotifications.setFont(new Font("Segoe UI Light", Font.PLAIN, 14));
lblNotifications.setBounds(10, 40, 414, 22);
panel.add(lblNotifications);
JLabel label_1 = new JLabel("Library Book Loan System");
label_1.setHorizontalAlignment(SwingConstants.CENTER);
label_1.setFont(new Font("Segoe UI Light", Font.PLAIN, 18));
label_1.setBounds(10, 11, 414, 25);
panel.add(label_1);
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Available Books", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
panel_1.setBounds(10, 73, 414, 177);
panel.add(panel_1);
panel_1.setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 22, 394, 144);
panel_1.add(scrollPane);
Object columnNames[] = { "No", "Message" };
Object rowData[][] = getNotifications();
table = new JTable(rowData, columnNames)
{
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
table.setBackground(Color.white);
table.setOpaque(true);
table.getTableHeader().setReorderingAllowed(false);
TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(table.getModel());
table.setRowSorter(sorter);
List<RowSorter.SortKey> sortKeys = new ArrayList<>(25);
sortKeys.add(new RowSorter.SortKey(0, SortOrder.ASCENDING));
sorter.setSortKeys(sortKeys);
table.getColumnModel().getColumn(0).setMaxWidth(40);
scrollPane.setViewportView(table);
}