本文整理汇总了Java中javax.swing.SwingUtilities.getWindowAncestor方法的典型用法代码示例。如果您正苦于以下问题:Java SwingUtilities.getWindowAncestor方法的具体用法?Java SwingUtilities.getWindowAncestor怎么用?Java SwingUtilities.getWindowAncestor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.getWindowAncestor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: repackWindow
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* Repacks the window
*/
private void repackWindow() {
Window window = SwingUtilities.getWindowAncestor(this);
if (window != null) {
window.pack();
window.setLocationRelativeTo(null);
}
}
示例2: executeCommand
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void executeCommand() {
PrivateChatter chat = mgr.getChatterFor(p);
if (chat == null) {
return;
}
Window f = SwingUtilities.getWindowAncestor(chat);
if (!f.isVisible()) {
f.setVisible(true);
Component c = KeyboardFocusManager.getCurrentKeyboardFocusManager()
.getFocusOwner();
if (c == null || !SwingUtilities.isDescendingFrom(c, f)) {
java.awt.Toolkit.getDefaultToolkit().beep();
for (int i = 0,j = chat.getComponentCount(); i < j; ++i) {
if (chat.getComponent(i) instanceof JTextField) {
(chat.getComponent(i)).requestFocus();
break;
}
}
}
}
else {
f.toFront();
}
chat.show(msg);
}
示例3: topComponentToFront
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* Attempts to bring the parent <code>Window</code> of the given <code>TopComponent</code>
* to front of other windows.
* @see java.awt.Window#toFront()
* @since 5.8
*/
protected void topComponentToFront(TopComponent tc) {
Window parentWindow = SwingUtilities.getWindowAncestor(tc);
// be defensive, although w probably will always be non-null here
if (null != parentWindow) {
if (parentWindow instanceof Frame) {
Frame parentFrame = (Frame) parentWindow;
int state = parentFrame.getExtendedState();
if ((state & Frame.ICONIFIED) > 0) {
parentFrame.setExtendedState(state & ~Frame.ICONIFIED);
}
}
parentWindow.toFront();
}
}
示例4: onRegistryChange
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void onRegistryChange( PropertyChangeEvent evt ) {
if( TopComponent.Registry.PROP_ACTIVATED.equals( evt.getPropertyName() ) ) {
final TopComponent tc = TopComponent.getRegistry().getActivated();
if( null != tc ) {
//#237857
Window activeWindow = SwingUtilities.getWindowAncestor(tc);
if( null != activeWindow && !activeWindow.equals(WindowManagerImpl.getInstance().getMainWindow()) )
return;
}
if( switchCurrentEditor() ) {
return;
}
cancel( true );
}
}
示例5: setImageName
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
public void setImageName(String name) {
imageName = name;
remove(0);
if (name == null || name.trim().length() == 0 || name.equals(NO_IMAGE)) {
imageName = "";
add(noImage,0);
}
else {
icon.setOp(Op.load(imageName));
Dimension d = new Dimension(icon.getIconWidth(), icon.getIconHeight());
if (d.width > 200) d.width = 200;
if (d.height > 200) d.height = 200; else d.height += 4;
imageScroller.setPreferredSize(d);
imageScroller.setMinimumSize(d);
add(imageViewer,0);
}
select.removeItemListener(this);
select.setSelectedItem(name);
if (name != null && !name.equals(select.getSelectedItem())) {
select.setSelectedItem(name+".gif");
}
select.addItemListener(this);
revalidate();
final Window w = SwingUtilities.getWindowAncestor(this);
if (w != null) {
w.pack();
}
repaint();
}
示例6: computePopupBounds
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void computePopupBounds (Rectangle result, JLayeredPane lPane, int modelSize) {
Dimension cSize = comboBar.getSize();
int width = getPopupWidth();
Point location = new Point(cSize.width - width - 1, comboBar.getBottomLineY() - 1);
if (SwingUtilities.getWindowAncestor(comboBar) != null) {
location = SwingUtilities.convertPoint(comboBar, location, lPane);
}
result.setLocation(location);
// hack to make jList.getpreferredSize work correctly
// JList is listening on ResultsModel same as us and order of listeners
// is undefined, so we have to force update of JList's layout data
jList1.setFixedCellHeight(15);
jList1.setFixedCellHeight(-1);
// end of hack
jList1.setVisibleRowCount(modelSize);
Dimension preferredSize = jList1.getPreferredSize();
preferredSize.width = width;
preferredSize.height += statusPanel.getPreferredSize().height + 3;
result.setSize(preferredSize);
}
示例7: expandWindowToFitNewConnectorForm
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private void expandWindowToFitNewConnectorForm() {
Window window = SwingUtilities.getWindowAncestor(this);
if (window == null) {
return;
}
Dimension currSize = getSize();
Dimension prefSize = getPreferredSize();
if ((currSize.width >= prefSize.width) && (currSize.height >= prefSize.height)) {
/* the dialog is large enough to fit the form */
return;
}
try {
requestedSize = new Dimension(
Math.max(currSize.width, prefSize.width),
Math.max(currSize.height, prefSize.height));
window.pack();
} finally {
requestedSize = null;
}
}
示例8: repack
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
*
* Utility method to allow Decorator Editors to repack themselves. c must be one of the
* components that make up the Decorator's controls.
*/
public static void repack(Component c) {
final Window w = SwingUtilities.getWindowAncestor(c);
if (w != null) {
w.pack();
}
}
示例9: putBackOriginal
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/** Sets the original glass pane to the root pane of stored container.
*/
static void putBackOriginal() {
if (oldPane == null) {
throw new IllegalStateException("No original pane present");
}
final JRootPane rp = originalSource.getRootPane();
if (rp == null) {
if( null != SwingUtilities.getWindowAncestor( originalSource ) ) //#232187 - only complain when the originalSource is still in component hierarchy
throw new IllegalStateException("originalSource " + originalSource + " has no root pane: " + rp); // NOI18N
} else {
rp.setGlassPane(oldPane);
oldPane.setVisible(wasVisible);
}
oldPane = null;
}
示例10: create
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
private static ProfilerPopup create(Component invoker, Component content, int x, int y, int popupAlign, int resizeMode, Listener listener) {
Point location = new Point(x, y);
Dimension size = new Dimension();
Window owner = null;
if (invoker != null) {
SwingUtilities.convertPointToScreen(location, invoker);
size.setSize(invoker.getSize());
owner = SwingUtilities.getWindowAncestor(invoker);
}
return new ProfilerPopup(content, new Rectangle(location, size), popupAlign, owner, resizeMode, listener);
}
示例11: addNotify
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void addNotify() {
super.addNotify();
//#205194 - cannot minimize floating tab group
Window w = SwingUtilities.getWindowAncestor( displayer );
boolean isFloating = w != WindowManager.getDefault().getMainWindow();
if( isFloating )
setVisible( false );
}
示例12: updateVisibility
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
protected void updateVisibility() {
mapLabel.setVisible(levelConfig.getValueString().equals(NAMED_MAP));
zoneLabel.setVisible(levelConfig.getValueString().equals(NAMED_ZONE));
nameBox.setVisible(!levelConfig.getValueString().equals(CURRENT_ZONE));
Window w = SwingUtilities.getWindowAncestor(controls);
if (w != null) {
w.pack();
}
}
示例13: actionPerformed
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
if (popup != null) {
popup.dispose();
}
Window window = SwingUtilities.getWindowAncestor(RSyntaxTextArea.this);
popup = new MatchedBracketPopup(window, RSyntaxTextArea.this, matchedBracketOffs);
popup.pack();
popup.setVisible(true);
}
示例14: actionPerformedImpl
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
@Override
public void actionPerformedImpl(ActionEvent e, RTextArea textArea) {
Window owner = SwingUtilities.getWindowAncestor(textArea);
ClipboardHistoryPopup popup = new ClipboardHistoryPopup(owner, textArea);
popup.setContents(clipboardHistory.getHistory());
popup.setVisible(true);
}
示例15: setup
import javax.swing.SwingUtilities; //导入方法依赖的package包/类
/**
* When a game is started, create a top-level window, if none exists.
* When a game is ended, remove all boards from the map.
*
* @see GameComponent
*/
public void setup(boolean show) {
if (show) {
final GameModule g = GameModule.getGameModule();
if (shouldDockIntoMainWindow()) {
mainWindowDock.showComponent();
final int height = ((Integer)
Prefs.getGlobalPrefs().getValue(MAIN_WINDOW_HEIGHT)).intValue();
if (height > 0) {
final Container top = mainWindowDock.getTopLevelAncestor();
top.setSize(top.getWidth(), height);
}
if (toolBar.getParent() == null) {
g.getToolBar().addSeparator();
g.getToolBar().add(toolBar);
}
toolBar.setVisible(true);
}
else {
if (SwingUtilities.getWindowAncestor(theMap) == null) {
final Window topWindow = createParentFrame();
topWindow.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (useLaunchButton) {
topWindow.setVisible(false);
}
else {
g.getGameState().setup(false);
}
}
});
((RootPaneContainer) topWindow).getContentPane().add("North", getToolBar()); //$NON-NLS-1$
((RootPaneContainer) topWindow).getContentPane().add("Center", layeredPane); //$NON-NLS-1$
topWindow.setSize(600, 400);
final PositionOption option =
new PositionOption(PositionOption.key + getIdentifier(), topWindow);
g.getPrefs().addOption(option);
}
theMap.getTopLevelAncestor().setVisible(!useLaunchButton);
theMap.revalidate();
}
}
else {
pieces.clear();
boards.clear();
if (mainWindowDock != null) {
if (mainWindowDock.getHideableComponent().isShowing()) {
Prefs.getGlobalPrefs().getOption(MAIN_WINDOW_HEIGHT)
.setValue(mainWindowDock.getTopLevelAncestor().getHeight());
}
mainWindowDock.hideComponent();
toolBar.setVisible(false);
}
else if (theMap.getTopLevelAncestor() != null) {
theMap.getTopLevelAncestor().setVisible(false);
}
}
launchButton.setEnabled(show);
launchButton.setVisible(useLaunchButton);
}