JFrame frame = new JFrame("title"); frame.setVisible(true); System.out.println(frame.getInsets());
public BambooVideoWall() { jFrame = new JFrame(BambooVideoWall.class.getSimpleName()); double adjustedVideoHeight = PLAYBACKER_HEIGHT / (double) NUMBER_OF_ROWS_OF_VIDEO; double adjustedVideoWidth = adjustedVideoHeight * VIDEO_WIDTH / VIDEO_HEIGHT; double width = adjustedVideoWidth * NUMBER_OF_COLUMNS_OF_VIDEO; videoPlayerGrid = new VideoPlayerGrid(NUMBER_OF_ROWS_OF_VIDEO, NUMBER_OF_COLUMNS_OF_VIDEO); jFrame.getContentPane().add(videoPlayerGrid); jFrame.setSize((int) width, (int) PLAYBACKER_HEIGHT + jFrame.getInsets().top); jFrame.setIconImage(new ImageIcon(ClassLoader.getSystemResource("us/ihmc/tools/icons/running-man-32x32.png").getPath()).getImage()); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.setVisible(true); }
/** * If a border has been set on this component, returns the border's * insets; otherwise calls super.getInsets. * * @return the value of the insets property */ public Insets getInsets() { Insets swingInsets = null; if (frame != null) { swingInsets = frame.getInsets(); } else { swingInsets = component.getInsets(); } Insets result = new Insets(swingInsets.top + adjustInsets.top, swingInsets.left + adjustInsets.left, swingInsets.bottom + adjustInsets.bottom, swingInsets.right + adjustInsets.right); return result; }
public static void fullscreen () { frame.setResizable(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); int w = frame.getSize().width; int h = frame.getSize().height; //int w = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); //int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); int borderY = frame.getInsets().top + frame.getInsets().bottom; int borderX = frame.getInsets().left + frame.getInsets().right; setCanvasSize(w - borderX, h - borderY - menuBar.getHeight(), true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); }
public static void fullscreen () { frame.setResizable(true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); int w = frame.getSize().width; int h = frame.getSize().height; //int w = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(); //int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight(); int borderY = frame.getInsets().top + frame.getInsets().bottom; int borderX = frame.getInsets().left + frame.getInsets().right; setCanvasSize(w - borderX, h - borderY - menuBar.getHeight(), true); frame.setExtendedState(Frame.MAXIMIZED_BOTH); }
private void setResolution(Dimension dim) { Dimension insetAwareDimension = new Dimension(dim.width + this.hostControl.getInsets().left + this.hostControl.getInsets().right, dim.height + this.hostControl.getInsets().top + this.hostControl.getInsets().bottom); if (Game.config().graphics().enableResolutionScaling()) { this.resolutionScale = (float) (dim.getWidth() / Resolution.Ratio16x9.RES_1920x1080.getWidth()); Game.graphics().setBaseRenderScale(Game.graphics().getBaseRenderScale() * this.resolutionScale); } this.hostControl.setSize(insetAwareDimension); }
/** * Resize the component to match the font dimensions. * * @param width the new width in pixels * @param height the new height in pixels */ public void setDimensions(final int width, final int height) { // Figure out the thickness of borders and use that to set the final // size. if (frame != null) { Insets insets = frame.getInsets(); frame.setSize(width + insets.left + insets.right, height + insets.top + insets.bottom); } else { Insets insets = component.getInsets(); component.setSize(width + insets.left + insets.right, height + insets.top + insets.bottom); } }
public class SwingExample implements Runnable { @Override public void run() { // Create the window final JFrame f = new JFrame("Hello, World!"); SwingExample.centerWindow(f); f.setPreferredSize(new Dimension(500, 250)); f.setMaximumSize(new Dimension(10000, 200)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void centerWindow(JFrame frame) { Insets insets = frame.getInsets(); frame.setSize(new Dimension(insets.left + insets.right + 500, insets.top + insets.bottom + 250)); frame.setVisible(true); frame.setResizable(false); Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); int x = (int) ((dimension.getWidth() - frame.getWidth()) / 2); int y = (int) ((dimension.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); } }
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLayout(new GridLayout(1,2)); Insets inset = frame.getInsets();
final Insets insets = frame.getInsets();
frame.add(b3); Insets insets = frame.getInsets(); Dimension size = b1.getPreferredSize();
public void componentResized(ComponentEvent event) { Insets insetsFrame = frame.getInsets(); windowWidth = frame.getWidth() - insetsFrame.left - insetsFrame.right - settingsPanel2.getWidth(); windowHeight = frame.getHeight() - insetsFrame.bottom - insetsFrame.top - settingsPanel1.getHeight(); if (windowHeight>0 && windowWidth > 0) resizeImagePanel(windowWidth, windowHeight); frame.pack(); } });
@Override public Dimension getPreferredSize() { Dimension frame = super.getPreferredSize(); Insets fb = super.getInsets(); Dimension screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().getSize(); Dimension canvasSize = canvas.getPreferredSize();
showingForms.put(formKey, this); frame.setVisible(true); Insets decorInsets = frame.getInsets(); windowDecorSize = new Dimension(decorInsets.left + decorInsets.right, decorInsets.top + decorInsets.bottom); if (formSize != null) {
int screenHeight = screenSize.height; Insets ins = frame.getInsets(); xloc = (screenWidth-windowWidth-ins.left-ins.right - 70)/2; yloc = (screenHeight-windowHeight-ins.bottom-ins.top - 75)/2;