Example usage for java.awt Window Window

List of usage examples for java.awt Window Window

Introduction

In this page you can find the example usage for java.awt Window Window.

Prototype

public Window(Window owner) 

Source Link

Document

Constructs a new, initially invisible window with the specified Window as its owner.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
    d1.setName("Dialog 1");

    JDialog d2 = new JDialog((Window) null, "Dialog 2");
    d2.setName("Dialog 2");

    Frame f = new Frame();
    f.setName("Frame 1");

    Window w1 = new Window(f);
    w1.setName("Window 1");

    Window w2 = new Window(null);
    w2.setName("Window 2");

    Window[] windows = Window.getWindows();
    for (Window window : windows)
        System.out.println(window.getName() + ": " + window.getClass());

}

From source file:MainClass.java

public static void main(String[] args) {
    JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
    d1.setName("Dialog 1");

    JDialog d2 = new JDialog((Window) null, "Dialog 2");
    d2.setName("Dialog 2");

    Frame f = new Frame();
    f.setName("Frame 1");

    Window w1 = new Window(f);
    w1.setName("Window 1");

    Window w2 = new Window(null);
    w2.setName("Window 2");

    Window[] ownerlessWindows = Window.getOwnerlessWindows();
    for (Window window : ownerlessWindows)
        System.out.println(window.getName() + ": " + window.getClass());

}

From source file:MainClass.java

public static void main(String[] args) {
    JDialog d1 = new JDialog((JFrame) null, "Dialog 1");
    d1.setName("Dialog 1");

    JDialog d2 = new JDialog((Window) null, "Dialog 2");
    d2.setName("Dialog 2");

    Frame f = new Frame();
    f.setName("Frame 1");

    Window w1 = new Window(f);
    w1.setName("Window 1");

    Window w2 = new Window(null);
    w2.setName("Window 2");

    System.out.println("FRAME WINDOWS");
    Frame[] frames = Frame.getFrames();
    for (Frame frame : frames)
        System.out.println(frame.getName() + ": " + frame.getClass());

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gs = ge.getDefaultScreenDevice();

    Button btn = new Button("OK");
    btn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            GraphicsDevice gs = ge.getDefaultScreenDevice();
            gs.setFullScreenWindow(null);
        }//from  w ww .  ja v  a  2  s  .c  om
    });
    Frame frame = new Frame(gs.getDefaultConfiguration());
    Window win = new Window(frame);
    win.add(btn, BorderLayout.CENTER);
    try {
        gs.setFullScreenWindow(win);
        win.validate();
    } finally {
        gs.setFullScreenWindow(null);
    }
}

From source file:com.xilinx.ultrascale.gui.MainScreen_video.java

