1

I have a JTable in which 1 column contains 3 radiobuttons per cell

mgrdData.getColumnModel().getColumn(intCol).setCellRenderer(new RadioButtonRenderer());
RadioButtonEditor butEdit = new RadioButtonEditor(new JCheckBox());
mgrdData.getColumnModel().getColumn(intCol).setCellEditor(butEdit);

This works fine as the radiobuttons are shown, and the correct ones are selected.

However the radiobuttons are too large to be completely visible, so I would like to reduce the height of the radiobuttons.

I tried changing the fontsize, as well as .setSize(), but that didn't have any effect on the height of the radiobutton.

After searching a lot, all I could find was the following :

btnVA.putClientProperty("JComponent.sizeVariant","mini");
btnUIT.putClientProperty("JComponent.sizeVariant","mini");
btnAAN.putClientProperty("JComponent.sizeVariant","mini");

where btnVA, btnUIT, and btnAAN are the radiobuttons in my RadioButtonRenderer.

If you want to see some more code let me know, and I will edit it in.

Is there anything special I should add to make the radiobuttons apply this ClientProperty?

kleopatra
  • 51,061
  • 28
  • 99
  • 211
Hrqls
  • 2,944
  • 4
  • 34
  • 54

2 Answers2

1

Try the setPreferredSize() // pretty sure that was the syntax.

method instead, see if that helps any. Remember someone in my class having this issue.

ObedMarsh
  • 433
  • 4
  • 19
  • Thanks for your answer! I found the solution though by changing the LookAndFeel to Nimbus. – Hrqls Feb 06 '13 at 15:21
0

I had overlooked that this code required the Nimbus LookAndFeel.

For easier testing with various LookAndFeels i created a function which I call in the init() of my Applet :

private void setLaF()
{
  try
  {
    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
    {
      if ("Nimbus".equals(info.getName()))
      {
        UIManager.setLookAndFeel(info.getClassName());
        break;
      }
    }
  } catch (Exception e)
  {
      // If Nimbus is not available, you can set the GUI to another look and feel.
  }
}

After calling this function, the radiobuttons do behave, and change their height accordingly

Hrqls
  • 2,944
  • 4
  • 34
  • 54