List of usage examples for javax.swing JTable setRowHeight
@BeanProperty(description = "The height in pixels of the cells in <code>row</code>") public void setRowHeight(int row, int rowHeight)
row
to rowHeight
, revalidates, and repaints. From source file:org.tellervo.desktop.io.ImportDialog.java
@SuppressWarnings("unused") private static void updateRowHeights(JTable table) { try {//from ww w . j av a2 s .c o m for (int row = 0; row < table.getRowCount(); row++) { int rowHeight = table.getRowHeight(); for (int column = 0; column < table.getColumnCount(); column++) { Component comp = table.prepareRenderer(table.getCellRenderer(row, column), row, column); rowHeight = Math.max(rowHeight, comp.getPreferredSize().height); } table.setRowHeight(row, rowHeight); } } catch (ClassCastException e) { } }
From source file:pipeline.parameter_cell_views.Button.java
@Override protected Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { evenTableRow = (row % 2 == 0);/*from ww w. j a va 2s.c o m*/ setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else { this.setBackground(Utils.COLOR_FOR_ODD_ROWS); } currentParameter = (ActionParameter) value; silenceUpdate = true; theButton.setEnabled(currentParameter.editable()[0]); theButton.setText(currentParameter.getParamNameDescription()[0]); setToolTipText( Utils.encodeHTML(WordUtils.wrap(currentParameter.getParamNameDescription()[1], 50, null, true)) .replace("\n", "<br>\n")); int height_wanted = (int) getPreferredSize().getHeight(); if (height_wanted > table.getRowHeight(row)) table.setRowHeight(row, height_wanted); silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.CheckBox.java
@Override protected Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { evenTableRow = (row % 2 == 0);// w w w . ja v a 2 s . com setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else { this.setBackground(Utils.COLOR_FOR_ODD_ROWS); } currentParameter = (BooleanParameter) value; silenceUpdate = true; Object[] selection = (Object[]) (currentParameter.getValue()); boolean selected = ((Boolean) selection[0]); jCheckBox.setSelected(selected); jCheckBox.setText(currentParameter.getParamNameDescription()[0]); setToolTipText( Utils.encodeHTML(WordUtils.wrap(currentParameter.getParamNameDescription()[1], 50, null, true)) .replace("\n", "<br>\n")); int height_wanted = (int) getPreferredSize().getHeight(); if ((table != null) && (height_wanted > table.getRowHeight(row))) table.setRowHeight(row, height_wanted); silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.ComboBox.java
@Override protected Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { evenTableRow = (row % 2 == 0);//ww w.ja v a 2s .co m setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else { this.setBackground(Utils.COLOR_FOR_ODD_ROWS); } parameterName.setBackground(getBackground()); currentParameter = (ComboBoxParameter) value; silenceUpdate = true; model = (DefaultComboBoxModel<Object>) theBox.getModel(); model.removeAllElements(); for (int i = 0; i < currentParameter.getChoices().length; i++) { model.addElement(currentParameter.getChoices()[i]); } Object[] selection = (Object[]) (currentParameter.getValue()); int selInt = (Integer) selection[1]; theBox.setSelectedIndex(selInt); parameterName.setText(currentParameter.getParamNameDescription()[0]); parameterName.setVisible(!currentParameter.getParamNameDescription()[0].equals("")); setToolTipText( Utils.encodeHTML(WordUtils.wrap(currentParameter.getParamNameDescription()[1], 50, null, true)) .replace("\n", "<br>\n")); theBox.setEditable(currentParameter.editable()[0]); int heightWanted = (int) getPreferredSize().getHeight(); if (heightWanted > table.getRowHeight(row)) table.setRowHeight(row, heightWanted); silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.CurveEditor.java
@SuppressWarnings("unchecked") @Override/* w w w.j av a 2s .co m*/ protected Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { if (table != null) { Dimension d = getPreferredSize(); d.width = table.getColumnModel().getColumn(column).getWidth(); setSize(d); } if (currentParameter != null) { currentParameter.removeListener(this); } currentParameter = (SplineParameter) value; currentParameter.addGUIListener(this); splineEditor.setCurvePoints((ArrayList<Point2D>) ((Object[]) currentParameter.getValue())[0]); splineEditor.setControlPoints((ArrayList<Point2D>) ((Object[]) currentParameter.getValue())[1]); silenceUpdate = true; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else this.setBackground(Utils.COLOR_FOR_ODD_ROWS); updateDisplay(); if (table != null) { int height_wanted = (int) getPreferredSize().getHeight(); if (height_wanted > table.getRowHeight(row)) table.setRowHeight(row, height_wanted); } silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.FloatSlider.java
@SuppressWarnings("unused") @Override//from w w w .ja va 2 s . co m public Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { if (table != null) { Dimension d = getPreferredSize(); d.width = table.getColumnModel().getColumn(column).getWidth(); setSize(d); } if (currentParameter != null) { currentParameter.removeListener(this); } currentParameter = (FloatParameter) value; /*if (value == null) { slider.setEnabled(true); textMinimum.setEditable(true); textMaximum.setEditable(true); currentTextValue.setEditable(true); return this; }*/ currentParameter.addGUIListener(this); currentParameter.validateRange(); silenceUpdate = true; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); else this.setBackground(Utils.COLOR_FOR_ODD_ROWS); if (true) {// rendererCalled GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; // For some strange reason, the slider doesn't get updated properly upon resizes // (only in the renderer, not the editor) // workaround is to remove it and re-create it remove(slider); readInParameterValues(); slider = new JSlider((int) (minimum * 100f), (int) (maximum * 100f), (int) (currentValue * 100f)); c.gridx = 0; c.gridy = 0; c.weighty = 1.0; c.weightx = 1.0; c.gridwidth = 3; add(slider, c); slider.addChangeListener(new sliderListener()); } else { if (table != null) slider.setBounds(table.getCellRect(row, column, false)); slider.updateUI(); } updateDisplay(); if (table != null) { int height_wanted = (int) getPreferredSize().getHeight(); if (height_wanted > table.getRowHeight(row)) table.setRowHeight(row, height_wanted); } silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.IntRangeSlider.java
@Override protected Component getRendererOrEditorComponent(JTable table0, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { if (currentParameter != null) { currentParameter.removeListener(this); }//from w w w . j ava 2s. co m currentParameter = (IntRangeParameter) value; currentParameter.addGUIListener(this); table = table0; tableRow = row; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) { this.setBackground(Utils.COLOR_FOR_EVEN_ROWS); } else this.setBackground(Utils.COLOR_FOR_ODD_ROWS); textValueFrame.setBackground(getBackground()); updateValues(); parameterName.setText(currentParameter.getParamNameDescription()[0]); parameterName.setVisible(!currentParameter.getParamNameDescription()[0].equals("")); textMinimum.setEditable(currentParameter.editable()[0]); textMaximum.setEditable(currentParameter.editable()[1]); this.setToolTipText(currentParameter.getParamNameDescription()[1]); int height_wanted = (int) getPreferredSize().getHeight(); if (height_wanted > table0.getRowHeight(row)) table0.setRowHeight(row, height_wanted); if (!rendererCalled) { slider.setBounds(table0.getCellRect(row, column, false)); slider.updateUI(); } silenceUpdate = false; return this; }
From source file:pipeline.parameter_cell_views.IntSlider.java
@Override public Component getRendererOrEditorComponent(JTable table, @NonNull Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { currentParameter = (IntParameter) value; evenTableRow = (row % 2 == 0);/*from www . j av a 2 s. c o m*/ setOpaque(true); if (evenTableRow) setBackground(Utils.COLOR_FOR_EVEN_ROWS); else setBackground(Utils.COLOR_FOR_ODD_ROWS); silenceUpdate = true; int[] intValues = (int[]) (currentParameter.getValue()); currentValue = intValues[0]; updateTextValue(currentTextValue, intValues[0]); updateTextValue(textMinimum, intValues[1]); updateTextValue(textMaximum, intValues[2]); minimum = intValues[1]; maximum = intValues[2]; if (true) {// rendererCalled GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; // For some strange reason, the slider doesn't get updated properly upon resizes // (only in the renderer, not the editor) // workaround is to remove it and re-create it remove(jSlider); jSlider = new JSlider(minimum, maximum, intValues[0]); c.gridx = 0; c.gridy = 0; c.weighty = 1.0; c.weightx = 1.0; c.gridwidth = 3; add(jSlider, c); jSlider.addChangeListener(new sliderListener()); } parameterName.setText(currentParameter.getParamNameDescription()[0]); parameterName.setVisible(!currentParameter.getParamNameDescription()[0].equals("")); textMinimum.setEditable(currentParameter.editable()[0]); textMaximum.setEditable(currentParameter.editable()[1]); setToolTipText( Utils.encodeHTML(WordUtils.wrap(currentParameter.getParamNameDescription()[1], 50, null, true)) .replace("\n", "<br>\n")); silenceUpdate = false; int heightWanted = (int) getPreferredSize().getHeight(); if (table != null) if (heightWanted > table.getRowHeight(row)) table.setRowHeight(row, heightWanted); return this; }
From source file:pipeline.parameter_cell_views.TextBox.java
@Override public Component getRendererOrEditorComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, boolean rendererCalled) { ourColumn = column;/*www . j ava 2 s . c o m*/ ourRow = row; silenceUpdate = true; if (currentParameter != null) { currentParameter.removeListener(this); } owningTable = table; evenTableRow = (row % 2 == 0); setOpaque(true); if (evenTableRow) setBackground(Utils.COLOR_FOR_EVEN_ROWS); else setBackground(Utils.COLOR_FOR_ODD_ROWS); textField.setBackground(getBackground()); currentParameter = (TextParameter) value; currentParameter.addGUIListener(this); updateText(); lastNonChangingValue = currentValue == null ? null : new String(currentValue); int height = currentParameter.isCompactDisplay() ? 60 : 60; this.setPreferredSize(new Dimension(100, height)); this.setMinimumSize(new Dimension(10, height)); this.setMaximumSize(new Dimension(1000, currentParameter.isCompactDisplay() ? 40 : 60)); int heightWanted = (int) getPreferredSize().getHeight(); if ((table != null) && (heightWanted > table.getRowHeight(row)) && !(getParent() instanceof SplitParameterDisplay)) table.setRowHeight(row, heightWanted); silenceUpdate = false; return this; }