JFrame frame = new JFrame(); // ... GraphicsDevice device = frame.getGraphicsConfiguration().getDevice();
CloseIcon() { img = frame.getGraphicsConfiguration().createCompatibleImage(20, 16, Transparency.TRANSLUCENT); Graphics2D g = img.createGraphics(); g.setColor(Color.black); g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.drawOval(4 + 2, 2, 12, 12); g.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); g.drawLine(4 + 4, 4, 4 + 11, 12); g.drawLine(4 + 4, 12, 4 + 11, 4); icon = new ImageIcon(img); }
private static void showSplashPanel() throws IOException { File karafBase = new File(System.getProperty("karaf.base")); BufferedImage background = ImageIO.read(new File(karafBase, "CytoscapeSplashScreen.png")); splashPanel = new SplashPanel(background); final JFrame frame = new JFrame(); frame.add(splashPanel); frame.setUndecorated(true); int width = background.getWidth(); int height = background.getHeight(); frame.setSize(width, height); // Center the frame in the current screen. Rectangle bounds = frame.getGraphicsConfiguration().getBounds(); frame.setLocation((bounds.width - width) / 2, (bounds.height - height) / 2); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { frame.setVisible(true); } }); }
/** * Creates a window showing the specified image. */ public static ImagePanel showWindow(BufferedImage img, String title, boolean closeOnExit ) { JFrame frame = new JFrame(title); ImagePanel panel = new ImagePanel(img); panel.setScaling(ScaleOptions.DOWN); // If the window will be too large to be displayed on the monitor set the bounds to something that can be // shown. The default behavior will just change one axis leaving it to have an awkward appearance Rectangle monitorBounds = frame.getGraphicsConfiguration().getBounds(); if( monitorBounds.width < img.getWidth() || monitorBounds.height < img.getHeight()) { double scale = Math.min(monitorBounds.width/(double)img.getWidth(),monitorBounds.height/(double)img.getHeight()); int width = (int)(scale*img.getWidth()); int height = (int)(scale*img.getHeight()); panel.setPreferredSize(new Dimension(width,height)); } frame.add(panel, BorderLayout.CENTER); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); if( closeOnExit ) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); return panel; }
/** * Requests the presentation be located at a given position. */ public void setLocation(Point p) { debug("setLocation"); location = p; if (jhelp != null) { if (modallyActivated) { if (dialog != null) { GraphicsConfiguration gc = dialog.getGraphicsConfiguration(); Rectangle gcBounds = gc.getBounds(); Point loc = new Point (gcBounds.x + p.x, gcBounds.y + p.y); dialog.setLocation(loc); } } else { if (frame != null) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Rectangle gcBounds = gc.getBounds(); Point loc = new Point (gcBounds.x + p.x, gcBounds.y + p.y); frame.setLocation(loc); } } } }
private void putPreferencesLocation() { int x = frame.getLocation().x; int y = frame.getLocation().y; if(getPreferencesX() == x && getPreferencesY() == y) return; preferences.putInt(X_PREFERENCE, x); preferences.putInt(Y_PREFERENCE, y); log.info("Storing frame location as " + frame.getLocation()); String deviceId = frame.getGraphicsConfiguration().getDevice().getIDstring(); preferences.put(DEVICE_PREFERENCE, deviceId); log.info("Storing graphics device as " + deviceId); }
/** * Maximize/Restore the window. * * @param maximize iconify {@code true} if we are to maximize the window, * {@code false} if we are to restore the window. */ private void setParentMaximum(boolean maximize) { if (rootParent instanceof JFrame) { JFrame frame = (JFrame) rootParent; int state = frame.getExtendedState(); if (maximize) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Insets i = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle r = gc.getBounds(); r.x = 0; r.y = 0; r.width -= i.left + i.right; r.height -= i.top + i.bottom; frame.setMaximizedBounds(r); } frame.setExtendedState(maximize ? state | Frame.MAXIMIZED_BOTH : state & ~Frame.MAXIMIZED_BOTH); } }
jf.setUndecorated(true); jf.pack(); DisplayMode dm = jf.getGraphicsConfiguration().getDevice().getDisplayMode(); Dimension contentSize = jf.getSize(); jf.dispose();
Point flocation = frame.getLocation(); if (isXinerama()) { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Rectangle gcBounds = gc.getBounds(); return new Point(flocation.x - gcBounds.x,
gc = frame.getGraphicsConfiguration();
public void moveToVisible(JFrame frame) { // Vertical position GraphicsDevice activeScreen = getGraphicsConfiguration().getDevice(); if (frame.getLocation().y < 0) { frame.setLocation(getLocation().x, 0); } if ((frame.getLocation().y + frame.getHeight()) > activeScreen.getDisplayMode().getHeight()) { frame.setLocation( frame.getLocation().x, (activeScreen.getDisplayMode().getHeight() - frame.getHeight()) ); } // Horizontal position int offsetRight = frame.getX() + frame.getWidth() - frame.getGraphicsConfiguration().getBounds().x + frame.getGraphicsConfiguration().getBounds().width; if (offsetRight > 0) { setLocation(frame.getX() - offsetRight, frame.getY()); } int offsetLeft = frame.getX() - frame.getGraphicsConfiguration().getBounds().x; if (offsetLeft < 0) { frame.setLocation(frame.getX() - offsetLeft, frame.getY()); } }
frame.setLocationRelativeTo(null); Rectangle bounds = frame.getGraphicsConfiguration().getBounds(); Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(frame.getGraphicsConfiguration()); log.info("Screen size is " + bounds + ", insets are " + insets);
final Image background = frame.getGraphicsConfiguration().createCompatibleImage(512, 512); final Image some = new ij.io.Opener().openImage("http://rsb.info.nih.gov/ij/images/bridge.gif").getProcessor().createImage(); java.awt.Graphics g = background.getGraphics();
GraphicsDevice device = frame.getGraphicsConfiguration().getDevice(); boolean result = device.isFullScreenSupported(); frame.setPreferredSize(frame.getGraphicsConfiguration().getBounds().getSize());
device = frame.getGraphicsConfiguration().getDevice();
Iterable<Window> visibleFrames = collectVisibleFrames(frame); if (fullScreen) { final GraphicsConfiguration graphicsConfiguration = frame.getGraphicsConfiguration(); final Rectangle bounds = graphicsConfiguration.getBounds(); frame.getRootPane().putClientProperty(FrameState.class,