当前位置: 首页>>代码示例>>Java>>正文


Java Window.getGraphicsConfiguration方法代码示例

本文整理汇总了Java中java.awt.Window.getGraphicsConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Window.getGraphicsConfiguration方法的具体用法?Java Window.getGraphicsConfiguration怎么用?Java Window.getGraphicsConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.Window的用法示例。


在下文中一共展示了Window.getGraphicsConfiguration方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrentGraphicsConfiguration

import java.awt.Window; //导入方法依赖的package包/类
/**
    * Finds out the monitor where the user currently has the input focus.
    * This method is usually used to help the client code to figure out on
    * which monitor it should place newly created windows/frames/dialogs.
    *
    * @return the GraphicsConfiguration of the monitor which currently has the
    * input focus
    */
   private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
       if (focusOwner != null) {
           Window w = SwingUtilities.getWindowAncestor(focusOwner);
           if (w != null) {
               return w.getGraphicsConfiguration();
           } else {
               //#217737 - try to find the main window which could be placed in secondary screen
               for( Frame f : Frame.getFrames() ) {
                   if( "NbMainWindow".equals(f.getName())) { //NOI18N
                       return f.getGraphicsConfiguration();
                   }
               }
           }
       }

       return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Utilities.java

示例2: centreOnScreen

import java.awt.Window; //导入方法依赖的package包/类
public static void centreOnScreen(Window window)
{
	Window owner = window.getOwner();

	// If the window has an owner, use the same graphics configuration so it
	// will
	// open on the same screen. Otherwise, grab the mouse pointer and work
	// from there.
	GraphicsConfiguration gc = owner != null ? owner.getGraphicsConfiguration() : MouseInfo.getPointerInfo()
		.getDevice().getDefaultConfiguration();

	if( gc != null )
	{
		window.setBounds(centre(getUsableScreenBounds(gc), window.getBounds()));
	}
	else
	{
		// Fall-back to letting Java do the work
		window.setLocationRelativeTo(null);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:22,代码来源:ComponentHelper.java

示例3: getCurrentGraphicsConfiguration

import java.awt.Window; //导入方法依赖的package包/类
private static GraphicsConfiguration getCurrentGraphicsConfiguration() {
Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
       if (focusOwner != null) {
           Window w = SwingUtilities.getWindowAncestor(focusOwner);
           if (w != null) {
               return w.getGraphicsConfiguration();
           }
       }

       return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ColumnSelectionPanel.java

示例4: setWindowAlpha

import java.awt.Window; //导入方法依赖的package包/类
@Override
public void setWindowAlpha(Window w, float alpha) {
    GraphicsConfiguration gc = w.getGraphicsConfiguration();
    GraphicsDevice gd = gc.getDevice();
    if (gc.getDevice().getFullScreenWindow() == w) {
        return;
    }
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        return;
    }
    w.setOpacity(alpha);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:NoNativeAccessWindowSystem.java

示例5: setWindowMask

import java.awt.Window; //导入方法依赖的package包/类
@Override
public void setWindowMask(Window w, Shape mask) {
    GraphicsConfiguration gc = w.getGraphicsConfiguration();
    GraphicsDevice gd = gc.getDevice();
    if (gc.getDevice().getFullScreenWindow() == w) {
        return;
    }
    if (!gd.isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency.TRANSLUCENT)) {
        return;
    }
    w.setShape(mask);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:NoNativeAccessWindowSystem.java

示例6: test

import java.awt.Window; //导入方法依赖的package包/类
private static void test(final Window window) throws Exception {
    final long start = System.nanoTime();
    final long end = start + NANOSECONDS.convert(1, MINUTES);

    final Runnable r1 = () -> {
        while (System.nanoTime() < end) {
            window.setBounds(window.getBounds());
        }
    };
    final Runnable r2 = () -> {
        while (System.nanoTime() < end) {
            window.getGraphicsConfiguration();
            window.getOpacity();
        }
    };

    final Thread t1 = new Thread(r1);
    final Thread t2 = new Thread(r1);
    final Thread t3 = new Thread(r2);
    final Thread t4 = new Thread(r2);

    t1.start();
    t2.start();
    t3.start();
    t4.start();
    t1.join();
    t2.join();
    t3.join();
    t4.join();
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:31,代码来源:TreeLockDeadlock.java

示例7: ButtonDialog

import java.awt.Window; //导入方法依赖的package包/类
/**
 * Constructor used by the {@link ButtonDialogBuilder} and can also be used when subclassing.
 *
 * @param owner
 *            the owner or {@code null}. Note that an owner should be set if the dialog will be
 *            modal, otherwise the order ends up being undefined and causing all sorts of
 *            trouble
 * @param key
 *            the i18n key
 * @param modalityType
 *            the modality type
 * @param arguments
 *            the optional i18n arguments
 * @since 6.5.0
 */
protected ButtonDialog(Window owner, String key, ModalityType modalityType, Object... arguments) {
	this(owner, key, modalityType, owner != null ? owner.getGraphicsConfiguration() : null, arguments);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:19,代码来源:ButtonDialog.java


注:本文中的java.awt.Window.getGraphicsConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。