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