Java Code Examples for javax.swing.JComponent.getMinimumSize()

The following are Jave code examples for showing how to use getMinimumSize() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: DataView.java   View Source Code Vote up 6 votes
public Dimension minimumLayoutSize(Container parent) {
    JComponent filter = filterPanel;
    if (filter != null && !filter.isVisible()) filter = null;
    
    JComponent search = searchPanel;
    if (search != null && !search.isVisible()) search = null;
    
    Dimension dim = new Dimension();
    
    if (filter != null && search != null) {
        Dimension dim1 = filter.getMinimumSize();
        Dimension dim2 = search.getMinimumSize();
        dim.width = dim1.width + dim2.width + 1;
        dim.height = Math.max(dim1.height, dim2.height);
    } else if (filter != null) {
        dim = filter.getMinimumSize();
    } else if (search != null) {
        dim = search.getMinimumSize();
    }
    
    if ((filter != null || search != null) && hasBottomFilterFindMargin())
        dim.height += 1;
    
    return dim;
}
 
Example 2
Project: Equella   File: AccessEditor.java   View Source Code Vote up 6 votes
private void setupGUI()
{
	JComponent whoCanPanel = createWhoCanPanel();
	JComponent modePanel = createModePanel();

	container = new JPanel(new GridLayout(1, 1));

	JSeparator separator = new JSeparator();

	final int height1 = whoCanPanel.getPreferredSize().height;
	final int height2 = modePanel.getMinimumSize().height;
	final int height3 = separator.getPreferredSize().height;
	final int[] rows = {height1, height2, height3, TableLayout.FILL,};
	final int[] cols = {TableLayout.DOUBLE_FILL, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));
	add(whoCanPanel, new Rectangle(0, 0, 1, 1));
	add(modePanel, new Rectangle(0, 1, 2, 1));
	add(separator, new Rectangle(0, 2, 2, 1));
	add(container, new Rectangle(0, 3, 2, 1));
}
 
Example 3
Project: Equella   File: ClientLauncher.java   View Source Code Vote up 5 votes
private void setupGUI()
{
	JComponent serverList = createServerList();
	JComponent configButtons = createConfigButtons();
	JComponent connectExit = createConnectExit();

	configButtonsHeight = configButtons.getPreferredSize().height;

	final int height1 = serverList.getMinimumSize().height;
	final int height2 = connectExit.getMinimumSize().height;
	final int[] rows = {height1, 0, height2,};
	final int[] cols = {WINDOW_WIDTH,};

	layout = new TableLayout(rows, cols);
	JPanel all = new JPanel(layout);
	all.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

	all.add(serverList, new Rectangle(0, 0, 1, 1));
	all.add(configButtons, new Rectangle(0, 1, 1, 1));
	all.add(connectExit, new Rectangle(0, 2, 1, 1));

	updateButtons();

	setTitle(WINDOW_TITLE);
	setResizable(false);
	getContentPane().add(all);
	getRootPane().setDefaultButton(connect);
	addWindowListener(this);
	setDefaultCloseOperation(EXIT_ON_CLOSE);

	pack();
	ComponentHelper.centreOnScreen(this);
}