List of usage examples for javax.swing.table TableColumnModel getColumn
public TableColumn getColumn(int columnIndex);
TableColumn
object for the column at columnIndex
. From source file:app.RunApp.java
/** * Generates TableModel for imbalanced data * /*from w w w .j a v a 2 s . c o m*/ * @param jtable Table * @param dataset Multi-label dataset * @return Generated TableModel */ private TableModel imbalancedTableModel(JTable jtable, MultiLabelInstances dataset) { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; tableModel.addColumn("Label"); tableModel.addColumn("IR intra class"); tableModel.addColumn("IR inter class"); tableModel.addColumn("STDEV intra class"); imbalancedLabels = MetricUtils.sortImbalancedDataByIRIntraClass(imbalancedLabels); Object[] row = new Object[4]; double std; String truncate; ImbalancedFeature current; for (int i = 0; i < dataset.getNumLabels(); i++) { current = imbalancedLabels[i]; row[0] = current.getName(); truncate = Double.toString(current.getIRIntraClass()); row[1] = MetricUtils.truncateValue(truncate, 5); truncate = Double.toString(current.getIRInterClass()); row[2] = MetricUtils.truncateValue(truncate, 5); std = Math.sqrt(current.getVariance()); row[3] = MetricUtils.truncateValue(std, 4); tableModel.addRow(row); } jtable.setModel(tableModel); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(100); tcm.getColumn(1).setPreferredWidth(20); tcm.getColumn(2).setPreferredWidth(80); tcm.getColumn(3).setPreferredWidth(40); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Set frequency of labelsets//from ww w. j a va 2s. co m * * @param jtable Table * @param dataset Dataset * @param stat Statistics * @param cp Plot * @return Generated TableModel * @throws Exception */ private TableModel labelsetsFrequencyTableModel(JTable jtable, MultiLabelInstances dataset, Statistics stat, CategoryPlot cp) throws Exception { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; DefaultCategoryDataset myData = new DefaultCategoryDataset(); tableModel.addColumn("Labelset Id"); tableModel.addColumn("# Examples"); tableModel.addColumn("Frequency"); double freq; //Labelsets frequency HashMap<LabelSet, Integer> result = stat.labelCombCount(); labelsetStringsByFreq = new ArrayList<>(result.size()); double sum = 0.0; Set<LabelSet> keysets = result.keySet(); Object[] row = new Object[3]; int count = 1; ArrayList<ImbalancedFeature> listImbalanced = new ArrayList(); ImbalancedFeature temp; int value; for (LabelSet current : keysets) { value = result.get(current); temp = new ImbalancedFeature(current.toString(), value); listImbalanced.add(temp); } labelsetsSorted = new ImbalancedFeature[listImbalanced.size()]; labelsetsFrequency = new double[listImbalanced.size()]; while (!listImbalanced.isEmpty()) { temp = Utils.getMax(listImbalanced); labelsetsSorted[count - 1] = temp; value = temp.getAppearances(); labelsetsFrequency[count - 1] = value; row[0] = count; freq = value * 1.0 / dataset.getNumInstances(); sum += freq; String valueFreq = Double.toString(freq); row[1] = value; row[2] = MetricUtils.getValueFormatted(valueFreq, 4); tableModel.addRow(row); String id = "ID: " + Integer.toString(count); myData.setValue(freq, id, ""); labelsetStringsByFreq.add(temp.getName()); count++; listImbalanced.remove(temp); } jtable.setModel(tableModel); jtable.setBounds(jtable.getBounds()); TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(50); tcm.getColumn(1).setPreferredWidth(50); tcm.getColumn(2).setPreferredWidth(60); //graph cp.setDataset(myData); sum = sum / keysets.size(); Marker start = new ValueMarker(sum); start.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); start.setLabel(" Mean: " + MetricUtils.truncateValue(sum, 4)); start.setPaint(Color.red); cp.addRangeMarker(start); return jtable.getModel(); }
From source file:app.RunApp.java
/** * Set label IR//from www . j a va2 s . c o m * * @param jtable Table * @param stat Statistics * @param cp CategoryPlot * @return Generated TableModel * @throws Exception */ private TableModel irLabelsetsTableModel(JTable jtable, Statistics stat, CategoryPlot cp) throws Exception { DefaultTableModel tableModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { //This causes all cells to be not editable return false; } }; DefaultCategoryDataset myData = new DefaultCategoryDataset(); tableModel.addColumn("Labelset id"); tableModel.addColumn("IR values"); //Labelsets frequency HashMap<LabelSet, Integer> labelsetsFrequency = stat.labelCombCount(); labelsetStringByIR = new ArrayList<>(labelsetsFrequency.size()); Set<LabelSet> keysets = labelsetsFrequency.keySet(); Object[] row = new Object[2]; int count = 1; double IR_labelset; int max = getMax(keysets, labelsetsFrequency); ArrayList<ImbalancedFeature> listImbalanced = new ArrayList(); ImbalancedFeature temp; int value; for (LabelSet current : keysets) { value = labelsetsFrequency.get(current); IR_labelset = max / (value * 1.0); String temp1 = MetricUtils.truncateValue(IR_labelset, 4); IR_labelset = Double.parseDouble(temp1); temp = new ImbalancedFeature(current.toString(), value, IR_labelset); listImbalanced.add(temp); } labelsetsIRSorted = new ImbalancedFeature[listImbalanced.size()]; labelsetsByIR = new double[listImbalanced.size()]; //stores IR per labelset String truncate; while (!listImbalanced.isEmpty()) { temp = Utils.getMin(listImbalanced); labelsetsIRSorted[count - 1] = temp; labelsetsByIR[count - 1] = temp.getIRIntraClass(); row[0] = count; truncate = Double.toString(temp.getIRIntraClass()); row[1] = MetricUtils.getValueFormatted(truncate, 3); tableModel.addRow(row); myData.setValue(temp.getIRIntraClass(), Integer.toString(count), ""); labelsetStringByIR.add(temp.getName()); count++; listImbalanced.remove(temp); } jtable.setModel(tableModel); jtable.setBounds(jtable.getBounds()); //Resize columns TableColumnModel tcm = jtable.getColumnModel(); tcm.getColumn(0).setPreferredWidth(50); tcm.getColumn(1).setPreferredWidth(50); //graph cp.setDataset(myData); //get mean double sum = 0; for (int i = 0; i < labelsetsIRSorted.length; i++) { sum += labelsetsIRSorted[i].getIRIntraClass(); } sum = sum / labelsetsIRSorted.length; Marker start = new ValueMarker(sum); start.setPaint(Color.blue); start.setLabelFont(new Font("SansSerif", Font.BOLD, 12)); start.setLabel(" Mean: " + MetricUtils.truncateValue(sum, 4)); cp.addRangeMarker(start); return jtable.getModel(); }
From source file:net.sourceforge.pmd.cpd.GUI.java
private void setListDataFrom(List<Match> matches) { resultsTable.setModel(tableModelFrom(matches)); TableColumnModel colModel = resultsTable.getColumnModel(); TableColumn column;//from www.j av a 2s . co m int width; for (int i = 0; i < matchColumns.length; i++) { if (matchColumns[i].width() > 0) { column = colModel.getColumn(i); width = matchColumns[i].width(); column.setPreferredWidth(width); column.setMinWidth(width); column.setMaxWidth(width); } } }
From source file:ome.formats.importer.gui.ErrorTable.java
/** * Constructor for class/*w ww. j a v a 2 s . c o m*/ */ public ErrorTable() { // set to layout that will maximize on resizing setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.setOpaque(false); // Main Panel containing all elements // Set up the main panel layout double mainTable[][] = { { 5, 200, 140, TableLayout.FILL, 140, 5 }, // columns { 5, TableLayout.PREFERRED, TableLayout.FILL, 5, 29, 5 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug); String message = "All errors accumulated during your import are displayed here, " + "and will be uploaded to us if check-marked. You can send us feedback on " + "these problems by clicking the 'Send Feedback' button."; JTextPane instructions = GuiCommonElements.addTextPane(mainPanel, message, "1,1,4,0", debug); instructions.setMargin(new Insets(10, 10, 10, 10)); TableColumnModel cModel = eTable.getColumnModel(); // *** remove last 3 rows from display *** TableColumn hiddenColumn = cModel.getColumn(6); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(5); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(4); cModel.removeColumn(hiddenColumn); MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer(); //LeftTableHeaderRenderer leftHeader = new LeftTableHeaderRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(myHeader); cModel.getColumn(1).setHeaderRenderer(myHeader); cModel.getColumn(2).setHeaderRenderer(myHeader); cModel.getColumn(3).setHeaderRenderer(myHeader); cbe = new CheckboxCellEditor(new JCheckBox()); cbe.checkbox.addMouseListener(this); cbr = new CheckboxRenderer(); cModel.getColumn(0).setCellEditor(cbe); cModel.getColumn(0).setCellRenderer(cbr); cModel.getColumn(1).setCellRenderer(new LeftDotRenderer()); cModel.getColumn(2).setCellRenderer(new TextLeftRenderer()); cModel.getColumn(3).setCellRenderer(new StatusRenderer()); // Set the width of the status column TableColumn statusColumn = eTable.getColumnModel().getColumn(3); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); // Set the width of the error column TableColumn dateColumn = eTable.getColumnModel().getColumn(2); dateColumn.setPreferredWidth(errorWidth); dateColumn.setMaxWidth(errorWidth); dateColumn.setMinWidth(errorWidth); // Set the width of the upload column TableColumn uploadColumn = eTable.getColumnModel().getColumn(0); uploadColumn.setPreferredWidth(uploadWidth); uploadColumn.setMaxWidth(uploadWidth); uploadColumn.setMinWidth(uploadWidth); eTable.setRowSelectionAllowed(false); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(eTable); mainPanel.add(scrollPane, "1,2,4,1"); double progressTable[][] = { { 200 }, // columns { 12, 5, 12 } }; // rows progressPanel = GuiCommonElements.addPlanePanel(mainPanel, progressTable, debug); runThread = new Thread() { public void run() { try { bytesProgressBar = new JProgressBar(); progressPanel.add(bytesProgressBar, "0,0"); filesProgressBar = new JProgressBar(0, 20); progressPanel.add(filesProgressBar, "0,2"); } catch (Throwable error) { } } }; runThread.start(); mainPanel.add(progressPanel, "1,4"); progressPanel.setVisible(false); cancelBtn = GuiCommonElements.addButton(mainPanel, "Cancel", 'c', "Cancel sending", "2,4,L,C", debug); cancelBtn.addActionListener(this); cancelBtn.setVisible(false); clearDoneBtn = GuiCommonElements.addButton(mainPanel, "Clear Done", 'd', "Clear done", "3,4,R,C", debug); clearDoneBtn.addActionListener(this); clearDoneBtn.setOpaque(false); clearDoneBtn.setEnabled(false); //clearDoneBtn.setVisible(false); // Disabled (See #5250) sendBtn = GuiCommonElements.addButton(mainPanel, "Send Feedback", 's', "Send your errors to the OMERO team", "4,4,R,C", debug); sendBtn.setOpaque(false); sendBtn.addActionListener(this); sendBtn.setEnabled(false); this.add(mainPanel); }
From source file:ome.formats.importer.gui.FileQueueTable.java
/** * Set up and display the file queue table *//* w ww .j av a2 s . c o m*/ FileQueueTable() { // ----- Variables ----- // Debug Borders Boolean debugBorders = false; // Size of the add/remove/refresh buttons (which are square). int buttonSize = 40; // Add graphic for the refresh button //String refreshIcon = "gfx/recycled.png"; // Add graphic for add button String addIcon = "gfx/add.png"; // Remove graphics for remove button String removeIcon = "gfx/remove.png"; // Width of the status columns int statusWidth = 100; // ----- GUI Layout Elements ----- // Start layout here setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); setBorder(BorderFactory.createEmptyBorder(6, 5, 9, 8)); JPanel buttonPanel = new JPanel(); if (debugBorders == true) buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS)); // refreshBtn = addButton("+", refreshIcon, null); // refreshBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setActionCommand(Actions.REFRESH); // refreshBtn.addActionListener(this); addBtn = GuiCommonElements.addBasicButton(null, addIcon, null); addBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); addBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); addBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); addBtn.setSize(new Dimension(buttonSize, buttonSize)); addBtn.setActionCommand(FileQueueHandler.ADD); addBtn.addActionListener(this); addBtn.setToolTipText("Add files to the import queue."); removeBtn = GuiCommonElements.addBasicButton(null, removeIcon, null); removeBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); removeBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setSize(new Dimension(buttonSize, buttonSize)); removeBtn.setActionCommand(FileQueueHandler.REMOVE); removeBtn.addActionListener(this); removeBtn.setToolTipText("Remove files from the import queue."); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); //buttonPanel.add(refreshBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(addBtn); buttonPanel.add(Box.createRigidArea(new Dimension(0, 5))); buttonPanel.add(removeBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); add(buttonPanel); add(Box.createRigidArea(new Dimension(5, 0))); JPanel queuePanel = new JPanel(); if (debugBorders == true) queuePanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); queuePanel.setLayout(new BoxLayout(queuePanel, BoxLayout.PAGE_AXIS)); //queuePanel.add(Box.createRigidArea(new Dimension(0,10))); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); JLabel label = new JLabel("Import Queue:"); labelPanel.add(label); labelPanel.add(Box.createHorizontalGlue()); groupBtn = GuiCommonElements.addBasicButton("Group: ", null, "Current Group"); groupBtn.setToolTipText("The user group you are logged into."); //groupBtn.setEnabled(false); labelPanel.add(groupBtn); queuePanel.add(labelPanel); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); TableColumnModel cModel = getQueue().getColumnModel(); headerCellRenderer = new MyTableHeaderRenderer(); fileCellRenderer = new LeftDotRenderer(); dpCellRenderer = new CenterTextRenderer(); statusCellRenderer = new CenterTextRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(headerCellRenderer); cModel.getColumn(1).setHeaderRenderer(headerCellRenderer); cModel.getColumn(2).setHeaderRenderer(headerCellRenderer); cModel.getColumn(0).setCellRenderer(fileCellRenderer); cModel.getColumn(1).setCellRenderer(dpCellRenderer); cModel.getColumn(2).setCellRenderer(statusCellRenderer); // Set the width of the status column TableColumn statusColumn = getQueue().getColumnModel().getColumn(2); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); SelectionListener listener = new SelectionListener(getQueue()); getQueue().getSelectionModel().addListSelectionListener(listener); //queue.getColumnModel().getSelectionModel() // .addListSelectionListener(listener); // Hide 3rd to 6th columns TableColumnModel tcm = getQueue().getColumnModel(); TableColumn projectColumn = tcm.getColumn(6); tcm.removeColumn(projectColumn); TableColumn userPixelColumn = tcm.getColumn(6); tcm.removeColumn(userPixelColumn); TableColumn userSpecifiedNameColumn = tcm.getColumn(6); tcm.removeColumn(userSpecifiedNameColumn); TableColumn datasetColumn = tcm.getColumn(3); tcm.removeColumn(datasetColumn); TableColumn pathColumn = tcm.getColumn(3); tcm.removeColumn(pathColumn); TableColumn archiveColumn = tcm.getColumn(3); tcm.removeColumn(archiveColumn); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(getQueue()); queuePanel.add(scrollPane); JPanel importPanel = new JPanel(); importPanel.setLayout(new BoxLayout(importPanel, BoxLayout.LINE_AXIS)); clearDoneBtn = GuiCommonElements.addBasicButton("Clear Done", null, null); clearFailedBtn = GuiCommonElements.addBasicButton("Clear Failed", null, null); importBtn = GuiCommonElements.addBasicButton("Import", null, null); importPanel.add(Box.createHorizontalGlue()); importPanel.add(clearDoneBtn); clearDoneBtn.setEnabled(false); clearDoneBtn.setActionCommand(FileQueueHandler.CLEARDONE); clearDoneBtn.addActionListener(this); clearDoneBtn.setToolTipText("Clear all 'done' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 5))); importPanel.add(clearFailedBtn); clearFailedBtn.setEnabled(false); clearFailedBtn.setActionCommand(FileQueueHandler.CLEARFAILED); clearFailedBtn.addActionListener(this); clearFailedBtn.setToolTipText("Clear all 'failed' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 10))); importPanel.add(importBtn); importBtn.setEnabled(false); importBtn.setActionCommand(FileQueueHandler.IMPORT); importBtn.addActionListener(this); importBtn.setToolTipText("Begin importing files."); GuiCommonElements.enterPressesWhenFocused(importBtn); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); queuePanel.add(importPanel); add(queuePanel); }
From source file:ome.formats.importer.gui.HistoryTable.java
/** * Create history table//w w w . j a va 2 s.c o m * * @param viewer- GuiImporter parent */ HistoryTable(GuiImporter viewer) { this.viewer = viewer; try { historyTaskBar.addPropertyChangeListener(this); } catch (Exception ex) { log.error("Exception adding property change listener.", ex); } HistoryTableStore db = null; //HistoryDB db = null; try { db = new HistoryTableStore(); db.addObserver(this); } catch (Exception e) { db = null; log.error("Could not start history DB.", e); if (HistoryDB.alertOnce == false) { JOptionPane.showMessageDialog(null, "We were not able to connect to the history DB.\n" + "In the meantime, you will still be able to use \n" + "the importer, but the history feature will be disable.", "Warning", JOptionPane.ERROR_MESSAGE); HistoryDB.alertOnce = true; } } this.db = db; // set to layout that will maximize on resizing setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.setOpaque(false); // Main Panel containing all elements // Set up the main panel layout /* Disabled till #2308 fixed double mainTable[][] = {{170, 10, TableLayout.FILL, 80}, // columns { 5, 30, 35, 40, TableLayout.FILL, 35, 5}}; // rows */ double mainTable[][] = { { 170, 10, TableLayout.FILL, 90 }, // columns { 5, 30, 35, 70, TableLayout.FILL, 35, 5 } }; // rows mainPanel = GuiCommonElements.addMainPanel(this, mainTable, 0, 0, 0, 0, debug); // *****Side Panel**** double topSideTable[][] = { { TableLayout.FILL }, // columns { 20, 20, 20, 20, 35 } }; // rows topSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, topSideTable, " Date Filter ", debug); String[] dateFormats = new String[1]; dateFormats[0] = DATE_FORMAT; fromDate = new JXDatePicker(); fromDate.setToolTipText("Pick a from date."); //fromDate.getEditor().setEditable(false); //fromDate.setEditable(false); fromDate.setFormats(dateFormats); toDate = new JXDatePicker(); toDate.setToolTipText("Pick a to date."); //toDate.getEditor().setEditable(false); //toDate.setEditable(false); toDate.setFormats(dateFormats); fromLabel = new JLabel("From (yy/mm/dd):"); topSidePanel.add(fromLabel, "0,0"); topSidePanel.add(fromDate, "0,1"); toLabel = new JLabel("To (yy/mm/dd):"); topSidePanel.add(toLabel, "0,2"); topSidePanel.add(toDate, "0,3"); double bottomSideTable[][] = { { TableLayout.FILL }, // columns { TableLayout.FILL } }; // rows historyTaskBar.addTaskPane("Today", historyTaskBar.getList(todayList)); historyTaskBar.addTaskPane("Yesterday", historyTaskBar.getList(yesterdayList)); historyTaskBar.addTaskPane("This Week", historyTaskBar.getList(thisWeekList)); historyTaskBar.addTaskPane("Last Week", historyTaskBar.getList(lastWeekList)); historyTaskBar.addTaskPane("This Month", historyTaskBar.getList(thisMonthList)); bottomSidePanel = GuiCommonElements.addBorderedPanel(mainPanel, bottomSideTable, " Quick Date ", debug); /* JPanel taskPanel = new JPanel( new BorderLayout() ); JScrollPane taskScrollPane = new JScrollPane(); taskScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); taskScrollPane.getViewport().add(historyTaskBar); taskPanel.add(taskScrollPane); bottomSidePanel.add(taskPanel, "f,f"); taskPanel.validate(); */ bottomSidePanel.add(historyTaskBar, "0,0"); clearBtn = GuiCommonElements.addIconButton(mainPanel, "Wipe History", clearIcon, 130, 32, (int) 'S', "Click here to clear your history log.", "0,5,C,C", debug); clearBtn.setActionCommand(HistoryHandler.CLEARHISTORY); clearBtn.addActionListener(this); // *****Top right most row containing search field and buttons***** /*// Disabled till #2308 fixed searchField = GuiCommonElements.addTextField(mainPanel, "Name Filter: ", "*.*", 'N', "Type in a file name to search for here.", "", TableLayout.PREFERRED, "2,1, 0, 0", debug); */ searchField = new JTextField("*.*"); searchField.setVisible(false); searchBtn = GuiCommonElements.addButton(topSidePanel, "Search", 'S', "Click here to search", "0,4,C,C", debug); searchBtn.setActionCommand(HistoryHandler.HISTORYSEARCH); searchBtn.addActionListener(this); // *****Middle right row containing the filter options***** // Since this panel has a different layout, use a new panel for it /* Disabled till #2308 fixed // Set up the filterTable layout double filterTable[][] = {{100, 80, 80, 80, 90, TableLayout.FILL}, // columns { 30 }}; // rows filterPanel = GuiCommonElements.addPlanePanel(mainPanel, filterTable, debug); filterLabel = GuiCommonElements.addTextPane(filterPanel, "Status Filters: ", "0,0,r,c", debug); doneCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Done", "1,0,L,C", debug); failedCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Failed", "2,0,L,C", debug); invalidCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Invalid", "3,0,L,C", debug); pendingCheckBox = GuiCommonElements.addCheckBox(filterPanel, "Pending", "4,0,L,C", debug); // Default filters to 'on' doneCheckBox.setSelected(true); failedCheckBox.setSelected(true); invalidCheckBox.setSelected(true); pendingCheckBox.setSelected(true); doneCheckBox.addActionListener(this); failedCheckBox.addActionListener(this); invalidCheckBox.addActionListener(this); pendingCheckBox.addActionListener(this); filterPanel.setVisible(false); */ // *****Bottom right most row containing the history table***** TableColumnModel cModel = eTable.getColumnModel(); // *** remove last 4 rows from display *** TableColumn hiddenColumn = cModel.getColumn(6); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(5); cModel.removeColumn(hiddenColumn); hiddenColumn = cModel.getColumn(4); cModel.removeColumn(hiddenColumn); MyTableHeaderRenderer myHeader = new MyTableHeaderRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(myHeader); cModel.getColumn(1).setHeaderRenderer(myHeader); cModel.getColumn(2).setHeaderRenderer(myHeader); cModel.getColumn(3).setHeaderRenderer(myHeader); cModel.getColumn(0).setCellRenderer(new LeftDotRenderer()); cModel.getColumn(1).setCellRenderer(new TextCellCenter()); cModel.getColumn(2).setCellRenderer(new TextCellCenter()); cModel.getColumn(3).setCellRenderer(new TextCellCenter()); // Set the width of the status column TableColumn statusColumn = eTable.getColumnModel().getColumn(3); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); // Set the width of the status column TableColumn dateColumn = eTable.getColumnModel().getColumn(2); dateColumn.setPreferredWidth(dateWidth); dateColumn.setMaxWidth(dateWidth); dateColumn.setMinWidth(dateWidth); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(eTable); // disabled till #2308 fixed //reimportBtn = GuiCommonElements.addButton(filterPanel, "Reimport", 'R', "Click here to reimport selected images", "5,0,R,C", debug); reimportBtn = GuiCommonElements.addButton(mainPanel, "Reimport", 'R', "Click here to reimport selected images", "3,5,C,C", debug); reimportBtn.setEnabled(false); reimportBtn.setActionCommand(HistoryHandler.HISTORYREIMPORT); reimportBtn.addActionListener(this); // Handle the listener ListSelectionModel selectionModel = this.eTable.getSelectionModel(); selectionModel.addListSelectionListener(this); //mainPanel.add(scrollPane, "2,3,3,5"); Disabled till #2308 fixed mainPanel.add(scrollPane, "2,1,3,4"); mainPanel.add(bottomSidePanel, "0,4,0,0"); mainPanel.add(topSidePanel, "0,0,0,3"); //mainPanel.add(filterPanel, "2,2,3,1"); this.add(mainPanel); }
From source file:op.care.nursingprocess.DlgNursingProcess.java
private void jspPlanungComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_jspPlanungComponentResized JScrollPane jsp = (JScrollPane) evt.getComponent(); if (tblPlanung.getRowCount() <= 0) { return;/*from w ww. j a v a2 s . co m*/ } Dimension dim = jsp.getSize(); int textWidth = dim.width - 25; TableColumnModel tcm1 = tblPlanung.getColumnModel(); tcm1.getColumn(0).setPreferredWidth(textWidth); tcm1.getColumn(0).setHeaderValue(SYSTools.xx("nursingrecords.nursingprocess.interventions")); }
From source file:org.apache.cayenne.swing.TableBinding.java
protected void resizeColumns(Object[] sampleLongValues) { TableCellRenderer headerRenderer = table.getTableHeader().getDefaultRenderer(); TableColumnModel columnModel = table.getColumnModel(); TableModel tableModel = table.getModel(); for (int i = 0; i < columnModel.getColumnCount(); i++) { TableColumn column = columnModel.getColumn(i); Component header = headerRenderer.getTableCellRendererComponent(null, column.getHeaderValue(), false, false, 0, 0);/*from www .j a v a 2s . com*/ int headerWidth = header.getPreferredSize().width; if (sampleLongValues[i] != null) { Component bigCell = table.getDefaultRenderer(tableModel.getColumnClass(i)) .getTableCellRendererComponent(table, sampleLongValues[i], false, false, 0, i); int cellWidth = bigCell.getPreferredSize().width; column.setPreferredWidth(Math.max(headerWidth, cellWidth)); } else { column.setPreferredWidth(headerWidth); } } }
From source file:org.datanucleus.ide.idea.ui.DNEConfigForm.java
public void setData(@NotNull final GuiState data) { this.guiStateBeforeChanges = new GuiState(data); ///*from www . j av a 2s .c o m*/ // Basic panels this.indexNotReadyPanel.setVisible(!data.isIndexReady()); this.contentPanel.setVisible(data.isIndexReady()); // // Enable enhancer checkbox this.enableEnhancerCheckBox.setSelected(data.isEnhancerEnabled()); // // Persistence implementation selection final EnhancerSupportRegistry enhancerSupportRegistry = data.getEnhancerSupportRegistry(); final Set<EnhancerSupport> supportedEnhancers = enhancerSupportRegistry.getSupportedEnhancers(); this.persistenceImplComboBox.removeAllItems(); for (final EnhancerSupport support : supportedEnhancers) { this.persistenceImplComboBox.addItem(support.getName()); } final EnhancerSupport enhancerSupport = data.getEnhancerSupport(); this.persistenceImplComboBox.setSelectedItem(enhancerSupport.getName()); if (supportedEnhancers.size() <= 1) { this.persistenceImplComboBox.setVisible(false); } else { this.persistenceImplComboBox.setVisible(true); } // just to be sure -> validate persistence settings from config file PersistenceApi persistenceApi = data.getApi(); if (!enhancerSupport.isSupported(persistenceApi)) { persistenceApi = enhancerSupport.getDefaultPersistenceApi(); } this.jDORadioButton.setSelected(PersistenceApi.JDO == persistenceApi); this.jPARadioButton.setSelected(PersistenceApi.JPA == persistenceApi); this.jDORadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JDO)); this.jPARadioButton.setEnabled(enhancerSupport.isSupported(PersistenceApi.JPA)); // // Metadata file extensions text field this.metadataExtensionTextField.setText(data.getMetaDataExtensions().trim()); // // Compiler resource file extensions control final boolean metadataExtensionsEnabled = data.getMetaDataExtensions() != null && !data.getMetaDataExtensions().trim().isEmpty(); this.addToCompilerResourceCheckBox.setSelected(data.isAddToCompilerResourcePatterns()); this.addToCompilerResourceCheckBox.setEnabled(metadataExtensionsEnabled); // // Test classes inclusion this.includeTestClassesCheckBox.setSelected(data.isIncludeTestClasses()); // // Panel displaying an info message if enhancer is not initialized this.infoPanel.setVisible(!data.isEnhancerInitialized()); this.infoPanel.setEnabled(!data.isEnhancerInitialized()); // // Table displaying affected modules if enhancer is initialized final TableModel affectedModulesRowModel = new AffectedModulesRowModel(data.getAffectedModules()); // modules affected by class enhancement this.affectedModulesTable.setModel(affectedModulesRowModel); // set column appearance final TableColumnModel columnModel = this.affectedModulesTable.getColumnModel(); final TableColumn firstColumn = columnModel.getColumn(0); firstColumn.setMinWidth(50); firstColumn.setMaxWidth(50); firstColumn.setPreferredWidth(50); this.affectedModulesTable.setDefaultEditor(Boolean.class, new BooleanTableCellEditor(false)); setPreferredTableHeight(this.affectedModulesTable, this.affectedModulesTable.getRowCount()); // // Table displaying affected files/classes/.. if enhancer is initialized final TableModel metadataOrClassFilesRowModel = new MetadataOrClassFilesRowModel(data.getMetadataFiles(), data.getAnnotatedClassFiles()); // files affected by class enhancement this.metadataAndClassesTable.setModel(metadataOrClassFilesRowModel); // set column appearance this.metadataAndClassesTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); // adjust column sizes (after being rendered the first time - necessary for ColumnAdjuster to work) final ColumnAdjuster columnAdjuster = new ColumnAdjuster(this.metadataAndClassesTable); //columnAdjuster.setOnlyAdjustLarger(false); columnAdjuster.setDynamicAdjustment(true); columnAdjuster.adjustColumns(); setPreferredTableHeight(this.metadataAndClassesTable, this.metadataAndClassesTable.getRowCount()); this.metadataAndClassesTable.setVisible(data.isEnhancerInitialized()); // only display detected classes if initialized this.metaDataAndClassesScrollPane.setVisible(data.isEnhancerInitialized()); if (enhancerSupport.getVersion() == EnhancerSupportVersion.V1_1_X) { this.depProjectModuleRadioButton.setSelected(!data.isDependenciesManual()); this.depManualRadioButton.setSelected(data.isDependenciesManual()); this.depManualRadioButton.setEnabled(true); this.depManualUnsupportedLabel.setVisible(false); } else { this.depProjectModuleRadioButton.setSelected(true); this.depManualRadioButton.setSelected(false); this.depManualRadioButton.setEnabled(false); this.depManualUnsupportedLabel.setVisible(true); } this.dependenciesAddDeletePanel.resetDependencyList(enhancerSupport.getId(), persistenceApi, data.getDependencies()); }