List of usage examples for java.awt DisplayMode getHeight
public int getHeight()
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gs = ge.getDefaultScreenDevice(); DisplayMode[] dmodes = gs.getDisplayModes(); for (int i = 0; i < dmodes.length; i++) { DisplayMode dm = dmodes[i]; int screenWidth = dm.getWidth(); int screenHeight = dm.getHeight(); System.out.println(screenWidth); System.out.println(screenHeight); }/* w w w . java 2 s. c o m*/ }
From source file:Main.java
public static void main(String[] argv) throws Exception { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); for (int i = 0; i < gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); int screenWidth = dm.getWidth(); int screenHeight = dm.getHeight(); }// w w w .j a va 2s. c o m }
From source file:br.com.ant.system.app.AntSystemApp.java
public static void main(String[] args) { try {//from www . j a v a 2 s . c o m if (SystemUtils.IS_OS_WINDOWS) { UIManager.setLookAndFeel(WindowsClassicLookAndFeel.class.getName()); } else { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } ColoniaFormigasView frame = new ColoniaFormigasView(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] devices = env.getScreenDevices(); DisplayMode mode = devices[0].getDisplayMode(); int height = mode.getHeight(); int width = mode.getWidth(); frame.setSize(width, height - 30); frame.setVisible(true); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:Main.java
/** Returns the Screen resolution of all available displays. If ther's only one display you might use: {@link #getScreenSize()} * @return Screen resolution of all available displays. * @see #getScreenSize()/*from ww w . ja va 2 s. co m*/ */ public static Dimension[] getScreenSizes() { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); // Get size of each screen Dimension[] dimension = new Dimension[gs.length]; for (int i = 0; i < gs.length; i++) { DisplayMode dm = gs[i].getDisplayMode(); dimension[i] = new Dimension(dm.getWidth(), dm.getHeight()); } return dimension; }
From source file:DisplayModeModel.java
public void actionPerformed(ActionEvent ev) { Object source = ev.getSource(); if (source == exit) { device.setDisplayMode(originalDM); System.exit(0);//from w ww . j a va 2 s .c o m } else { // if (source == changeDM) int index = dmList.getSelectionModel().getAnchorSelectionIndex(); if (index >= 0) { DisplayModeModel model = (DisplayModeModel) dmList.getModel(); DisplayMode dm = model.getDisplayMode(index); device.setDisplayMode(dm); setDMLabel(dm); setSize(new Dimension(dm.getWidth(), dm.getHeight())); validate(); } } }
From source file:DisplayModeModel.java
public Object getValueAt(int rowIndex, int colIndex) { DisplayMode dm = modes[rowIndex]; switch (colIndex) { case DisplayModeTest.INDEX_WIDTH: return Integer.toString(dm.getWidth()); case DisplayModeTest.INDEX_HEIGHT: return Integer.toString(dm.getHeight()); case DisplayModeTest.INDEX_BITDEPTH: { int bitDepth = dm.getBitDepth(); String ret;/* ww w . j a v a 2s . co m*/ if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) { ret = "Multi"; } else { ret = Integer.toString(bitDepth); } return ret; } case DisplayModeTest.INDEX_REFRESHRATE: { int refreshRate = dm.getRefreshRate(); String ret; if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) { ret = "Unknown"; } else { ret = Integer.toString(refreshRate); } return ret; } } throw new ArrayIndexOutOfBoundsException("Invalid column value"); }
From source file:com.callidusrobotics.swing.SwingConsole.java
private void initConsole(final Font font, final int rows, final int cols) { frame = new JFrame(); icon = new ImageIcon(); label = new JLabel(icon); // Compute font metrics final DisplayMode displayMode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDisplayMode();//from w ww . j a va 2 s. com frame.setVisible(true); imageBuffer = frame.createImage(displayMode.getWidth(), displayMode.getHeight()); graphicsRenderer = imageBuffer.getGraphics(); graphicsRenderer.setFont(font); final FontMetrics fontMetrics = graphicsRenderer.getFontMetrics(font); charHeight = fontMetrics.getHeight(); charWidth = fontMetrics.getHeight(); charHOffset = 0; charVOffset = fontMetrics.getAscent(); // Compute console dimensions and initialize graphics renderer final int width = charWidth * cols; final int height = charHeight * rows; imageBuffer = frame.createImage(width, height); graphicsRenderer = imageBuffer.getGraphics(); graphicsRenderer.setFont(font); render(); label.setBackground(TrueColor.MAGENTA); label.setBounds(0, 0, width, height); label.setVisible(true); frame.setBounds(0, 0, width, height); frame.setBackground(TrueColor.MAGENTA); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(label); frame.setCursor(null); frame.pack(); frame.setLocationRelativeTo(null); frame.setResizable(false); frame.addKeyListener(this); }
From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java
/** * This method initializes this/*ww w . j ava2 s.com*/ * */ private void initialize() { this.setSize(new Dimension(534, 264)); this.setResizable(false); this.setModal(true); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setContentPane(getJPanel()); this.setTitle(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_5)); // Centramos la ventana del applet // Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice[] gs = ge.getScreenDevices(); int screenWidth = 0; int screenHeight = 0; int longitud = gs.length; for (int i = 0; i < longitud; i++) { DisplayMode dm = gs[i].getDisplayMode(); screenWidth = dm.getWidth(); screenHeight = dm.getHeight(); } this.setLocation((int) (screenWidth / 2) - (int) (539 / 2), (int) (screenHeight / 2) - (int) (497 / 2)); }
From source file:DisplayModeModel.java
public void setDMLabel(DisplayMode newMode) { int bitDepth = newMode.getBitDepth(); int refreshRate = newMode.getRefreshRate(); String bd, rr;/* w w w.j av a 2 s.c o m*/ if (bitDepth == DisplayMode.BIT_DEPTH_MULTI) { bd = "Multi"; } else { bd = Integer.toString(bitDepth); } if (refreshRate == DisplayMode.REFRESH_RATE_UNKNOWN) { rr = "Unknown"; } else { rr = Integer.toString(refreshRate); } currentDM.setText(COLUMN_NAMES[INDEX_WIDTH] + ": " + newMode.getWidth() + " " + COLUMN_NAMES[INDEX_HEIGHT] + ": " + newMode.getHeight() + " " + COLUMN_NAMES[INDEX_BITDEPTH] + ": " + bd + " " + COLUMN_NAMES[INDEX_REFRESHRATE] + ": " + rr); }
From source file:Filter3dTest.java
/** * Determines if two display modes "match". Two display modes match if they * have the same resolution, bit depth, and refresh rate. The bit depth is * ignored if one of the modes has a bit depth of * DisplayMode.BIT_DEPTH_MULTI. Likewise, the refresh rate is ignored if one * of the modes has a refresh rate of DisplayMode.REFRESH_RATE_UNKNOWN. */// www. j a va 2s .c om public boolean displayModesMatch(DisplayMode mode1, DisplayMode mode2) { if (mode1.getWidth() != mode2.getWidth() || mode1.getHeight() != mode2.getHeight()) { return false; } if (mode1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI && mode1.getBitDepth() != mode2.getBitDepth()) { return false; } if (mode1.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && mode2.getRefreshRate() != DisplayMode.REFRESH_RATE_UNKNOWN && mode1.getRefreshRate() != mode2.getRefreshRate()) { return false; } return true; }