java.awt.Window#addWindowListener ( )源码实例Demo

下面列出了java.awt.Window#addWindowListener ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: dragonwell8_jdk   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码2 项目: TencentKona-8   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码3 项目: raccoon4   文件: WindowToggleAction.java
/**
 * Hide the window
 */
public void hideWindow() {
	Window frame = lifecycleManager.getWindow(id);
	if (!connected) {
		frame.addWindowListener(this);
		connected = true;
		// Catch up, just in case someone ignored the warning and made another
		// toggle for the window.
		putValue(SELECTED_KEY, false);
	}
	frame.setVisible(false);
}
 
源代码4 项目: openjdk-jdk8u   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码5 项目: netbeans   文件: TableCustomizer.java
@Override
public void addNotify() {
    super.addNotify();
    Window window = SwingUtilities.getWindowAncestor(this);
    if (window != null) {
        window.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosed(WindowEvent e) {
                updateFromUI();
            }
        });
    }
}
 
源代码6 项目: netbeans   文件: PluginManagerUI.java
@Override
public void addNotify () {
    super.addNotify ();
    //show progress for initialize method
    final Window w = findWindowParent ();
    if (w != null) {
        w.addWindowListener (new WindowAdapter (){
            @Override
            public void windowOpened (WindowEvent e) {
                final WindowAdapter waa = this;
                setWaitingState (true);
                Utilities.startAsWorkerThread (PluginManagerUI.this,
                        new Runnable () {
                            @Override
                            public void run () {
                                try {
                                    initTask.waitFinished ();
                                    w.removeWindowListener (waa);
                                } finally {
                                    setWaitingState (false);
                                }
                            }
                        },
                        NbBundle.getMessage (PluginManagerUI.class, "UnitTab_InitAndCheckingForUpdates"),
                        Utilities.getTimeOfInitialization ());
            }
        });
    }
    HelpCtx.setHelpIDString (this, PluginManagerUI.class.getName ());
    tpTabs.addChangeListener (new ChangeListener () {
        @Override
        public void stateChanged (ChangeEvent evt) {
            HelpCtx.setHelpIDString (PluginManagerUI.this, getHelpCtx ().getHelpID ());
        }
    });
}
 
源代码7 项目: netbeans   文件: WindowTable.java
public synchronized void putTaskWindow(Window win, TaskThreadGroup grp) {
    ArrayList<Window> vec;
    if ((vec = windowMap.get(grp)) == null) {
        vec = new ArrayList<Window>();
        windowMap.put(grp, vec);
    }
    vec.add(win);
    win.addWindowListener(winListener);
    super.put(win, grp);
}
 
源代码8 项目: netbeans   文件: BufferedCanvasComponent.java
public void hierarchyChanged(HierarchyEvent e) {
    if ((e.getChangeFlags() & HierarchyEvent.PARENT_CHANGED) != 0) {
        Window parentWindow = SwingUtilities.getWindowAncestor(BufferedCanvasComponent.this);
        if (lastParentWindow != parentWindow) {
            if (lastParentWindow != null) lastParentWindow.removeWindowListener(VisibilityHandler.this);
            if (parentWindow != null) parentWindow.addWindowListener(VisibilityHandler.this);
            lastParentWindow = parentWindow;
        }
    }
    
    if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
        if (isShowing()) BufferedCanvasComponent.this.shown();
        else BufferedCanvasComponent.this.hidden();
    }
}
 
源代码9 项目: raccoon4   文件: WindowToggleAction.java
/**
 * Toggle window visibility.
 */
public void toggleWindow() {
	Window frame = lifecycleManager.getWindow(id);
	if (!connected) {
		frame.addWindowListener(this);
		connected = true;
		// Catch up, just in case someone ignored the warning and made another
		// toggle for the window.
		putValue(SELECTED_KEY, frame.isVisible());
	}
	frame.setVisible(!frame.isVisible());
}
 
源代码10 项目: triplea   文件: SwingComponents.java
/**
 * Executes the specified action when the specified window has been closed.
 *
 * @param window The window to which the action is attached.
 * @param action The action to execute.
 */
