本文整理汇总了Java中javax.swing.SwingUtilities.getRootPane方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.getRootPane方法的具体用法?Java SwingUtilities.getRootPane怎么用?Java SwingUtilities.getRootPane使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.getRootPane方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyPressed
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent ev) {
if (ev.getKeyCode() != KeyEvent.VK_ENTER || "".equals(getText()))
return;
JRootPane root = SwingUtilities.getRootPane(getParent());
if (root != null)
root.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
// Create regex pattern
pat = Pattern.compile(getText(), Pattern.CASE_INSENSITIVE);
search(pat);
} catch (PatternSyntaxException ex) {
System.err.println(ex.getMessage());
}
if (root != null)
root.setCursor(null); // turn off wait cursor
// // Check if there was a recent update to reduce event load!
// if (!isRunning) {
// isRunning = true;
// javax.swing.SwingUtilities.invokeLater(new Runnable() {
// public void run() {
}
示例2: resetState
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void resetState() {
state = STATE_NOOP;
JRootPane pane = SwingUtilities.getRootPane(comp);
glass.setVisible(false);
if (pane != null && oldGlass != null) {
// when clicking results in hidden slide window, pne can be null?
// how to avoid?
JComponent current = (JComponent) pane.getGlassPane();
if (current instanceof GlassPane) {
pane.setGlassPane(oldGlass);
}
}
if( null != comp )
comp.setCursor(null);
oldGlass = null;
startPoint = null;
}
示例3: postProcessKeyEvent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
// mnemonic combination, it's consumed, but we need
// set altKeyPressed to false, otherwise after selection
// component by mnemonic combination a menu will be open
altKeyPressed = false;
return false;
}
if (ev.getKeyCode() == KeyEvent.VK_ALT) {
root = SwingUtilities.getRootPane(ev.getComponent());
winAncestor = (root == null ? null :
SwingUtilities.getWindowAncestor(root));
if (ev.getID() == KeyEvent.KEY_PRESSED) {
if (!altKeyPressed) {
altPressed(ev);
}
altKeyPressed = true;
return true;
} else if (ev.getID() == KeyEvent.KEY_RELEASED) {
if (altKeyPressed) {
altReleased(ev);
} else {
MenuSelectionManager msm =
MenuSelectionManager.defaultManager();
MenuElement[] path = msm.getSelectedPath();
if (path.length <= 0) {
WindowsLookAndFeel.setMnemonicHidden(true);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
}
altKeyPressed = false;
}
root = null;
winAncestor = null;
} else {
altKeyPressed = false;
}
return false;
}
示例4: dispatchKeyEvent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean dispatchKeyEvent(KeyEvent e) {
if (skippingEvents || e.isConsumed()) return false;
if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_ESCAPE)
if (SwingUtilities.getRootPane(this) != e.getSource()) { // Closing JPopupMenu using the ESC key
e.consume();
if (DEBUG) System.err.println(">>> Closed by ESC"); // NOI18N
ProfilerPopup.this.hide();
return true;
}
return false;
}
示例5: setDragCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
protected void setDragCursor() {
JRootPane rootWin = SwingUtilities.getRootPane(this);
if (rootWin != null) {
// remove cursor from old window
if (dragCursor.getParent() != null) {
dragCursor.getParent().remove(dragCursor);
}
drawWin = rootWin.getLayeredPane();
calcDrawOffset();
dragCursor.setVisible(true);
drawWin.add(dragCursor, JLayeredPane.DRAG_LAYER);
}
}
示例6: setDragCursor
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
protected void setDragCursor() {
final JRootPane rootWin = SwingUtilities.getRootPane(this);
if (rootWin != null) {
// remove cursor from old window
if (dragCursor.getParent() != null) {
dragCursor.getParent().remove(dragCursor);
}
drawWin = rootWin.getLayeredPane();
dragCursor.setVisible(true);
drawWin.add(dragCursor, JLayeredPane.DRAG_LAYER);
}
}
示例7: setDrawWinToOwnerOf
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* creates or moves cursor object to given window. Called when drag operation begins in a window or the cursor is
* dragged over a new drop-target window
*/
public void setDrawWinToOwnerOf(Component newDropWin) {
if (newDropWin != null) {
final JRootPane rootWin = SwingUtilities.getRootPane(newDropWin);
if (rootWin != null) {
setDrawWin(rootWin.getLayeredPane());
}
}
}
示例8: selectInitialValue
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void selectInitialValue(JOptionPane op) {
if (initialFocusComponent != null) {
initialFocusComponent.requestFocus();
if (initialFocusComponent instanceof JButton) {
JRootPane root = SwingUtilities.getRootPane(initialFocusComponent);
if (root != null) {
root.setDefaultButton((JButton)initialFocusComponent);
}
}
}
}
示例9: postProcessKeyEvent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
if(ev.isConsumed()) {
// do not manage consumed event
return false;
}
if (ev.getKeyCode() == KeyEvent.VK_ALT) {
root = SwingUtilities.getRootPane(ev.getComponent());
winAncestor = (root == null ? null :
SwingUtilities.getWindowAncestor(root));
if (ev.getID() == KeyEvent.KEY_PRESSED) {
if (!altKeyPressed) {
altPressed(ev);
}
altKeyPressed = true;
return true;
} else if (ev.getID() == KeyEvent.KEY_RELEASED) {
if (altKeyPressed) {
altReleased(ev);
} else {
MenuSelectionManager msm =
MenuSelectionManager.defaultManager();
MenuElement[] path = msm.getSelectedPath();
if (path.length <= 0) {
WindowsLookAndFeel.setMnemonicHidden(true);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
}
altKeyPressed = false;
}
root = null;
winAncestor = null;
} else {
altKeyPressed = false;
}
return false;
}
示例10: postProcessKeyEvent
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public boolean postProcessKeyEvent(KeyEvent ev) {
if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
// mnemonic combination, it's consumed, but we need
// set altKeyPressed to false, otherwise after selection
// component by mnemonic combination a menu will be open
altKeyPressed = false;
return false;
}
if (ev.getKeyCode() == KeyEvent.VK_ALT) {
root = SwingUtilities.getRootPane(ev.getComponent());
winAncestor = (root == null ? null :
SwingUtilities.getWindowAncestor(root));
if (ev.getID() == KeyEvent.KEY_PRESSED) {
if (!altKeyPressed) {
altPressed(ev);
}
altKeyPressed = true;
return true;
} else if (ev.getID() == KeyEvent.KEY_RELEASED) {
if (altKeyPressed) {
altReleased(ev);
} else {
MenuSelectionManager msm =
MenuSelectionManager.defaultManager();
MenuElement[] path = msm.getSelectedPath();
if (path.length <= 0) {
WindowsLookAndFeel.setMnemonicHidden(true);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
}
altKeyPressed = false;
}
root = null;
winAncestor = null;
} else {
if (WindowsLookAndFeel.isMnemonicHidden() && ev.isAltDown()) {
WindowsLookAndFeel.setMnemonicHidden(false);
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
}
altKeyPressed = false;
}
return false;
}