List of usage examples for java.awt DisplayMode DisplayMode
public DisplayMode(int width, int height, int bitDepth, int refreshRate)
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); boolean canChg = gs.isDisplayChangeSupported(); if (canChg) { DisplayMode displayMode = gs.getDisplayMode(); int screenWidth = 640; int screenHeight = 480; int bitDepth = 8; displayMode = new DisplayMode(screenWidth, screenHeight, bitDepth, displayMode.getRefreshRate()); try {//ww w.j a v a2 s .c o m gs.setDisplayMode(displayMode); } catch (Throwable e) { gs.setFullScreenWindow(null); } } }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(800, 600);/*from w ww . j a va 2 s. c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device.setFullScreenWindow(frame); device.setDisplayMode(new DisplayMode(800, 600, 32, 60)); frame.setVisible(true); JButton btn = new JButton(); btn.setText("Button"); JPanel panel = new JPanel(); panel.add(btn); frame.add(panel); btn.addActionListener(e -> { JOptionPane.showMessageDialog(frame.getContentPane(), "JOptionPane"); }); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); device.setFullScreenWindow(frame);//from w w w.j av a 2 s . com device.setDisplayMode(new DisplayMode(800, 600, 32, 60)); frame.addWindowListener(new WindowAdapter() { @Override public void windowIconified(WindowEvent we) { if (programmatic) { programmatic = false; frame.setState(JFrame.NORMAL); } } }); JButton btn = new JButton(); btn.setText("Btn"); final JPanel panel = new JPanel(); panel.add(btn); frame.add(panel); btn.addActionListener(e -> { programmatic = true; JOptionPane.showMessageDialog(panel, "Sample"); }); frame.setVisible(true); }