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


Java RootPaneContainer.getRootPane方法代码示例

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


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

示例1: uninstallOperation

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * Removes an operation installed in the specified frame for the specified
 * keystroke and condition.
 * 
 * @param frame
 *            The frame from which the keybind is to be uninstalled.
 * @param condition
 *            When should this keybind be activated.
 *            Either {@link JComponent#WHEN_FOCUSED}, {@link JComponent#WHEN_IN_FOCUSED_WINDOW}, or
 *            {@link JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}.
 * @param keyStroke
 *            The keystroke used to activate the keybind
 */
public static void uninstallOperation(
	final RootPaneContainer frame,
	final int condition,
	final KeyStroke keyStroke )
{
	JRootPane root = frame.getRootPane();

	InputMap inputMap = root.getInputMap( condition );
	InputMap parentMap = inputMap.getParent();

	// Temporarily remove the parent input map, so that we don't receive the
	// action key from the parent's input map if the current input map has
	// no action key bound to the key stroke.
	inputMap.setParent( null );

	Object actionKey = root.getInputMap( condition ).get( keyStroke );
	if ( actionKey == null )
		throw new OperationNotInstalledException( keyStroke );
	root.getInputMap( condition ).remove( keyStroke );
	root.getActionMap().remove( actionKey );

	inputMap.setParent( parentMap );
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:37,代码来源:SwingUIUtils.java

示例2: getInstalledOperation

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * Returns the Action installed under the specified action key in the specified frame.
 * 
 * @param frame
 *            The frame in which the action is installed
 * @param actionKey
 *            The action key to which the action is bound
 * @param selfOnly
 *            If true, will only check the frame specified in argument for actions bound
 *            to the action key.
 *            If false, will check any parents of the action map for actions bound to the
 *            action key, if none was found in the first one.
 */
public static Action getInstalledOperation(
	final RootPaneContainer frame,
	final Object actionKey,
	boolean selfOnly )
{
	JRootPane root = frame.getRootPane();

	if ( selfOnly ) {
		ActionMap actionMap = root.getActionMap();
		ActionMap parentMap = actionMap.getParent();

		actionMap.setParent( null );
		Action result = actionMap.get( actionKey );
		actionMap.setParent( parentMap );

		return result;
	}
	else {
		return root.getActionMap().get( actionKey );
	}
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:35,代码来源:SwingUIUtils.java

示例3: setShortcutsActive

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/** Turn on/off special shortcuts. For example: on Mac command+D should navigate to the desktop.
 */
protected void setShortcutsActive(boolean b) {
	Window window = SwingUtilities.getWindowAncestor(locationPane);
	/** T4L Bug 21770 had to do with a normally hidden LocationPaneUI consuming cmd+D
	 * keystrokes. So now we only install these keystrokes if we're visible and
	 * in a dialog...
	 */
	if(window instanceof RootPaneContainer && window instanceof Dialog) {
		RootPaneContainer rpc = (RootPaneContainer)window;
		JRootPane rootPane = rpc.getRootPane();
		if(b) {
			rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(desktopKeystroke, "navigateToDesktop");
			rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(desktopKeystroke, "navigateToDesktop");
			rootPane.getActionMap().put("navigateToDesktop", navigateToDesktop);
		} else {
			rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).remove(desktopKeystroke);
			rootPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(desktopKeystroke);
		}
	}
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:22,代码来源:LocationPaneUI.java

示例4: setKeyCatcher

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * Set up a key-press catcher for the specified component such that when F1
 * is pressed it should help for the component where the cursor is.
 *
 * @param rootpanecontainer
 */
public static void setKeyCatcher(final RootPaneContainer rootpanecontainer) {
	@SuppressWarnings("serial")
	AbstractAction theAction = new AbstractAction() {
		@Override
		public void actionPerformed(ActionEvent evt) {
			Component component = (Component) rootpanecontainer;
			Container container = (Container) rootpanecontainer;
			logger.info("frame action F1 pressed with source "
					+ evt.getSource().getClass().getName());
			Point mousePosition = getPointerInfo().getLocation();
			Point framePosition = component.getLocation();
			Point relativePosition = (Point) mousePosition.clone();
			relativePosition.translate(-framePosition.x, -framePosition.y);
			Component c = container.findComponentAt(relativePosition);
			if (c != null)
				logger.info("F1 pressed in a " + c.getClass().getName());
			showHelpWithinContainer(rootpanecontainer, c);
		}
	};

	JRootPane pane = rootpanecontainer.getRootPane();
	setKeyCatcher(pane, theAction);
}
 
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:30,代码来源:Helper.java

示例5: install

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
public void install(RootPaneContainer rpc) {
	if(getParent()!=rpc.getLayeredPane())
		rpc.getLayeredPane().add( this , JLayeredPane.POPUP_LAYER);
	
	if(rootPaneInUse!=null)
		rootPaneInUse.removeComponentListener(rootPaneComponentListener);
	
	rootPaneInUse = rpc.getRootPane();
	setBounds(0,0,rootPaneInUse.getWidth(),rootPaneInUse.getHeight());
	setVisible(true);
	rootPaneInUse.addComponentListener(rootPaneComponentListener);
}
 
开发者ID:mickleness,项目名称:pumpernickel,代码行数:13,代码来源:BlockingPane.java

示例6: addEscapeKeyListener

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * To a given dialog, adds a key listener that is fired if a key is pressed.
 */
public static void addEscapeKeyListener(
    final RootPaneContainer dialog,
    final Runnable keyDownAction) {
  if (dialog.getRootPane() != null) {
    addKeyListener(dialog.getRootPane(), KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), keyDownAction);
  }
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:11,代码来源:SwingComponents.java

示例7: testUpdateAllComponentTreeUIs

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
@Test
public void testUpdateAllComponentTreeUIs() {
    // This test will not work in a headless configuration.
    if (GraphicsEnvironment.isHeadless()) {
        LOG.fine("cannot run test - headless environment");
        return;
    }
    if (isCrossPlatformLFSameAsSystem()) {
        LOG.info("cannot run test - no safe LFs to toggle");
        return;
    }
    List<RootPaneContainer> toplevels = new ArrayList<RootPaneContainer>();
    for (int i = 0; i < 10; i++) {
        JXFrame frame = new JXFrame();
        toplevels.add(frame);
        toplevels.add(new JDialog(frame));
        toplevels.add(new JWindow(frame));
    }
    // sanity
    if (!UIManager.getLookAndFeel().isNativeLookAndFeel()) {
        LOG.warning("Assumption is to start with native LaF. Found " + UIManager.getLookAndFeel() + " instead.");
    }
    setSystemLF(false);
    SwingXUtilities.updateAllComponentTreeUIs();
    // sanity
    for (RootPaneContainer window : toplevels) {
        JRootPane rootPane = window.getRootPane();
        assertEquals(UIManager.get(rootPane.getUIClassID()),  
                rootPane.getUI().getClass().getName());
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:32,代码来源:SwingXUtilitiesTest.java

示例8: hadBeenPrepared

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * Checks and returns whether the given RootPaneContainer already has 
 * been prepared. As a side-effect, the container is marked as prepared 
 * (wrong place?)
 * 
 * @param c
 * @return
 */
private boolean hadBeenPrepared(RootPaneContainer c) {
    JComponent rootPane = c.getRootPane();
    // These initializations are only done once
    Object k = "SingleFrameApplication.initRootPaneContainer";
    boolean prepared = Boolean.TRUE.equals(rootPane.getClientProperty(k));
    if (!prepared) {
        rootPane.putClientProperty(k, Boolean.TRUE);
    }
    return prepared;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:19,代码来源:SingleXFrameApplication.java

示例9: findWindow

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
private final Window findWindow(@Nullable final RootPaneContainer rootPaneContainer)
{
	final Component comp;
	if (rootPaneContainer == null)
	{
		comp = null;
	}
	else if (rootPaneContainer instanceof Window)
	{
		return (Window)rootPaneContainer;
	}
	else if (rootPaneContainer instanceof Component)
	{
		comp = (Component)rootPaneContainer;
	}
	else
	{
		comp = rootPaneContainer.getRootPane();
	}

	final Window window = AEnv.getParentComponent(comp, Window.class);
	if (window == null)
	{
		final String errmsg = "No " + Window.class + " found."
				+ "Ignore, but please check because this could be a development error."
				+ "\n RootPaneContainer: " + rootPaneContainer
				+ "\n Component: " + comp
				+ "\n Executor: " + this;
		new AdempiereException(errmsg).throwIfDeveloperModeOrLogWarningElse(logger);
	}
	return window;
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:33,代码来源:SwingClientUIInvoker.java

示例10: installOperation

import javax.swing.RootPaneContainer; //导入方法依赖的package包/类
/**
 * Installs a keybind in the specified frame for the specified action.
 * 
 * @param frame
 *            The frame in which this keybind can be activated
 * @param condition
 *            When should this keybind be activated.
 *            Either {@link JComponent#WHEN_FOCUSED}, {@link JComponent#WHEN_IN_FOCUSED_WINDOW}, or
 *            {@link JComponent#WHEN_ANCESTOR_OF_FOCUSED_COMPONENT}.
 * @param keyStroke
 *            The keystroke used to activate the keybind
 * @param actionKey
 *            Identifier of the action
 * @param action
 *            The action to execute when the keybind is activated
 */
public static void installOperation(
	final RootPaneContainer frame,
	final int condition,
	final KeyStroke keyStroke,
	final String actionKey,
	Action action )
{
	JRootPane root = frame.getRootPane();
	root.getInputMap( condition ).put( keyStroke, actionKey );
	root.getActionMap().put( actionKey, action );
}
 
开发者ID:kartoFlane,项目名称:hiervis,代码行数:28,代码来源:SwingUIUtils.java


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