本文整理匯總了Java中javax.swing.JWindow.setAlwaysOnTop方法的典型用法代碼示例。如果您正苦於以下問題:Java JWindow.setAlwaysOnTop方法的具體用法?Java JWindow.setAlwaysOnTop怎麽用?Java JWindow.setAlwaysOnTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JWindow
的用法示例。
在下文中一共展示了JWindow.setAlwaysOnTop方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: WindowNotification
import javax.swing.JWindow; //導入方法依賴的package包/類
public WindowNotification() {
m_window = new JWindow();
m_window.setAlwaysOnTop(true);
m_listener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
fireListeners(CLICKED);
if (m_closeOnClick)
removeFromManager();
}
};
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
setPanel(new JPanel());
}
示例2: start
import javax.swing.JWindow; //導入方法依賴的package包/類
/** Start the bot. */
public void start() {
Toolkit tk = Toolkit.getDefaultToolkit();
int xSize = ((int) tk.getScreenSize().getWidth());
int ySize = ((int) tk.getScreenSize().getHeight());
window = new JWindow();
window.setSize(xSize, ySize);
window.setOpacity(0.0f);
window.setVisible(true);
window.setAlwaysOnTop(true);
window.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (clicks < _numberOfLocations) {
location[clicks] = getLocation();
window.setVisible(false);
sleep();
click();
sleep();
window.setVisible(true);
sleep();
clicks += 1;
}
if (clicks == _numberOfLocations) {
window.setVisible(false);
process();
}
}
});
}
示例3: initializeSlider
import javax.swing.JWindow; //導入方法依賴的package包/類
private void initializeSlider(TopicMapGraphPanel gp) {
int minValue = getMinValue(gp);
int maxValue = getMaxValue(gp);
int defaultValue = getDefaultValue(gp);
if(defaultValue < minValue) defaultValue = minValue;
if(defaultValue > maxValue) defaultValue = maxValue;
slider = new SimpleSlider(SimpleSlider.HORIZONTAL, minValue, maxValue, defaultValue);
sliderLabel = new SimpleLabel();
sliderPopup = new JWindow();
slider.setPreferredSize(new Dimension(120, 24));
slider.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
sliderLabel.setFont(UIConstants.smallButtonLabelFont);
sliderLabel.setPreferredSize(new Dimension(30, 24));
sliderLabel.setHorizontalAlignment(SimpleLabel.CENTER);
JPanel panel = new JPanel();
panel.setBorder(new LineBorder(UIConstants.defaultBorderShadow));
panel.setLayout(new BorderLayout(2,2));
panel.add(slider, BorderLayout.CENTER);
panel.add(sliderLabel, BorderLayout.EAST);
sliderPopup.setLayout(new BorderLayout(2,2));
sliderPopup.add(panel, BorderLayout.CENTER);
sliderPopup.setSize(150, 24);
// sliderPopup.addMouseListener(this);
sliderPopup.setAlwaysOnTop(true);
slider.addChangeListener(this);
slider.addMouseListener(this);
}
示例4: createWindow
import javax.swing.JWindow; //導入方法依賴的package包/類
/**
* Creates the WindowGui
* @param icon
* @param head
* @param body
* @param posx
* @param posy
* @param backgroundcolor
* @param headerColor
* @param messageColor
* @return
*/
private static JWindow createWindow(Icon icon, String head, String body,
int posx, int posy, Color backgroundcolor, Color headerColor, Color messageColor) {
final JWindow window = new JWindow();
JPanel windowpanel = new JPanel(new GridBagLayout());
windowpanel.setBackground(backgroundcolor);
AWTUtilities.setWindowShape(window, new RoundRectangle2D.Float(0, 0,
WIDTH, HEIGHT, 20, 20));
AWTUtilities.setWindowOpaque(window, true);
JLabel text = new JLabel("<HTML>" + body + "</HTML>");
text.setForeground(messageColor);
JLabel header = new JLabel(head);
header.setForeground(headerColor);
header.setFont(new Font(header.getFont().getName(), Font.BOLD, header
.getFont().getSize() + 2));
windowpanel.add(new JLabel(icon), new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
windowpanel.add(header, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0));
windowpanel.add(text, new GridBagConstraints(1, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
window.add(windowpanel);
window.setSize(WIDTH, HEIGHT);
window.setLocation(posx - (WIDTH+5), posy+5);
window.setAlwaysOnTop(true);
return window;
}
示例5: 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();
}
示例6: createAndShowLoading
import javax.swing.JWindow; //導入方法依賴的package包/類
private static void createAndShowLoading(){
// create loading welcome
JWindow loading = new JWindow();
loading.setAlwaysOnTop(true);
// set backgroud
loading.setBackground(new Color(0, 0, 0, 0));
// set transparent content
loading.setContentPane(new JPanel(){
@Override
public void setOpaque(boolean isOpaque) {
super.setOpaque(false);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// get g2
Graphics2D g2 = (Graphics2D)g.create();
g2.setComposite(AlphaComposite.SrcOver.derive(0.0f));
g2.setColor(getBackground());
g2.fillRect(0, 0, getWidth(), getHeight());
}
});
JLabel mainLabel = null;
// add the icon
java.net.URL imgURL = WirelessLCDSystem.class.getResource("resource/welcome.png");
if(null != imgURL){
mainLabel = new JLabel(new ImageIcon(imgURL));
loading.add(mainLabel);
}
// set the property location
loading.setLocationRelativeTo(null);
int x = loading.getLocation().x;
int y = loading.getLocation().y;
loading.setLocation(x-400, y-250);
// pack and show
loading.pack();
// show
loading.setVisible(true);
// use a thread to update the logo
(new WelcomeLogo(loading, mainLabel)).execute();
}
示例7: menuFullScreenActionPerformed
import javax.swing.JWindow; //導入方法依賴的package包/類
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed
final AbstractEditor selectedEditor = this.tabPane.getCurrentEditor();
if (selectedEditor != null) {
final GraphicsConfiguration gconfig = this.getGraphicsConfiguration();
if (gconfig != null) {
final GraphicsDevice device = gconfig.getDevice();
if (device.isFullScreenSupported()) {
if (device.getFullScreenWindow() == null) {
final JLabel label = new JLabel("Opened in full screen");
final int tabIndex = this.tabPane.getSelectedIndex();
this.tabPane.setComponentAt(tabIndex, label);
final JWindow window = new JWindow(Main.getApplicationFrame());
window.setAlwaysOnTop(true);
window.setAutoRequestFocus(true);
window.setContentPane(selectedEditor.getContainerToShow());
endFullScreenIfActive();
final KeyEventDispatcher fullScreenEscCatcher = new KeyEventDispatcher() {
@Override
public boolean dispatchKeyEvent(@Nonnull final KeyEvent e) {
if (e.getID() == KeyEvent.KEY_PRESSED && (e.getKeyCode() == KeyEvent.VK_ESCAPE || e.getKeyCode() == KeyEvent.VK_F11)) {
endFullScreenIfActive();
return true;
}
return false;
}
};
if (this.taskToEndFullScreen.compareAndSet(null, new Runnable() {
@Override
public void run() {
try {
window.dispose();
}
finally {
tabPane.setComponentAt(tabIndex, selectedEditor.getContainerToShow());
device.setFullScreenWindow(null);
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(fullScreenEscCatcher);
}
}
})) {
try {
KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(fullScreenEscCatcher);
device.setFullScreenWindow(window);
}
catch (Exception ex) {
LOGGER.error("Can't turn on full screen", ex); //NOI18N
endFullScreenIfActive();
KeyboardFocusManager.getCurrentKeyboardFocusManager().removeKeyEventDispatcher(fullScreenEscCatcher);
}
} else {
LOGGER.error("Unexpected state, processor is not null!"); //NOI18N
}
} else {
LOGGER.warn("Attempt to full screen device which already in full screen!"); //NOI18N
}
} else {
LOGGER.warn("Device doesn's support full screen"); //NOI18N
DialogProviderManager.getInstance().getDialogProvider().msgWarn(null, "The Device doesn't support full-screen mode!");
}
} else {
LOGGER.warn("Can't find graphics config for the frame"); //NOI18N
}
}
}