Effect of Desktop Desktop mode for java application


Does anyone now how to achieve a "Secure-Desktop Mode" (effect) such as one gets from the Windows Vista/7 UAC consent-blocks?

I assume it is some function which will remove pixels here-and-there (and possibly graying them) and then finally drawing that to screen... I would like to apply it to my application to keep the user from doing anything until the another user connects to the system (but that is besides the point)

I would really appreciate the advise.

Kind regards


EDIT: i was really only looking for this

        graphicsFX.setColor(new Color(0, 0, 0, 0.8f));
        graphicsFX.fillRect(0, 0, 800, 600);

the defering of input i can do quite well...

Thanks for all....

We use JXLayer for this exact purpose...

This is really useful as it locks the user out of the given container without locking the out of the application like a GlassPane solution does. It's like a glass pane for containers ;)

I stole the basic idea for here

 public class JXLayerTest {

      public static void main(String[] args) {
           new JXLayerTest();

      public JXLayerTest() {
           EventQueue.invokeLater(new Runnable() {
                public void run() {
                     try {
                     } catch (ClassNotFoundException ex) {
                     } catch (InstantiationException ex) {
                     } catch (IllegalAccessException ex) {
                     } catch (UnsupportedLookAndFeelException ex) {

                     final LockableUI ui = new LockableUI();
                     JPanel panel = new JPanel(new GridBagLayout());

                     // This stolen directly from the JXLayer lockable blog
                     JXLayer layer = new JXLayer(panel, ui);

                     // Java2D grayScale BufferedImageOp
                     ColorConvertOp grayScale = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
                     // wrap it with the jxlayer's BufferedImageOpEffect
                     BufferedImageOpEffect effect = new BufferedImageOpEffect(grayScale);
                     // set it as the locked effect

                     JFrame frame = new JFrame();
                     frame.setLayout(new BorderLayout());

                     JPanel panelButtons = new JPanel(new GridBagLayout());

                     final JButton lock = new JButton("Lock");
                     lock.addActionListener(new ActionListener() {
                          public void actionPerformed(ActionEvent e) {
                               boolean locked = !ui.isLocked();
                               lock.setText(locked ? "Unlock" : "Lock");


                     frame.add(panelButtons, BorderLayout.SOUTH);


                protected void buildUI(JPanel panel) {
                     GridBagConstraints gbc = new GridBagConstraints();
                     gbc.gridx = 0;
                     gbc.gridy = 0;

                     JLabel label = new JLabel();
                     try {
                          BufferedImage image = ImageIO.read(new File("megatokyo.png"));
                          label.setIcon(new ImageIcon(image));
                     } catch (IOException ex) {
                          label.setText("Nothing to see here");

                     panel.add(label, gbc);

                     JButton button = new JButton("Clickl me");
                     button.addActionListener(new ActionListener() {
                          public void actionPerformed(ActionEvent e) {
                               JOptionPane.showMessageDialog(null, "Clicked");

                     panel.add(button, gbc);