Here you can find the source of getPreferredSizeComponent(JComponent component)
Parameter | Description |
---|---|
component | the component |
public static JComponent getPreferredSizeComponent(JComponent component)
//package com.java2s; //License from project: Open Source License import java.awt.*; import javax.swing.*; public class Main { /**//from www. ja v a2 s . com * Wraps a {@link JComponent} into a {@link JPanel} using a {@link BorderLayout}, adding it to WEST.<br> * If using this method for e.g. a {@link JCheckBox} and adding it to a layout, the {@link JCheckBox} won't * span the entire space and thus, it won't change the checked state if clicking outside of it. * * @param component the component * @return the preferred size component */ public static JComponent getPreferredSizeComponent(JComponent component) { JPanel pWrap = new JPanel(new BorderLayout()); pWrap.add(component, BorderLayout.WEST); return pWrap; } }