Dimension size = new JTextField(cols).getPreferredSize();
Dimension size; if (cols >= 0) size = new JTextField(cols).getPreferredSize(); else size = new JRadioButton().getPreferredSize();
    private static JLabel getSizedJLabel(String text, int cols)    {        JLabel out = new JLabel(text);        Dimension size = new JTextField(cols).getPreferredSize();        out.setMaximumSize(size);        return out;    }