Example usage for javax.swing JTable getRowHeight

List of usage examples for javax.swing JTable getRowHeight

Introduction

In this page you can find the example usage for javax.swing JTable getRowHeight.

Prototype

public int getRowHeight(int row) 

Source Link

Document

Returns the height, in pixels, of the cells in row.

Usage

From source file:pipeline.parameter_cell_views.FloatSlider.java

@SuppressWarnings("unused")
@Override// w ww  .  j a v  a2  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 a  va  2s. c  o  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);/*  w w  w  .  j  a  v a  2 s  .  c om*/
    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;/*w w  w.  j  a va  2  s .com*/
    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;

}