List of usage examples for java.awt Window setVisible
public void setVisible(boolean b)
From source file:Main.java
public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); Window w = new Main(); w.setVisible(true); com.sun.awt.AWTUtilities.setWindowOpacity(w, 0.7f); }
From source file:Main.java
public static void main(String[] args) { final JLabel label = new JLabel(); int timerDelay = 1000; new Timer(timerDelay, new ActionListener() { int timeLeft = 5; @Override/* w w w .j a va2 s . c om*/ public void actionPerformed(ActionEvent e) { if (timeLeft > 0) { label.setText("Closing in " + timeLeft + " seconds"); timeLeft--; } else { ((Timer) e.getSource()).stop(); Window win = SwingUtilities.getWindowAncestor(label); win.setVisible(false); } } }) { { setInitialDelay(0); } }.start(); JOptionPane.showMessageDialog(null, label); }
From source file:Main.java
public static void close(Window win) { if (win != null) { win.setVisible(false); win.dispose();/*from w ww . j a v a 2 s .co m*/ } }
From source file:Main.java
/** Shortcut for the boilerplate code to pack and display a window (such as a {@code JFrame}). */ public static void displayWindow(Window w) { w.pack();//w w w. ja v a 2 s. c o m w.setVisible(true); }
From source file:Main.java
/** * Centers the passed window (dialog or frame) on the screen and makes * it visible. This is typically used to display the main window for * an application./*ww w.j av a 2s . co m*/ */ public static void centerAndShow(Window window) { center(window); window.setVisible(true); }
From source file:Main.java
/** * Centers the passed window (dialog or frame) within the second window * and makes it visible. This is typically used to display a dialog. * <p>/*from ww w . jav a 2 s. co m*/ * The second window may be null, in which case the first is centered within * the screen. This is a convenience for ownerless dialogs. */ public static void centerAndShow(Window window, Window inWindow) { center(window, inWindow); window.setVisible(true); }
From source file:Main.java
/** * Attaches a {@link WindowListener} to the given Window so it is disposed * when the close button is hit. Some windows do not respond to the * DISPOSE_ON_CLOSE operation, so this is better than using that. *//*from w w w .j a va 2 s. c om*/ public static void attachDisposeOnClose(final Window w) { w.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { w.setVisible(false); w.dispose(); } }); }
From source file:Main.java
public static void showWindow(final Window window, boolean modal) { Runnable r = new Runnable() { public void run() { window.pack();/*from www.j a va 2 s . c om*/ window.setVisible(true); } }; if (modal) { try { SwingUtilities.invokeAndWait(r); window.dispose(); } catch (Exception e) { throw new RuntimeException(e); } } else { SwingUtilities.invokeLater(r); } }
From source file:Main.java
/** * Makes a window visible - if invisible - and brings it to front. * * @param window window/*from w w w . j ava 2 s.c o m*/ */ public static void show(Window window) { if (window == null) { throw new NullPointerException("window == null"); } if (!window.isVisible()) { window.setVisible(true); } window.toFront(); }
From source file:Main.java
/** * Closes and disposes a given {@link Window}. * //www .j a v a2 s . c o m * @param aWindow * the window to close, if <code>null</code>, this method doesn't do * anything. */ public static void dispose(final Window aWindow) { if (aWindow == null) { return; } if (aWindow.isVisible()) { aWindow.setVisible(false); } aWindow.dispose(); }