@Override public JComponent createContentPanel() { JPanel panel = new JPanel(new BorderLayout(10, 10)); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); JLabel label = new JLabel("Please select the column you want to shown."); label.setHorizontalAlignment(SwingConstants.LEFT); DefaultListModel listModel = new DefaultListModel(); ArrayList<String> selected = new ArrayList(); TableColumnModel tcm = this.tablePanel.getColumnModel(); for (int i = 0; i < tcm.getColumnCount(); i++) { TableColumn tc = tcm.getColumn(i); listModel.addElement(tc.getHeaderValue()); if (tc.getWidth() > 0) { selected.add(tc.getHeaderValue().toString()); } } this.cbList = new CheckBoxList(listModel); this.cbList.setLayoutOrientation(JList.VERTICAL_WRAP); this.cbList.setSelectedObjects(selected.toArray()); this.cbList.setClickInCheckBoxOnly(false); this.cbList.getCheckBoxListSelectionModel().setSelectionMode(2); JPanel topPanel = new JPanel(new BorderLayout(6, 6)); topPanel.add(label, "North"); topPanel.add(this.cbList, "Center"); panel.add(topPanel, "First"); this.labDesc = new JideLabel(""); this.labDesc.setIcon(IconFactory.getImageIcon("exclamation.png")); this.labDesc.setVisible(false); panel.add(this.labDesc, "South"); return panel; }
public ColumnOptionDialog(TableEnqPanel tablePanel) { this.setIconImage(IconFactory.getImage("app.png")); this.setTitle("Column Option Dialog"); this.tablePanel = tablePanel; this.model = tablePanel.getTableModel(); }