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


Java SwingUtilities.windowForComponent方法代码示例

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


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

示例1: postProcessKeyEvent

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
    if (ev.isConsumed())
        return false;

    if (processShortcut(ev))
        return true;

    Window w = SwingUtilities.windowForComponent(ev.getComponent());        
    if (w instanceof Dialog && !WindowManagerImpl.isSeparateWindow(w))
        return false;
    
    JFrame mw = (JFrame)WindowManagerImpl.getInstance().getMainWindow();
    if (w == mw) {
        return false;
    }

    JMenuBar mb = mw.getJMenuBar();
    if (mb == null)
        return false;
    boolean pressed = (ev.getID() == KeyEvent.KEY_PRESSED);        
    boolean res = invokeProcessKeyBindingsForAllComponents(ev, mw, pressed);
    
    if (res)
        ev.consume();
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ShortcutAndMenuKeyEventProcessor.java

示例2: show

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:TooltipWindow.java

示例3: setLookAndFeel

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void setLookAndFeel(String clazz) {
  JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);

  if (frame != null) {
    try {
      UIManager.setLookAndFeel(clazz);
      SwingUtilities.updateComponentTreeUI(frame);

      // Needs to assign the key bindings again
      keyboardHandler = new EditorKeyboardHandler(graphComponent);
    } catch (Exception e1) {
      e1.printStackTrace();
    }
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:19,代码来源:BasicGraphEditor.java

示例4: appear

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void appear() {
	final JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
	final long startTime = System.currentTimeMillis();
	appearTimer = new javax.swing.Timer(APPEAR_STEP, new ActionListener() {
		/** {@inheritDoc} */
		@Override
		public void actionPerformed(ActionEvent e) {
			// calculate elapsed time
			final long elapsed = System.currentTimeMillis() - startTime;
			final float alpha = Math.min(1f, 1.0f * elapsed / APPEAR_DURATION);
			setWindowOpacity(frame, alpha);
			if (elapsed >= APPEAR_DURATION) { // should we stop timer?
				appearTimer.stop();
			}
		}
	});

	appearTimer.start();
}
 
开发者ID:evernat,项目名称:dead-code-detector,代码行数:20,代码来源:DeadCodeDetectorUI.java

示例5: createDragWindow

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private Window createDragWindow( Image dragImage, Rectangle bounds ) {
    Window w = new Window( SwingUtilities.windowForComponent(sourceRow) );
    w.add(new JLabel(new ImageIcon(dragImage)));
    w.setBounds(bounds);
    w.setVisible(true);
    NativeWindowSystem nws = NativeWindowSystem.getDefault();
    if( nws.isUndecoratedWindowAlphaSupported() ) {
        nws.setWindowAlpha(w, 0.7f);
    }
    return w;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DnDSupport.java

示例6: updateTitle

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void updateTitle()
{
	JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);

	if (frame != null)
	{
		String title = (currentFile != null) ? currentFile
				.getAbsolutePath() : mxResources.get("newDiagram");

		if (modified)
		{
			title += "*";
		}

		frame.setTitle(title + " - " + appTitle);
	}
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:21,代码来源:BasicGraphEditor.java

示例7: makeFloatingWindowsTransparent

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void makeFloatingWindowsTransparent( ModeImpl activeMode ) {
    float alpha = WinSysPrefs.HANDLER.getFloat(WinSysPrefs.TRANSPARENCY_FLOATING_ALPHA, 0.5f);
    NativeWindowSystem nws = NativeWindowSystem.getDefault();
    for( ModeImpl m : WindowManagerImpl.getInstance().getModes() ) {
        if( m.getState() != Constants.MODE_STATE_SEPARATED 
                || m.equals( activeMode )
                || m.getKind() == Constants.MODE_KIND_EDITOR )
            continue;
        TopComponent tc = m.getSelectedTopComponent();
        if( null != tc ) {
            Window w = SwingUtilities.windowForComponent(tc);
            if( null != w ) {
                nws.setWindowAlpha( w, alpha );
            }
        }
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FloatingWindowTransparencyManager.java

示例8: eventDispatched

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Receives all key events in the AWT and processes the ones that originated
 * from the current window with the glass pane.
 * 
 * @param event the AWTEvent that was fired
 */
@Override
public void eventDispatched(AWTEvent event)
{
	Object source = event.getSource();

	// discard the event if its source is not from the correct type
	boolean sourceIsComponent = (event.getSource() instanceof Component);

	if( (event instanceof KeyEvent) && sourceIsComponent )
	{
		// If the event originated from the window w/glass pane, consume the
		// event
		if( (SwingUtilities.windowForComponent((Component) source) == theWindow) )
		{
			((KeyEvent) event).consume();
		}
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:25,代码来源:BusyGlassPane.java

示例9: setLinkedEmitter

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * Set the emitter that is being controlled
 *  
 * @param emitter The emitter that is configured by this panel
 */
public void setLinkedEmitter(ConfigurableEmitter emitter) {
	// set the title
	Window w = SwingUtilities.windowForComponent(this);
	if (w instanceof Frame)
		((Frame) w).setTitle("Whiskas Gradient Editor (" + emitter.name
				+ ")");

	// clear all values
	properties.removeAllItems();
	values.clear();
	panel.setInterpolator(null);
	enableControls();
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:19,代码来源:GraphEditorWindow.java

示例10: show

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel();
    Window w = SwingUtilities.windowForComponent(parent);
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
        // the whole window does fully not fit to the right
        // the x position where the window has to start to fully fit to the right
        int left = screenBounds.width + screenBounds.x - cp.longestLine;
        // the window should have x pos minimally at the screen's start
        location.x = Math.max(screenBounds.x, left);
    }
    
    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y + 1);  // slight visual adjustment
    
    contentWindow.setVisible(true);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            cp.scrollRectToVisible(new Rectangle(1, 1));
        }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
    contentWindow.addKeyListener(this);
    w.addKeyListener(this);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:53,代码来源:MsgTooltipWindow.java

示例11: updateTitle

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void updateTitle() {
  JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);

  if (frame != null) {
    String title =
        (currentFile != null) ? currentFile.getAbsolutePath() : mxResources.get("newDiagram");

    if (modified) {
      title += "*";
    }

    frame.setTitle(title + " - " + appTitle);
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:18,代码来源:BasicGraphEditor.java

示例12: processShortcut

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private boolean processShortcut(KeyEvent ev) {
    //ignore shortcut keys when the IDE is shutting down
    if (NbLifecycleManager.isExiting()) {
        ev.consume();
        return true;
    }
    
    KeyStroke ks = KeyStroke.getKeyStrokeForEvent(ev);
    Window w = SwingUtilities.windowForComponent(ev.getComponent());

    // don't process shortcuts if this is a help frame
    if ((w instanceof JFrame) && ((JFrame)w).getRootPane().getClientProperty("netbeans.helpframe") != null) // NOI18N
        return true;
    
    // don't let action keystrokes to propagate from both
    // modal and nonmodal dialogs, but propagate from separate floating windows,
    // even if they are backed by JDialog
    if ((w instanceof Dialog) &&
        !WindowManagerImpl.isSeparateWindow(w) &&
        !isTransmodalAction(ks)) {
        return false;
    }
    
    // Provide a reasonably useful action event that identifies what was focused
    // when the key was pressed, as well as what keystroke ran the action.
    ActionEvent aev = new ActionEvent(
        ev.getSource(), ActionEvent.ACTION_PERFORMED, Utilities.keyToString(ks));
        
    Keymap root = Lookup.getDefault().lookup(Keymap.class);
    Action a = root.getAction (ks);
    if (a != null && a.isEnabled()) {
        ActionManager am = Lookup.getDefault().lookup(ActionManager.class);
        am.invokeAction(a, aev);
        ev.consume();
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ShortcutAndMenuKeyEventProcessor.java

示例13: turnTransparencyOff

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void turnTransparencyOff() {
    NativeWindowSystem nws = NativeWindowSystem.getDefault();
    for( ModeImpl m : WindowManagerImpl.getInstance().getModes() ) {
        if( m.getState() != Constants.MODE_STATE_SEPARATED
                || m.getKind() == Constants.MODE_KIND_EDITOR )
            continue;
        TopComponent tc = m.getSelectedTopComponent();
        if( null != tc ) {
            Window w = SwingUtilities.windowForComponent(tc);
            if( null != w ) {
                nws.setWindowAlpha( w, 1.0f );
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:FloatingWindowTransparencyManager.java

示例14: exit

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
 * 
 */
public void exit() {
  JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);

  if (frame != null) {
    frame.dispose();
  }
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:11,代码来源:BasicGraphEditor.java

示例15: willPopupBeContained

import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static boolean willPopupBeContained(JPopupMenu popup, Point origin) {
    if (!popup.isShowing()) {
        return false;
    }

    Window w = SwingUtilities.windowForComponent(popup.getInvoker());
    Rectangle r = new Rectangle(origin, popup.getSize());

    return (w != null) && w.getBounds().contains(r);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:JPopupMenuUtils.java


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