當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。