List of usage examples for java.awt Dimension Dimension
public Dimension()
From source file:Main.java
/** * /*from w ww. j a v a 2 s. c o m*/ * @param component */ public static void setMiniSize(JFrame component) { Dimension size = new Dimension(); size.height = (int) (Toolkit.getDefaultToolkit().getScreenSize().height / 4); size.width = (int) (Toolkit.getDefaultToolkit().getScreenSize().width / 4); component.setMinimumSize(size); }
From source file:Main.java
public static Dimension currentWindowSize(double widthRatio, double heightRatio) { Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); Dimension rtnDim = new Dimension(); rtnDim.width = new Double(dim.getWidth() * widthRatio).intValue(); rtnDim.height = new Double(dim.getHeight() * heightRatio).intValue(); return rtnDim; }
From source file:Main.java
public static void pack(Component c) { Window window = getFrame(c);/* www . j a v a 2 s .co m*/ window.pack(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension bounds = new Dimension(); bounds.width = Math.min(window.getWidth(), screenSize.width * 8 / 10); bounds.height = Math.min(window.getHeight(), screenSize.height * 8 / 10); window.setSize(bounds); }
From source file:Main.java
/** * Converts a Bound to a Dimension. Note that some information will be * lost (depth, x, y, etc) yet the width and height will be preserved * @param pBound/*from w ww .j a va2 s . c o m*/ * @return */ public static Dimension convertToDimension(Bounds pBound) { Dimension result = new Dimension(); result.setSize(pBound.getWidth(), pBound.getHeight()); return result; }
From source file:Main.java
/** * Returns the maximum preferred size of the given components. * @param components the components/* w ww . ja v a2s . c o m*/ * @return Dimension */ public static final Dimension getMaximumSize(Component... components) { Dimension size = new Dimension(); for (Component component : components) { Dimension cSize = component.getPreferredSize(); if (size.width < cSize.width) { size.width = cSize.width; } if (size.height < cSize.height) { size.height = cSize.height; } } return size; }