public Dimension getAvailableSize() { Dimension availableSize = getSize(); if (!cc.opts.fullScreen) { Insets vpInsets = VncViewer.insets; availableSize.width -= vpInsets.left + vpInsets.right; availableSize.height -= vpInsets.top + vpInsets.bottom; } if (tb.isVisible()) availableSize.height -= tb.getHeight(); if (availableSize.width < 0) availableSize.width = 0; if (availableSize.height < 0) availableSize.height = 0; return availableSize; }
/** * Returns the preferred size of the viewport for a view component. For example the preferredSize * of a JList component is the size required to acommodate all of the cells in its list however * the value of preferredScrollableViewportSize is the size required for * JList.getVisibleRowCount() rows. A component without any properties that would effect the * viewport size should just return getPreferredSize() here. * * @return The preferredSize of a JViewport whose view is this Scrollable. * @see JViewport#getPreferredSize */ public Dimension getPreferredScrollableViewportSize() { Dimension size = getPreferredSize(); Dimension retval = new Dimension(); retval.width = size.width > 600 ? 600 : size.width; retval.height = size.height > 400 ? 400 : size.height; return retval; }
public static void openFrame(Object frame) { boolean packFrame = false; if (packFrame) { ((JFrame) frame).pack(); } else { ((JFrame) frame).validate(); } // Center the window Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = ((JFrame) frame).getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } ((JFrame) frame) .setLocation( (screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); ((JFrame) frame).setVisible(true); }