當前位置: 首頁>>代碼示例>>Java>>正文


Java DisplayMode.getWidth方法代碼示例

本文整理匯總了Java中java.awt.DisplayMode.getWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java DisplayMode.getWidth方法的具體用法?Java DisplayMode.getWidth怎麽用?Java DisplayMode.getWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.DisplayMode的用法示例。


在下文中一共展示了DisplayMode.getWidth方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getMatchingDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:Win32GraphicsDevice.java

示例2: getMatchingDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
    if (!isDisplayChangeSupported()) {
        return null;
    }
    DisplayMode[] modes = getDisplayModes();
    for (DisplayMode mode : modes) {
        if (dm.equals(mode) ||
            (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
             dm.getWidth() == mode.getWidth() &&
             dm.getHeight() == mode.getHeight() &&
             dm.getBitDepth() == mode.getBitDepth()))
        {
            return mode;
        }
    }
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:X11GraphicsDevice.java

示例3: testWindowBounds

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static void testWindowBounds(final DisplayMode dm, final Window w) {
    if (w.getWidth() != dm.getWidth() || w.getHeight() != dm.getHeight()) {
        System.err.println(" Wrong window bounds:" +
                           " Expected: width = " + dm.getWidth()
                           + ", height = " + dm.getHeight() + " Actual: "
                           + w.getSize());
        passed = false;
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:10,代碼來源:FullScreenInsets.java

示例4: loadWindowGeometryFromConfig

import java.awt.DisplayMode; //導入方法依賴的package包/類
public void loadWindowGeometryFromConfig() {
    final Framework framework = Framework.getInstance();
    String maximisedStr = framework.getConfigVar(CONFIG_GUI_MAIN_MAXIMISED, false);
    String widthStr = framework.getConfigVar(CONFIG_GUI_MAIN_WIDTH, false);
    String heightStr = framework.getConfigVar(CONFIG_GUI_MAIN_HEIGHT, false);

    boolean maximised = (maximisedStr == null) ? true : Boolean.parseBoolean(maximisedStr);
    setExtendedState(maximised ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);

    DisplayMode mode = getDisplayMode();
    Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(getGraphicsConfiguration());
    int width = mode.getWidth() - insets.right - insets.left;
    int height = mode.getHeight() - insets.top - insets.bottom;
    if ((widthStr != null) && (heightStr != null)) {
        width = Integer.parseInt(widthStr);
        if (width < MIN_WIDTH) {
            width = MIN_WIDTH;
        }
        height = Integer.parseInt(heightStr);
        if (height < MIN_HEIGHT) {
            height = MIN_HEIGHT;
        }
    }
    setSize(width, height);
}
 
開發者ID:workcraft,項目名稱:workcraft,代碼行數:26,代碼來源:MainWindow.java

示例5: init

import java.awt.DisplayMode; //導入方法依賴的package包/類
private void init(int deviceID) throws Exception {
	if (deviceID < -1)
		throw new Exception("Unknown Device Handle");
	ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	if (deviceID != -1) {
		screen = ge.getScreenDevices()[deviceID];
	}
	else {
		screen = ge.getDefaultScreenDevice();
	}
	
	DisplayMode mode = screen.getDisplayMode();
	refreshRate = mode.getRefreshRate();
	bitDepth = mode.getBitDepth();
	colors = (int) Math.pow(2, bitDepth);
	dimensions = new Vector2(mode.getWidth(), mode.getHeight());
}
 
開發者ID:nickclark2016,項目名稱:JavaGraphicsEngine,代碼行數:18,代碼來源:Device.java

示例6: getBestDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
/**
 * Finds the best display mode the graphics device supports. Based on the
 * preferred modes.
 * 
 * @param device the device being inspected
 * 
 * @return best display mode the given device supports
 */
protected DisplayMode getBestDisplayMode(final GraphicsDevice device) {
    final Iterator itr = getPreferredDisplayModes(device).iterator();
    while (itr.hasNext()) {
        final DisplayMode each = (DisplayMode) itr.next();
        final DisplayMode[] modes = device.getDisplayModes();
        for (int i = 0; i < modes.length; i++) {
            if (modes[i].getWidth() == each.getWidth() && modes[i].getHeight() == each.getHeight()
                    && modes[i].getBitDepth() == each.getBitDepth()) {
                return each;
            }
        }
    }

    return null;
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:24,代碼來源:PFrame.java

示例7: findDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
private DisplayMode findDisplayMode() {
    GraphicsDevice gd = getGraphicsConfiguration().getDevice();
    DisplayMode dms[] = gd.getDisplayModes();
    DisplayMode currentDM = gd.getDisplayMode();
    for (DisplayMode dm : dms) {
        if (dm.getBitDepth() > 8 &&
            dm.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
            dm.getBitDepth() != currentDM.getBitDepth() &&
            dm.getWidth() == currentDM.getWidth() &&
            dm.getHeight() == currentDM.getHeight())
        {
            // found a mode which has the same dimensions but different
            // depth
            return dm;
        }
        if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI &&
            (dm.getWidth() != currentDM.getWidth() ||
             dm.getHeight() != currentDM.getHeight()))
        {
            // found a mode which has the same depth but different
            // dimensions
            return dm;
        }
    }

    return null;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:28,代碼來源:AltTabCrashTest.java

示例8: deriveDepth

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveDepth(DisplayMode dm) {
    int depth;
    if (dm.getBitDepth() == DisplayMode.BIT_DEPTH_MULTI) {
        depth = 77;
    } else {
        depth = DisplayMode.BIT_DEPTH_MULTI;
    }
    return new DisplayMode(dm.getWidth(), dm.getHeight(),
                           depth, dm.getRefreshRate());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:11,代碼來源:NonExistentDisplayModeTest.java

示例9: ScreenResolution

import java.awt.DisplayMode; //導入方法依賴的package包/類
/**
 * Constructor where the resolution is computed.
 *
 * @param comp - the frame of the gui - needed to get the resolution of the screen where the app is showed
 */
public ScreenResolution(Component comp) {
    //set the current screen resolution                
    GraphicsConfiguration graphicsCfg = comp.getGraphicsConfiguration();
    DisplayMode displayMode = graphicsCfg.getDevice().getDisplayMode();
    resolution = new Dimension(displayMode.getWidth(), displayMode.getHeight());
}
 
開發者ID:buni-rock,項目名稱:Pixie,代碼行數:12,代碼來源:ScreenResolution.java

示例10: getCenterToScreenLocation

import java.awt.DisplayMode; //導入方法依賴的package包/類
public static Point getCenterToScreenLocation(final DisplayMode displayMode, final Dimension size) {
  if (displayMode == null) {
    return new Point();
  }
  final int x = displayMode.getWidth() / 2 - size.width / 2;
  final int y = displayMode.getHeight() / 2 - size.height / 2;
  return new Point(x, y);
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:9,代碼來源:GuiUtilities.java

示例11: setDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
public void setDisplayMode(DisplayMode dm)
{
  if (fixedDisplayMode != null)
    throw new UnsupportedOperationException("Cannnot change display mode.");

  if (dm == null)
    throw new IllegalArgumentException("DisplayMode must not be null.");

  synchronized (this)
    {
      if (displayModes == null)
        displayModes = nativeGetDisplayModes(env);
    }

  for (int i=0; i<displayModes.length; i++)
    if (displayModes[i].width == dm.getWidth()
        && displayModes[i].height == dm.getHeight())
      {
        synchronized (this)
        {
          nativeSetDisplayMode(env,
                               i,
                               (short) dm.getRefreshRate());

          bounds = null;
        }

        return;
      }

  throw new IllegalArgumentException("Mode not supported by this device.");
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:33,代碼來源:GdkScreenGraphicsDevice.java

示例12: SystemNode

import java.awt.DisplayMode; //導入方法依賴的package包/類
public SystemNode(GraphicsDevice device) {
    super("System", device);

    addStringChild("Java version", System.getProperty("java.version"));
    addStringChild("Java vendor", System.getProperty("java.vendor"));
    addStringChild("OS name", System.getProperty("os.name"));

    DisplayMode displayMode = device.getDisplayMode();

    int width = displayMode.getWidth();
    int height = displayMode.getHeight();
    int bitDepth = displayMode.getBitDepth();
    addIntChild("display width", width);
    addIntChild("display height", height);
    addIntChild("display bit depth", bitDepth);

    PixelitorWindow pw = PixelitorWindow.getInstance();
    addIntChild("app window width", pw.getWidth());
    addIntChild("app window height", pw.getHeight());

    addStringChild("max memory", Utils.getMaxHeapInMegabytes() + " Mb");
    addStringChild("used memory", Utils.getUsedMemoryInMegabytes() + " Mb");

    GraphicsConfiguration configuration = device.getDefaultConfiguration();
    ColorModel defaultColorModel = configuration.getColorModel();

    ColorModelNode colorModelNode = new ColorModelNode("Default Color Model", defaultColorModel);
    add(colorModelNode);
}
 
開發者ID:teddyted,項目名稱:iSeleda,代碼行數:30,代碼來源:SystemNode.java

示例13: checkDisplayMode

import java.awt.DisplayMode; //導入方法依賴的package包/類
static void checkDisplayMode(DisplayMode displayMode) {
    if (displayMode == null || displayMode.getWidth() <= 1 || displayMode.getHeight() <= 1) {
        throw new RuntimeException("invalid display mode");
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:CheckDisplayModes.java

示例14: deriveSize

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveSize(DisplayMode dm) {
    int w = dm.getWidth() / 7;
    int h = dm.getHeight() / 3;
    return new DisplayMode(w, h, dm.getBitDepth(), dm.getRefreshRate());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:6,代碼來源:NonExistentDisplayModeTest.java

示例15: deriveRR

import java.awt.DisplayMode; //導入方法依賴的package包/類
private static DisplayMode deriveRR(DisplayMode dm) {
    return new DisplayMode(dm.getWidth(), dm.getHeight(),
                           dm.getBitDepth(), 777);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:5,代碼來源:NonExistentDisplayModeTest.java


注:本文中的java.awt.DisplayMode.getWidth方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。