public static void addWindowClosedListener(final Window window, final Runnable action) {
  checkNotNull(window);
  checkNotNull(action);

  window.addWindowListener(
      new WindowAdapter() {
        @Override
        public void windowClosed(final WindowEvent e) {
          action.run();
        }
      });
}
 
源代码11 项目: wpcleaner   文件: Configuration.java
/**
 * Move/Resize a window at the preferred position and size.
 * 
 * @param window The window.
 */
public void restoreWindowPosition(Window window) {
  if (window == null) {
    return;
  }
  window.addWindowListener(this);
  if (getBoolean(null, ConfigurationValueBoolean.RESTORE_WINDOW) &&
      (getPreferences() != null)) {
    try {
      if (!getPreferences().nodeExists(PROPERTY_WINDOW)) {
        return;
      }
      Preferences node = getPreferences().node(PROPERTY_WINDOW);
      if (!node.nodeExists(window.getName())) {
        return;
      }
      node = node.node(window.getName());
      window.setLocation(
          node.getInt(PROPERTY_WINDOW_X, 0),
          node.getInt(PROPERTY_WINDOW_Y, 0));
      boolean restoreSize = true;
      if (window instanceof Versionned) {
        Integer version = ((Versionned) window).getVersion();
        if (version != null) {
          int storedVersion = node.getInt(PROPERTY_WINDOW_VERSION, 1);
          if (version.intValue() > storedVersion) {
            restoreSize = false;
          }
        }
      }
      if (restoreSize) {
        window.setSize(
            node.getInt(PROPERTY_WINDOW_W, 1000),
            node.getInt(PROPERTY_WINDOW_H, 700));
      }
    } catch (BackingStoreException e) {
      //
    }
  }
}
 
源代码12 项目: jdk8u-jdk   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码13 项目: jdal   文件: PageableTable.java
/**
 * @param toEdit model to edit
 * @return model editor.
 */
public Window getEditor(Object toEdit) {
	Window dlg = openDialogs.get(toEdit);
	if (dlg == null) {
		dlg = getEditor();
		
		if (dlg == null)
			return null;
			
		openDialogs.put(toEdit, dlg);
		((View<Object>) dlg).setModel(toEdit);
		((View<Object>) dlg).refresh();
		dlg.addWindowListener(new DialogWindowListener());
		if (dlg instanceof Editor) {
			Editor<T> editor = (Editor<T>) dlg;
			editor.addEditorListener(new EditorListener() {
				
				public void modelChanged(EditorEvent e) {
					refresh();
				}
			});
		}
	}
	((View<T>) dlg).refresh();
	
	return dlg;
}
 
源代码14 项目: openjdk-8-source   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码15 项目: RipplePower   文件: SwingUtils.java
public static void packLater(final Window win, final Component parent) {
	win.pack();
	win.setLocationRelativeTo(parent);
	win.addWindowListener(new WindowAdapter() {
		@Override
		public void windowOpened(WindowEvent e) {
			win.pack();
			win.setLocationRelativeTo(parent);
		}
	});
}
 
源代码16 项目: openjdk-8   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码17 项目: jdk8u_jdk   文件: InputContext.java
private synchronized void addClientWindowListeners() {
    Component client = getClientComponent();
    if (client == null) {
        return;
    }
    Window window = getComponentWindow(client);
    if (window == null) {
        return;
    }
    window.addComponentListener(this);
    window.addWindowListener(this);
    clientWindowListened = window;
}
 
源代码18 项目: rapidminer-studio   文件: WindowChoreographer.java
/**
 * Adds a Window into the next free position
 *
 * @param window
 *            The window
 * @return true if the Window could be displayed immediately
 */
