List of usage examples for javax.swing JTable getRowHeight
public int getRowHeight(int row)
row
. From source file:Main.java
/** * Returns the visual height of the given table. * * @param table the table.//from w ww .java 2 s. c om * * @return the table height. */ public static int getTableHeight(JTable table) { int result = 0; int rowHeight = 0; for (int i = 0, rows = table.getRowCount(); i < rows; i++) { int height = table.getRowHeight(i); result += height; if (height > rowHeight) { rowHeight = height; } } return result + rowHeight + (table.getRowCount() * table.getRowMargin()); }
From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java
public static void setVisibleRowCount(JTable table, int visibleRows) { int height = 0; for (int row = 0; row < visibleRows; row++) height += table.getRowHeight(row); table.setPreferredScrollableViewportSize( new Dimension(table.getPreferredScrollableViewportSize().width, height)); }
From source file:modnlp.capte.AlignmentInterfaceWS.java
public static void packRows(JTable table, int start, int end, int margin) { for (int r = 0; r < table.getRowCount(); r++) { // Get the preferred height int h = getPreferredRowHeight(table, r, margin); // Now set the row height using the preferred height if (table.getRowHeight(r) != h) { table.setRowHeight(r, h);//w ww. j a va2s . c o m } } }
From source file:ca.uhn.hl7v2.testpanel.ui.ActivityDetailsCellRenderer.java
private void updatePreferredHeight(final JTable theTable, final int theRow) { final int newHeight = (int) getPreferredSize().getHeight(); if (theTable.getRowHeight(theRow) != newHeight) { EventQueue.invokeLater(new Runnable() { public void run() { theTable.setRowHeight(theRow, newHeight); // theTable.getColumnModel().getColumn(2).setWidth(5000); }/*from w ww . j a va 2s . co m*/ }); } }
From source file:ca.uhn.hl7v2.testpanel.ui.ActivityDetailsCellRenderer.java
private void renderInfo(final JTable theTable, Object theValue, final int theRow) { if (theValue instanceof ActivityInfoError) { setForeground(Color.red); } else {//www . j a v a2s . co m setForeground(Color.black); } String message = ((ActivityInfo) theValue).getMessage(); setText(message); // setText(text); setFont(myVarWidthFont); if (theTable.getRowHeight(theRow) != theTable.getRowHeight()) { EventQueue.invokeLater(new Runnable() { public void run() { theTable.setRowHeight(theRow, theTable.getRowHeight()); } }); } }
From source file:edu.ku.brc.ui.UIHelper.java
/** * Sizes the table to number of rows using the height of actual rows. * @param table the table to be sized/* www . j a v a 2s .c o m*/ * @param rows the number of rows */ public static void setVisibleRowCountForHeight(final JTable table, final int rows) { if (table != null) { int height = 0; for (int row = 0; row < rows; row++) height += table.getRowHeight(row); table.setPreferredScrollableViewportSize( new Dimension(table.getPreferredScrollableViewportSize().width, height)); } }
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 w w w . j a v a 2s .co 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);//from w w w . j a va 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);//from w w w. java2s . c o 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 ww . ja v a2 s.c o 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; }