JinternalFrame设计问题

时间:2015-10-13 12:12:46

标签: java swing jinternalframe

我开始创建一个swing java应用程序,当我突然注意到JInternalFrame中的这个设计问题时,我正在使用JInternalFrame:
enter image description here

是设计错误还是什么?
它有解决方案吗? 这是我的代码:

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JDesktopPane;
import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class TestJInternalFrame extends JFrame {
    public TestJInternalFrame() {

        JDesktopPane desktopPane = new JDesktopPane();
        desktopPane.setBackground(Color.LIGHT_GRAY);
        getContentPane().add(desktopPane, BorderLayout.CENTER);
        desktopPane.setLayout(null);

        JPanel panel = new JPanel();
        getContentPane().add(panel, BorderLayout.NORTH);

        JButton btnOpenInternalframe = new JButton("Open InternalFrame");
        btnOpenInternalframe.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                JInternalFrame f = new JInternalFrame("Test", false, true, false);
                f.setBounds(250, 50, 300, 200);
                desktopPane.add(f);
                f.show();
            }
        });
        panel.add(btnOpenInternalframe);
        setBounds(100, 50, 700, 600);
        setVisible(true);
    }

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (UnsupportedLookAndFeelException e) {
            e.printStackTrace();
        }
        new TestJInternalFrame();
    }
}

0 个答案:

没有答案