本文整理匯總了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;
}
示例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);
}
示例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();
}
}
}
示例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();
}
示例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;
}
示例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);
}
}
示例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 );
}
}
}
}
示例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();
}
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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;
}
示例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 );
}
}
}
}
示例14: exit
import javax.swing.SwingUtilities; //導入方法依賴的package包/類
/**
*
*/
public void exit() {
JFrame frame = (JFrame) SwingUtilities.windowForComponent(this);
if (frame != null) {
frame.dispose();
}
}
示例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);
}