List of usage examples for javax.swing JWindow setAlwaysOnTop
public final void setAlwaysOnTop(boolean alwaysOnTop) throws SecurityException
From source file:com.totsp.sotu.app.ScreenAreaWatcher.java
/** Creates a new instance of ScreenWatcher */ public ScreenAreaWatcher(final Configuration config) throws AWTException { super();/* w w w.ja v a 2 s . c o m*/ this.config = config; System.out.println(config.getWidth() + "x" + config.getHeight()); JPanel jp = null; JWindow top = new JWindow(); top.setBackground(GREEN); top.setLocation(0, 0); top.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); top.add(jp); top.pack(); top.setSize(config.getWidth(), config.getBorderSize()); JWindow bottom = new JWindow(); bottom.setBackground(GREEN); bottom.setLocation(0, config.getHeight() - config.getBorderSize()); bottom.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); bottom.add(jp); bottom.pack(); bottom.setSize(config.getWidth(), config.getBorderSize()); JWindow left = new JWindow(); left.setBackground(GREEN); left.setLocation(0, 0); left.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); left.add(jp); left.pack(); left.setSize(config.getBorderSize(), config.getHeight()); JWindow right = new JWindow(); right.setLocation(config.getWidth() - config.getBorderSize(), 0); right.setAlwaysOnTop(true); jp = new JPanel(); jp.setBackground(GREEN); right.add(jp); right.pack(); right.setSize(config.getBorderSize(), config.getHeight()); top.setVisible(true); bottom.setVisible(true); left.setVisible(true); right.setVisible(true); windows = new JWindow[4]; windows[0] = top; windows[1] = bottom; windows[2] = left; windows[3] = right; MouseInputAdapter adapter = new Adapter(windows); top.addMouseListener(adapter); top.addMouseMotionListener(adapter); bottom.addMouseListener(adapter); bottom.addMouseMotionListener(adapter); left.addMouseListener(adapter); left.addMouseMotionListener(adapter); right.addMouseListener(adapter); right.addMouseMotionListener(adapter); timer.schedule(new ImageUpdateTimerTask(this), 0, config.getMaxUpdateInterval()); this.addPropertyChangeListener("image", new PropertyChangeListener() { HttpClient client = new HttpClient(); public void propertyChange(PropertyChangeEvent propertyChangeEvent) { BufferedImage img = (BufferedImage) propertyChangeEvent.getNewValue(); try { File outputFile = File.createTempFile("save-" + System.currentTimeMillis(), ".png"); JAI.create("filestore", img, outputFile.getCanonicalPath(), "PNG", null); System.out.println("Temp File: " + outputFile.getCanonicalPath()); MultipartPostMethod method = new MultipartPostMethod( config.getServerUrl() + "/ImagePublishingServlet"); method.addParameter("adminPassword", config.getAdminPassword()); method.addParameter("conversation", config.getConversationName()); method.addParameter("image", outputFile); client.executeMethod(method); } catch (Exception e) { System.err.println("Error handling image"); e.printStackTrace(); } } }); }
From source file:com.igormaznitsa.sciareto.ui.MainFrame.java
private void menuFullScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFullScreenActionPerformed final Component currentComponent = this.tabPane.getSelectedComponent(); if (!(currentComponent instanceof Container)) { LOGGER.warn("Detected attempt to full screen not a container : " + currentComponent); return;//from w w w . j a v a2 s .c o m } 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.setContentPane((Container) currentComponent); 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, currentComponent); 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); endFullScreenIfActive(); KeyboardFocusManager.getCurrentKeyboardFocusManager() .removeKeyEventDispatcher(fullScreenEscCatcher); } } else { LOGGER.error("Unexpected state, processor is not null!"); } } else { LOGGER.warn("Attempt to full screen device which already in full screen!"); } } else { LOGGER.warn("Device doesn's support full screen"); DialogProviderManager.getInstance().getDialogProvider() .msgWarn("The Device doesn't support full-screen mode!"); } } else { LOGGER.warn("Can't find graphics config for the frame"); } }