private void initVideoPlayer() {
    //        jSlider1.setValue(0);
    //NativeLibrary.addSearchPath("libvlc", "/usr/local/lib/");
    //        sysout("initializing video player");
    System.setProperty("jna.library.path", "/usr/local/lib/");
    //JDesktopPane desktopPane;

    //desktopPane = new JDesktopPane();
    videoFrame = new JFrame("Video Panel");
    videoFrame.setSize(975, 300);/*from w  w  w  . ja v a  2 s.  c o  m*/
    videoFrame.setBounds(0, 0, 975, 350);
    videoFrame.setResizable(false);
    videoFrame.setLocationRelativeTo(this);
    //        videoFrame.getContentPane().setBackground(Color.BLACK);
    videoFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    //videoFrame.setContentPane(desktopPane);
    //videoFrame.add(desktopPane);
    videoFrame.setVisible(false);
    //videoFrame.setUndecorated(true);
    //videoFrame.setFocusableWindowState(false);
    //videoFrame.setEnabled(false);

    frame1 = new Window(videoFrame);
    frame1.setSize(480, 270);
    frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270);
    //frame1.setUndecorated(true);
    //frame1.setAlwaysOnTop(true);

    //frame1.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame2 = new Window(videoFrame);

    frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270);
    //frame2.setUndecorated(true);
    //frame2.setAlwaysOnTop(true);
    //frame2.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    //JInternalFrame jf1 = new JInternalFrame();
    //jf1.setContentPane(frame1.getContentPane());
    //JInternalFrame jf2 = new JInternalFrame();
    //jf2.setContentPane(frame2.getContentPane());
    //desktopPane.add(jf1);
    //desktopPane.add(jf2);
    screen = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    txMediaPlayer = create(frame1, 1);
    rxMediaPlayer = create(frame2, 0);
    txMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
                if (screen.getFullScreenWindow() == null) {
                    //                        System.out.println("TX fullscreen");
                    screen.setFullScreenWindow(frame1);
                    txMediaPlayer.getMediaPlayer().setAspectRatio("16:10");
                    //                        System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() );
                } else {
                    //                        System.out.println("TX normalscreen");
                    screen.setFullScreenWindow(null);
                    txMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio);
                    //                        System.out.println("aspect ratio: "+txMediaPlayer.getMediaPlayer().getAspectRatio() );
                }
            }
        }
    });

    rxMediaPlayer.getVideoSurface().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent event) {
            if (event.getClickCount() == 2) {
                if (screen.getFullScreenWindow() == null) {
                    //                        System.out.println("RX fullscreen");
                    screen.setFullScreenWindow(frame2);
                    rxMediaPlayer.getMediaPlayer().setAspectRatio("16:10");
                    //                        System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() );

                } else {
                    //                        System.out.println("rX normalscreen");
                    screen.setFullScreenWindow(null);
                    rxMediaPlayer.getMediaPlayer().setAspectRatio(aspectRatio);
                    //                        System.out.println("aspect ratio: "+rxMediaPlayer.getMediaPlayer().getAspectRatio() );
                }
            }
        }
    });
    videoFrame.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentMoved(ComponentEvent e) {
            super.componentMoved(e); //To change body of generated methods, choose Tools | Templates.
            frame1.setBounds(videoFrame.getBounds().x + 5, videoFrame.getBounds().y + 50, 480, 270);

            frame2.setBounds(videoFrame.getBounds().x + 490, videoFrame.getBounds().y + 50, 480, 270);
            //frame1.setBounds(videoFrame.getBounds().x + 50, videoFrame.getBounds().y + 50, 400, 400);
            //frame2.setBounds(videoFrame.getBounds().x + 500, videoFrame.getBounds().y + 50, 400, 400);
        }

    });
    /*txCanvas = new Canvas();
     txCanvas.setSize(videoWidth, VideoHeight);//(txVidPanel.getWidth(), txVidPanel.getHeight());
     txVidPanel.add(txCanvas);
     txVidPanel.revalidate();
     txVidPanel.repaint();
     //Creation a media player :
     txMediaPlayerFactory = new MediaPlayerFactory(VLC_ARGS);
     txMediaPlayer = txMediaPlayerFactory.newEmbeddedMediaPlayer();
     CanvasVideoSurface videoSurface = txMediaPlayerFactory.newVideoSurface(txCanvas);
     txMediaPlayer.setVideoSurface(videoSurface);
            
            
     // rx video
     rxCanvas = new Canvas();
     rxCanvas.setSize(videoWidth, VideoHeight);//(rxVidPanel.getWidth(), rxVidPanel.getHeight());
     rxVidPanel.add(rxCanvas);
     rxVidPanel.revalidate();
     rxVidPanel.repaint();
     //Creation a media player :
     rxMediaPlayerFactory = new MediaPlayerFactory();
     rxMediaPlayer = rxMediaPlayerFactory.newEmbeddedMediaPlayer();
     CanvasVideoSurface videorxSurface = rxMediaPlayerFactory.newVideoSurface(rxCanvas);
     rxMediaPlayer.setVideoSurface(videorxSurface);
            
     //frame to display video
     videoFrame = new JFrame("Video Panel");
     videoFrame.addWindowListener(new WindowAdapter() {
     @Override
     public void windowClosing(WindowEvent we) {
     //                rxMediaPlayer.stop();
     //                txMediaPlayer.stop();
     //                videoFrame.hide();
     }
     });
            
     videoFrame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
     //        videoFrame.add(videosPanel);
            
     videoFrame.setSize(videoWidth * 2, VideoHeight);
     videoFrame.setPreferredSize(new Dimension(videoWidth * 2, VideoHeight + 20));
            
     videosPanel.setLocation(0, 0);
     videoFrame.setLayout(new BorderLayout());
     videoFrame.add(videosPanel, BorderLayout.CENTER);
     //videoFrame.show();\
     videoFrame.setResizable(false);
     videoFrame.pack();
            
     sysout("video player initialized");*/
}

