Note that there are some explanatory texts on larger screens.

plurals
  1. POresizing component in jtable cell
    text
    copied!<p>I am trying to resize a slider inside a jtable cell. But when resizing the column header, I do pass in the concerned code (method getTableCellRendererComponent for column one), but nothing happens (the slider is not resized??).</p> <p>below is the code of my renderer :</p> <pre><code>public class NavigationDataModelRenderer extends JLabel implements TableCellRenderer { private JSlider slider = null; public NavigationDataModelRenderer() { super(); } public NavigationDataModelRenderer(int tolerance) { super(); slider = new JSlider(tolerance * -3,tolerance *3); slider.setPaintTicks(true); slider.setMajorTickSpacing(tolerance); slider.setUI(new SpreadSliderUI(slider)); } @Override public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected, boolean hasFocus, int row, int column) { Component comp = null; if (table.getModel()!= null &amp;&amp; table.getModel() instanceof NavigationDataModel) { NavigationDataModel model = (NavigationDataModel) table.getModel(); Object o = table.getModel().getValueAt(row, column); this.setText(o.toString()); if (column == 1) {//slider if (model.getList() != null &amp;&amp; model.getList().get(0)!= null &amp;&amp; model.getList().get(row) != null) { slider.setValue((Integer)o); } comp = slider; slider.setSize(table.getCellRect(row, column, false).getSize()); } else if (column == 2) { if (((Integer)o) == Integer.MAX_VALUE) { this.setText("Invalid"); } } else { comp = this; } } return comp; } </code></pre> <p>}</p> <p>thanks for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload