摆动窗口在mac上没有响应

时间:2014-03-12 12:35:49

标签: java macos swing

嗨我正在使用mac在eclipse上运行以下程序。它们将弹出一个窗口,该窗口在Windows系统中是交互式的。但弹出窗口在我的mac中没有响应。我正在使用JRE 1.6。谁能帮助我?

public static void main(String[] args) {
        try {
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            //UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
        } catch (UnsupportedLookAndFeelException ex) {
            ex.printStackTrace();
        } catch (IllegalAccessException ex) {
            ex.printStackTrace();
        } catch (InstantiationException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        /* Turn off metal's use of bold fonts */
        //UIManager.put("swing.boldMetal", Boolean.FALSE);

        //Schedule a job for event dispatch thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                UserInterface.createAndShowGUI();
            }
        });

    }


    public static void createAndShowGUI() {
            //Create and set up the window.
            UserInterface frame = new UserInterface("something");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

            //Set up the content pane.
            frame.addComponentsToPane();

            uih.start();

            //Display the window.
            frame.pack();
            frame.setVisible(true);
        }
private void addComponentsToPane() {

        typingArea = new JTextField(20);
        typingArea.addKeyListener(this);

        displayArea = new JTextArea();
        displayArea.setEditable(false);
        JScrollPane scrollPane = new JScrollPane(displayArea);
        scrollPane.setPreferredSize(new Dimension(375, 125));

        getContentPane().add(scrollPane, BorderLayout.PAGE_START);
        getContentPane().add(typingArea, BorderLayout.CENTER);
    }
//the following 3 are for addKeyListener
@Override
    public void keyPressed(KeyEvent e) {
        displayInfo(e);
    }

    @Override
    public void keyTyped(KeyEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void keyReleased(KeyEvent e) {
        // TODO Auto-generated method stub

    }

0 个答案:

没有答案