List of utility methods to do JComponent Size
void | setSizeBasedOnResolution(final JComponent component) Set the size of the JComponent based on the resolution of the screen Dimension dimension = getDimensionBasedOnResolution(); component.setSize(dimension.width, dimension.height); |
void | setSizes(JComponent[] components, final Dimension dimension) set Sizes for (int i = 0; i < components.length; i++) { JComponent comp = components[i]; comp.setPreferredSize(dimension); comp.setMaximumSize(dimension); |
void | setSMPSizes(JComponent comp, Dimension d) set SMP Sizes comp.setSize(d); comp.setMinimumSize(d); comp.setPreferredSize(d); |
void | setUnlimitedSize(JComponent component) set Unlimited Size Dimension size = new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
component.setMaximumSize(size);
|
void | setZeroMinimumSize(Component component) Sets the component to a minimum size of zero to allow split panes and layout managers from shrinking the components if (component instanceof JComponent) { ((JComponent) component).setMinimumSize(ZERO_DIMENSION); |
void | show(final JComponent component, final String windowTitle, final Dimension size) Show the given component in it's own window. SwingUtilities.invokeLater(() -> showGUI(component, windowTitle, size)); |
void | showComponent(JComponent component, Dimension size) Shows a JFrame containing the specified component .
fixJMenuBug();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(component);
frame.pack();
frame.setVisible(true);
frame.setMinimumSize(size);
|
JFrame | showGUI(final JComponent newContentPane, final String windowTitle, final Dimension size) show GUI final JFrame frame = new JFrame(windowTitle); newContentPane.setOpaque(true); frame.setContentPane(newContentPane); if (size == null) { frame.pack(); } else { frame.setSize(size); frame.setLocationRelativeTo(null); frame.setVisible(true); return frame; |
void | showStaticPage(final URI uri, final Dimension size, final Point location) Creates a frame with a JEditorPane with given URI. final JFrame frame = new JFrame(); frame.getRootPane().setLayout(new BorderLayout()); JEditorPane editor = new JEditorPane(uri.toString()); editor.setEditable(false); JScrollPane scrollPane = new JScrollPane(editor); frame.getRootPane().add(scrollPane); frame.setAlwaysOnTop(true); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); ... |
void | sizeUniformly(JComponent... components) size Uniformly for (JComponent c : components) { c.setPreferredSize(null); c.setMinimumSize(null); c.setMaximumSize(null); int width = 0; int height = 0; for (JComponent c : components) { ... |