繁体   English   中英

Java 应用程序的安全桌面模式效果

[英]Secure Desktop Mode effect for java application

现在有没有人如何实现“安全桌面模式”(效果),例如从 Windows Vista/7 UAC 同意块中获得的?

我假设这是一些函数,它会在这里和那里删除像素(并可能使它们变灰),然后最终将其绘制到屏幕上。 我想将它应用于我的应用程序,以防止用户在另一个用户连接到系统之前做任何事情(但这不是重点)。

我真的很感激你的建议。

亲切的问候,
一种。

编辑:我真的只是在寻找这个

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

输入的延迟我可以做得很好。

谢谢大家。

我们将JXLayer用于这个确切的目的......

在此处输入图像描述在此处输入图像描述

这非常有用,因为它可以将用户锁定在给定容器之外,而不会像GlassPane解决方案那样锁定应用程序。 它就像容器的玻璃板;)

我偷了这里的基本想法

 public class JXLayerTest {

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

      public JXLayerTest() {
           EventQueue.invokeLater(new Runnable() {
                @Override
                public void run() {
                     try {
                          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                     } catch (ClassNotFoundException ex) {
                     } catch (InstantiationException ex) {
                     } catch (IllegalAccessException ex) {
                     } catch (UnsupportedLookAndFeelException ex) {
                     }

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

                     // 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        
                     ui.setLockedEffects(effect);
                     ui.setLocked(false);

                     JFrame frame = new JFrame();
                     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                     frame.setLayout(new BorderLayout());
                     frame.add(layer);

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

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

                          }
                     });

                     panelButtons.add(lock);
                     frame.add(panelButtons, BorderLayout.SOUTH);

                     frame.pack();
                     frame.setLocationRelativeTo(null);
                     frame.setVisible(true);
                }

                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() {
                          @Override
                          public void actionPerformed(ActionEvent e) {
                               JOptionPane.showMessageDialog(null, "Clicked");
                          }
                     });

                     gbc.gridy++;
                     panel.add(button, gbc);

                }
           });
      }
 }

不要重新发明轮子,而是尝试在组件上使用setEnabled(false)来禁用它,并在连接到系统时调用setEnabled(true)再次启用组件。

有关更多信息,请参见此示例,其中显示了一个灰色/不可点击的JButton

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM