本文整理汇总了Java中javax.swing.JWindow.setFocusableWindowState方法的典型用法代码示例。如果您正苦于以下问题:Java JWindow.setFocusableWindowState方法的具体用法?Java JWindow.setFocusableWindowState怎么用?Java JWindow.setFocusableWindowState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JWindow
的用法示例。
在下文中一共展示了JWindow.setFocusableWindowState方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ParameterizedCompletionDescriptionToolTip
import javax.swing.JWindow; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param owner The parent window.
* @param ac The parent auto-completion.
* @param pc The completion being described.
*/
public ParameterizedCompletionDescriptionToolTip(Window owner,
ParameterizedCompletionContext context,
AutoCompletion ac, ParameterizedCompletion pc) {
tooltip = new JWindow(owner);
this.pc = pc;
descLabel = new JLabel();
descLabel.setBorder(BorderFactory.createCompoundBorder(
TipUtil.getToolTipBorder(),
BorderFactory.createEmptyBorder(2, 5, 2, 5)));
descLabel.setOpaque(true);
descLabel.setBackground(TipUtil.getToolTipBackground());
// It appears that if a JLabel is set as a content pane directly, when
// using the JDK's opacity API's, it won't paint its background, even
// if label.setOpaque(true) is called. You have to have a container
// underneath it for it to paint its background. Thus, we embed our
// label in a parent JPanel to handle this case.
//tooltip.setContentPane(descLabel);
JPanel panel = new JPanel(new BorderLayout());
panel.add(descLabel);
tooltip.setContentPane(panel);
// Give apps a chance to decorate us with drop shadows, etc.
PopupWindowDecorator decorator = PopupWindowDecorator.get();
if (decorator!=null) {
decorator.decorate(tooltip);
}
updateText(0);
tooltip.setFocusableWindowState(false);
}
示例2: add
import javax.swing.JWindow; //导入方法依赖的package包/类
private static void add(String[] mmeldung, boolean fehler) {
if (Boolean.parseBoolean(MVConfig.get(MVConfig.Configs.SYSTEM_NOTIFICATION))) {
String meldung = "<html><head></head><body><p>";
for (String s : mmeldung) {
meldung += s + "<br />";
}
meldung += "</p></body></html>";
final JWindow messageFrame = new JWindow();
messageFrame.setLayout(new BorderLayout());
final JPanel panel = new JPanel();
panel.setBackground(Color.BLACK);
messageFrame.setContentPane(panel);
final JLabel iconLabel = new JLabel(fehler ? Icons.ICON_NOTIFICATION : Icons.ICON_NOTIFICATION_ERROR);
iconLabel.setVerticalAlignment(SwingConstants.TOP);
messageFrame.getContentPane().add(iconLabel, BorderLayout.WEST);
final JLabel meldungsLabel = new JLabel(meldung);
meldungsLabel.setForeground(Color.WHITE);
messageFrame.getContentPane().add(meldungsLabel, BorderLayout.CENTER);
messageFrame.pack();
messageFrame.setFocusableWindowState(false);
Notification notification = new Notification(messageFrame, WindowPosition.BOTTOMRIGHT, 20, 20, 6000);
NotificationQueue q = new NotificationQueue();
q.add(notification);
}
}
示例3: show
import javax.swing.JWindow; //导入方法依赖的package包/类
public void show() {
// Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
// if (focusOwner != null) focusRef = new WeakReference(focusOwner);
owner = ownerRef == null ? null : ownerRef.get();
ownerLocation = owner == null ? null : owner.getLocationOnScreen();
window = new JWindow(owner);
window.setType(Window.Type.POPUP);
window.setAlwaysOnTop(false);
window.setFocusable(true);
window.setFocusableWindowState(true);
window.setAutoRequestFocus(true);
window.getContentPane().add(content);
window.pack();
if (popupAlign == -1) {
window.setLocation(location.getLocation());
} else {
Dimension size = content.getSize();
int x;
switch (popupAlign) {
case SwingConstants.EAST:
case SwingConstants.NORTH_EAST:
case SwingConstants.SOUTH_EAST:
x = location.x + location.width - size.width + 1;
break;
default:
x = location.x + 1;
break;
}
int y;
switch (popupAlign) {
case SwingConstants.NORTH:
case SwingConstants.NORTH_EAST:
case SwingConstants.NORTH_WEST:
y = location.y - size.height + 1;
break;
default:
y = location.y + location.height + 1;
break;
}
window.setLocation(x, y);
}
window.setVisible(true);
Component defaultFocus = content.getFocusTraversalPolicy().getDefaultComponent(content);
if (defaultFocus != null) defaultFocus.requestFocusInWindow();
content.installListeners();
if (listener != null) listener.popupShown();
}