当前位置: 首页>>代码示例>>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;未经允许,请勿转载。