Example usage for java.awt DisplayMode getWidth

List of usage examples for java.awt DisplayMode getWidth

Introduction

In this page you can find the example usage for java.awt DisplayMode getWidth.

Prototype

public int getWidth() 

Source Link

Document

Returns the width of the display, in pixels.

Usage

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();
        System.out.println(screenWidth);
    }/*from   w ww  .j  a va2  s .c o  m*/
}

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);
    }/*  www.jav  a2s .com*/
}

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();
    }/*from w  ww.  ja v a  2  s.co  m*/

}

From source file:br.com.ant.system.app.AntSystemApp.java

public static void main(String[] args) {

    try {/*from  w w  w.  ja  v a  2s.  c om*/
        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()/*ww  w.j  a v  a2 s.c  om*/
 */
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 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;// w w w . j  a  v a 2 s .  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:DisplayModeModel.java

public void actionPerformed(ActionEvent ev) {
    Object source = ev.getSource();
    if (source == exit) {
        device.setDisplayMode(originalDM);
        System.exit(0);/*from w w  w  .jav a  2s .  co 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: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  v a2  s  . co  m
    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:DisplayModeModel.java

public void setDMLabel(DisplayMode newMode) {
    int bitDepth = newMode.getBitDepth();
    int refreshRate = newMode.getRefreshRate();
    String bd, rr;//from ww w .j av a  2  s  .c om
    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:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes this/*from ww w. j  ava2s . c  o m*/
 * 
 */
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));
}