posts - 38,  comments - 22,  trackbacks - 0

1、在程序中调用dos命令,并返回结果:
String command = "cmd.exe /c ver";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
2、初始窗口最大化&最小化
frame.setVisible(true);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setExtendedState(JFrame.ICONIFIED);
3、监听F11
static {
        try {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            toolkit.addAWTEventListener(new AWTEventListener() {
                public void eventDispatched(AWTEvent e) {
                    if (((KeyEvent) e).getKeyCode() == KeyEvent.VK_F1)
                        System.out.println("F1");
                    if (((KeyEvent) e).getKeyCode() == KeyEvent.VK_F2)
                        System.out.println("F2");
                }
            }, AWTEvent.KEY_EVENT_MASK);
            Thread thread = new Thread(new Runnable() {
                public void run() {
                    try {
                        File music = new File(iSystemConstants.muiscfile);
                        Player player = new Player(new FileInputStream(music));
                        player.play();
                    } catch (FileNotFoundException ex) {
                    } catch (JavaLayerException ex) {
                    }

                }
            });
            //thread.start();

            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e.getMessage(), "ERROR",
                                          JOptionPane.ERROR_MESSAGE);
        }
    }

posted on 2007-04-11 11:53 aaabbb 阅读(308) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航: