import java.awt.GraphicsDevice; 
import java.awt.GraphicsEnvironment; 
import java.awt.GridLayout; 

import javax.swing.JFrame; 
import javax.swing.JLabel; 
import javax.swing.JWindow; 
import javax.swing.SwingUtilities; 

public class SwingTest { 
    public static void main(String args[]) throws InterruptedException { 
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 
        GraphicsDevice[] gs = ge.getScreenDevices(); 
        for (GraphicsDevice g : gs) { 
            SwingUtilities.invokeLater(new Runnable() { 
                 
                @Override 
                public void run() { 
                    final JFrame frame = new JFrame(); 
                    frame.setLayout(new GridLayout(1, 1)); 
                    g.setFullScreenWindow(frame); 
                    JLabel screenIDLabel = new JLabel("Screen " + g.getIDstring()); 
                    JWindow popup = new JWindow(frame); 
                    popup.setSize(200, 200); 
                    popup.setVisible(true); 
                    frame.getContentPane().add(screenIDLabel); 
                    frame.setVisible(true); 
                     
                } 
            }); 
        } 
        Thread.sleep(2000); 
        System.exit(0); 
         
    } 
} 