public synchronized boolean addWindow(Window window) {
	if (window == null) {
		throw new IllegalArgumentException("window must not be null!");
	}
	// Don't trigger in iconified mode
	if (RapidMinerGUI.getMainFrame().getExtendedState() == Frame.ICONIFIED) {
		bubbleStack.add(window);
		return false;
	}

	int pos = getNextPosition(window);
	int yOffset = windowYOffset.get(pos - 1);
	if (!fitsScreen(window, yOffset)) {
		// Lets store the bubble for later
		bubbleStack.add(window);
		return false;
	}
	// Allow a window only one time
	if (windowPosition.containsKey(window)) {
		return false;
	}
	// Remember the position of the window
	windowPosition.put(window, pos);
	// Great job Java there are two remove methods
	freeSpaces.remove(pos);

	// Remember size if it's a new window
	if (pos >= windowYOffset.size()) {
		this.windowYOffset.set(pos, yOffset + window.getHeight() + DEFAULT_BOTTOM_MARGIN);
	}
	window.addWindowListener(closeListener);
	window.setVisible(true);
	recalculateWindowPosition(window, pos);
	return true;
}
 
源代码19 项目: raccoon4   文件: MainLifecycle.java
@Override
public Window onCreatePrimaryWindow(Globals globals) {
	WindowTogglers wt = globals.get(WindowTogglers.class);
	PushUrlAction pua = new PushUrlAction(globals);
	ScreenshotAction ssa = new ScreenshotAction(globals);
	UpdateAppAction uaa = new UpdateAppAction(globals);
	PlayProfileDao dao = globals.get(DatabaseManager.class).get(
			PlayProfileDao.class);
	dao.subscribe(new DatasetListenerProxy(uaa));
	dao.subscribe(new DatasetListenerProxy(wt));

	BridgeManager bridgeManager = globals.get(BridgeManager.class);
	bridgeManager.addBridgeListener(ssa);
	bridgeManager.addBridgeListener(pua);
	ProfilesMenuBuilder pmb = new ProfilesMenuBuilder();
	Traits traits = globals.get(Traits.class);
	wt.grants.setEnabled(!traits.isMaxed() || traits.isTrial());

	MenuBarBuilder mbb = new MenuBarBuilder()
			.withLocalizer(Messages.getLocalizer())
			.withMenus("filemenu", "marketmenu", "devicemenu", "viewmenu",
					"helpmenu")
			.addItem("filemenu/share", wt.share)
			.addItem("filemenu/importapps", new ImportAppAction(globals))
			.addSeparator("filemenu/---1")
			.addItem("filemenu/quit", new QuitAction(globals))
			.add("marketmenu/profiles", pmb.assemble(globals))
			.addItem("marketmenu/update", uaa)
			.addSeparator("marketmenu/---1")
			.addCheckbox("marketmenu/manualdownload", wt.manualdownload)
			.addCheckbox("marketmenu/importurls", wt.marketimport)
			.addItem("devicemenu/pushurl", pua)
			.addItem("devicemenu/screenshot", ssa)
			.addCheckbox("viewmenu/myapps", wt.myApps)
			.addCheckbox("viewmenu/qrtool", wt.qrtool)
			.addCheckbox("viewmenu/transfers", wt.transfers)
			.addItem("helpmenu/handbook", new BrowseAction(Bookmarks.HANDBOOK))
			.addItem("helpmenu/support", new BrowseAction(Bookmarks.SUPPORT))
			.addItem("helpmenu/featurelist",
					new BrowseAction(Bookmarks.FEATURELIST))
			.addSeparator("helpmenu/---1")
			.addCheckbox("helpmenu/grants", wt.grants);

	Window ret = new WindowBuilder(
			new PlayStoreViewBuilder().withBorder(new EmptyBorder(10, 10, 10, 10)))
			.withTitle(Messages.getString("MainLifecycle.title")).withMenu(mbb)
			.withSize(1200, 768).withIcons("/icons/appicon.png").build(globals);
	ret.addWindowListener(new PostWindowSetup(globals));
	return ret;
}
 
源代码20 项目: consulo   文件: WindowStateAdapter.java
private WindowStateAdapter(@Nonnull Window window) {
  myWindowState.applyFrom(window);
  window.addComponentListener(this);
  window.addWindowListener(this);
  window.addWindowStateListener(this);
}