本文整理匯總了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();
}