From source file:org.openmrs.test.BaseContextSensitiveTest.java

/**
 * Utility method for obtaining username and password through Swing interface for tests. Any
 * tests extending the org.openmrs.BaseTest class may simply invoke this method by name.
 * Username and password are returned in a two-member String array. If the user aborts, null is
 * returned. <b> <em>Do not call for non-interactive tests, since this method will try to
 * render an interactive dialog box for authentication!</em></b>
 * /* w w w.  j  a  v a2s.  c  o m*/
 * @param message string to display above username field
 * @return Two-member String array containing username and password, respectively, or
 *         <code>null</code> if user aborts dialog
 */
public static synchronized String[] askForUsernameAndPassword(String message) {

    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {

    }

    if (message == null || "".equals(message))
        message = "Enter username/password to authenticate to OpenMRS...";

    JPanel panel = new JPanel(new GridBagLayout());
    JLabel usernameLabel = new JLabel("Username");
    usernameLabel.setFont(font);
    usernameField = new JTextField(20);
    usernameField.setFont(font);
    JLabel passwordLabel = new JLabel("Password");
    passwordLabel.setFont(font);
    JPasswordField passwordField = new JPasswordField(20);
    passwordField.setFont(font);
    panel.add(usernameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
    panel.add(usernameField, new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    panel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 5, 0));
    panel.add(passwordField, new GridBagConstraints(1, 1, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    frame = new JFrame();
    Window window = new Window(frame);
    frame.setVisible(true);
    frame.setTitle("JUnit Test Credentials");

    // We use a TimerTask to force focus on username, but still use
    // JOptionPane for model dialog
    TimerTask later = new TimerTask() {

        @Override
        public void run() {
            if (frame != null) {
                // bring the dialog's window to the front
                frame.toFront();
                usernameField.grabFocus();
            }
        }
    };
    // try setting focus half a second from now
    new Timer().schedule(later, 500);

    // attention grabber for those people that aren't as observant
    TimerTask laterStill = new TimerTask() {

        @Override
        public void run() {
            if (frame != null) {
                frame.toFront(); // bring the dialog's window to the
                // front
                usernameField.grabFocus();
            }
        }
    };
    // if the user hasn't done anything in 10 seconds, tell them the window
    // is there
    new Timer().schedule(laterStill, 10000);

    // show the dialog box
    int response = JOptionPane.showConfirmDialog(window, panel, message, JOptionPane.OK_CANCEL_OPTION);

    // clear out the window so the timer doesn't screw up
    laterStill.cancel();
    frame.setVisible(false);
    window.setVisible(false);
    frame = null;

    // response of 2 is the cancel button, response of -1 is the little red
    // X in the top right
    return (response == 2 || response == -1 ? null
            : new String[] { usernameField.getText(), String.valueOf(passwordField.getPassword()) });
}

From source file:processing.app.Base.java

/**
 * Show the About box.//from w  w  w. j  a  v  a2 s  .  co m
 */
@SuppressWarnings("serial")
public void handleAbout() {
    final Image image = Theme.getLibImage("about", activeEditor, Theme.scale(475), Theme.scale(300));
    final Window window = new Window(activeEditor) {
        public void paint(Graphics graphics) {
            Graphics2D g = Theme.setupGraphics2D(graphics);
            g.drawImage(image, 0, 0, null);

            Font f = new Font("SansSerif", Font.PLAIN, Theme.scale(11));
            g.setFont(f);
            g.setColor(new Color(0, 151, 156));
            g.drawString(BaseNoGui.VERSION_NAME_LONG, Theme.scale(33), Theme.scale(20));
        }
    };
    window.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            window.dispose();
        }
    });
    int w = image.getWidth(activeEditor);
    int h = image.getHeight(activeEditor);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    window.setBounds((screen.width - w) / 2, (screen.height - h) / 2, w, h);
    window.setLocationRelativeTo(activeEditor);
    window.setVisible(true);
}