本文整理汇总了Java中javax.swing.RootPaneContainer类的典型用法代码示例。如果您正苦于以下问题:Java RootPaneContainer类的具体用法?Java RootPaneContainer怎么用?Java RootPaneContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RootPaneContainer类属于javax.swing包,在下文中一共展示了RootPaneContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: detachWindow
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/** Stops to track given window (RootPaneContainer).
*/
public boolean detachWindow (RootPaneContainer rpc) {
logger.entering(getClass().getName(), "detachWindow");
if (!(rpc instanceof Window)) {
throw new IllegalArgumentException("Argument must be subclas of java.awt.Window: " + rpc); //NOI18N
}
WeakReference<RootPaneContainer> ww = getWeak(rpc);
if (ww == null) {
return false;
}
((Window)rpc).removeWindowListener(this);
return zOrder.remove(ww);
}
示例2: findDefaultButton
import javax.swing.RootPaneContainer; //导入依赖的package包/类
private static AbstractButton findDefaultButton(Container c, String txt) {
if (c instanceof RootPaneContainer) {
JRootPane root = ((RootPaneContainer) c).getRootPane();
if (root == null) {
return null;
}
AbstractButton btn = root.getDefaultButton();
if (btn == null) {
//Metal L&F does not set default button for JFileChooser
Container parent = c;
while (parent.getParent() != null && !(parent instanceof Dialog)) {
parent = parent.getParent();
}
if (parent instanceof Dialog) {
return findFileChooserAcceptButton ((Dialog) parent, txt);
}
} else {
return btn;
}
}
return null;
}
示例3: showSpyDialog
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/**
* Shows spy dialog or reload existing one.
*
* @param rootComponent root component
* @param component current component
*/
public void showSpyDialog(final Component rootComponent, final Component component) {
if (spyDialog != null) {
spyDialog.setVisible(true);
spyGlass.setVisible(true);
spyPanel.reload(rootComponent, component);
return;
}
if (rootComponent instanceof RootPaneContainer) {
RootPaneContainer rootPane = (RootPaneContainer) rootComponent;
spyGlass = new SwingSpyGlassPane(rootPane);
rootPane.setGlassPane(spyGlass);
rootPane.getGlassPane().setVisible(true);
Toolkit.getDefaultToolkit().addAWTEventListener(spyGlass, AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK);
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
initSpyDialog(rootComponent, component);
}
});
}
示例4: getRootContainer
import javax.swing.RootPaneContainer; //导入依赖的package包/类
private static RootPaneContainer getRootContainer(Component startComponent)
{
Component aComponent = startComponent;
// Climb the component hierarchy until a RootPaneContainer is found or
// until the very top
while( (aComponent.getParent() != null) && !(aComponent instanceof RootPaneContainer) )
{
aComponent = aComponent.getParent();
}
// Guard against error conditions if climb search wasn't successful
if( aComponent instanceof RootPaneContainer )
{
return (RootPaneContainer) aComponent;
}
return null;
}
示例5: installOperation
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/**
* {@linkplain #installOperation(RootPaneContainer, int, KeyStroke, String, Action)}
*/
public static Action installOperation(
final RootPaneContainer frame,
final int condition,
final KeyStroke keyStroke,
final String actionKey,
final Runnable runnable )
{
Action result = new AbstractAction( actionKey ) {
public void actionPerformed( ActionEvent e )
{
runnable.run();
}
};
installOperation( frame, condition, keyStroke, actionKey, result );
return result;
}
示例6: 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 );
}
示例7: 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 );
}
}
示例8: DesignGridLayout
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/**
* Builds a DesignGridLayout instance attached to a {@link Container}.
* This instance should be then used to add rows and components to the parent
* container.
* <p/>
* Note that this constructor auomatically calls {@code parent.setLayout(this)}
* so you don't need to call it yourself.
* <p/>
* In no way should the {@link Container#add} and {@link Container#remove}
* ever be used with {@code parent}.
*
* @param parent the container for which we want to use DesignGridLayout;
* cannot be {@code null}.
*/
public DesignGridLayout(Container parent)
{
if (parent == null)
{
throw new NullPointerException("parent cannot be null");
}
Container target = parent;
if (parent instanceof RootPaneContainer)
{
target = ((RootPaneContainer) parent).getContentPane();
}
_wrapper = new ParentWrapper<Container>(target);
_orientation = new OrientationPolicy(target);
_layout = new DesignGridLayoutManager(this, _wrapper, _rows, _orientation);
_layout.setHeightTester(_heightTester);
target.setLayout(_layout);
}
示例9: 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);
}
}
}
示例10: isDarkBackground
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/** Are we painting against a dark background?
* This checks the JVM version, the os, and whether the window's ultimate parent
* uses Apple's brush-metal-look.
*/
protected static boolean isDarkBackground(Window w) {
if(!isMac)
return false;
if(JVM.getMajorJavaVersion()<1.5)
return false;
while(w!=null) {
if(w instanceof RootPaneContainer) {
JRootPane rootPane = ((RootPaneContainer)w).getRootPane();
Object obj = rootPane.getClientProperty("apple.awt.brushMetalLook");
if(obj==null) obj = Boolean.FALSE;
if(obj.toString().equals("true")) {
return true;
}
}
w = w.getOwner();
}
return false;
}
示例11: getOrNull
import javax.swing.RootPaneContainer; //导入依赖的package包/类
public static final MetasfreshGlassPane getOrNull(final RootPaneContainer rootPaneContainer)
{
if (rootPaneContainer == null)
{
return null;
}
final Component glassPaneComp = rootPaneContainer.getGlassPane();
if (glassPaneComp instanceof MetasfreshGlassPane)
{
return (MetasfreshGlassPane)glassPaneComp;
}
else
{
return null;
}
}
示例12: setRootPaneContainer
import javax.swing.RootPaneContainer; //导入依赖的package包/类
private void setRootPaneContainer(JButton button,RootPaneContainer c) {
RootPaneContainer lastContainer = (RootPaneContainer)button.getClientProperty("bric.footer.rpc");
if(lastContainer==c) return;
if(lastContainer!=null) {
lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(escapeKey);
lastContainer.getRootPane().getActionMap().remove(escapeKey);
if(JVM.isMac)
lastContainer.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).remove(commandPeriodKey);
}
if(c!=null) {
c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(escapeKey, escapeKey);
c.getRootPane().getActionMap().put(escapeKey, new ClickAction(button));
if(JVM.isMac)
c.getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(commandPeriodKey, escapeKey);
}
button.putClientProperty("bric.footer.rpc", c);
}
示例13: MWaitCursor
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/**
* Constructeur : crée le WaitCursor et affiche le sablier.
* @param comp Component
*/
public MWaitCursor(Component comp) {
// Curseur de la frame contenant le component
window = SwingUtilities.windowForComponent(comp);
windowGlassPaneVisible = window instanceof RootPaneContainer
&& ((RootPaneContainer) window).getGlassPane().isVisible();
oldWindowCursor = window != null ? window.getCursor() : null;
// On ne change pas le curseur du component car cela poserait problème en cas d'imbrication
// pour le remettre à sa valeur initiale (Component.getCursor renvoyant le cursor de son parent si non défini)
// On active le curseur d'attente
// (l'utilisation du glassPane rend le curseur visible lors d'un double-clique sur une ligne par ex.
// et l'utilisation de curseur de la window rend celui-ci visible même si on sort de la fenêtre pour revenir)
if (window instanceof RootPaneContainer) {
final Component glassPane = ((RootPaneContainer) window).getGlassPane();
glassPane.setVisible(true);
glassPane.setCursor(WAIT_CURSOR);
}
if (window != null) {
window.setCursor(WAIT_CURSOR);
}
}
示例14: isInState
import javax.swing.RootPaneContainer; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public boolean isInState(JComponent c) {
Component parent = c;
while (parent.getParent() != null) {
if (parent instanceof RootPaneContainer) {
break;
}
parent = parent.getParent();
}
if (parent instanceof JFrame) {
return (((JFrame) parent).getExtendedState() & Frame.MAXIMIZED_BOTH) != 0;
} else if (parent instanceof JInternalFrame) {
return ((JInternalFrame) parent).isMaximum();
}
return false;
}
示例15: 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);
}