private void prepareComponent() { CloseEventHandler closeEventHandler = new CloseEventHandler(); addWindowListener(closeEventHandler); Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(); // JPanel contentPanel = new FormDebugPanel(); contentPane.add(contentPanel, BorderLayout.CENTER); CellConstraints cc = new CellConstraints(); FormLayout layout = new FormLayout( "4dlu, d:grow, 4dlu", // columns "4dlu, p, 2dlu, fill:100dlu:grow, 4dlu, " + // rows "p, 2dlu, p, 4dlu"); // btn rows PanelBuilder contentPB = new PanelBuilder(layout, contentPanel); int columnCount = layout.getColumnCount(); int rowCount = layout.getRowCount(); JLabel label = new JLabel(Localizer.getString("MediaTypeCondEditor_ConditionToAdd")); contentPB.add(label, cc.xywh(2, 2, 1, 1)); mediaTypeModel = new MediaTypeModel(); mediaTypeTable = new JTable(mediaTypeModel); JTableHeader tableHeader = mediaTypeTable.getTableHeader(); tableHeader.setResizingAllowed(false); tableHeader.setReorderingAllowed(false); // adjust column witdh of checkbox JCheckBox box = (JCheckBox) mediaTypeTable.getDefaultRenderer(Boolean.class); TableColumn column = mediaTypeTable.getColumnModel().getColumn(0); column.setMaxWidth(box.getPreferredSize().width + 2); column.setMinWidth(box.getPreferredSize().width + 2); mediaTypeTable.getColumnModel().getColumn(1).setCellRenderer(new MediaTypeCellRenderer()); // ToolTipManager.sharedInstance().registerComponent( mediaTypeTable ); contentPB.add(new JScrollPane(mediaTypeTable), cc.xywh(2, 4, 1, 1)); // button bar contentPB.add(new JSeparator(), cc.xywh(1, rowCount - 3, columnCount, 1)); JButton okBtn = new JButton(Localizer.getString("OK")); okBtn.addActionListener(new OkBtnListener()); okBtn.setDefaultCapable(true); okBtn.setRequestFocusEnabled(true); JButton cancelBtn = new JButton(Localizer.getString("Cancel")); cancelBtn.addActionListener(closeEventHandler); JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn); contentPB.add(btnPanel, cc.xywh(2, rowCount - 1, columnCount - 2, 1)); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); getRootPane().setDefaultButton(okBtn); pack(); setLocationRelativeTo(getParent()); }
protected JTableHeader createDefaultTableHeader() { if (dataTableHeader == null) { dataTableHeader = new JTableHeader(getDataColumnModel()); dataTableHeader.setResizingAllowed(true); dataTableHeader.setTable(dataTable); } return (dataTableHeader); }