关于InternalFrame内部窗体的问题

25K邪帥 发布于 2010/01/06 20:58
阅读 1K+
收藏 0

能帮忙写写个代码 说明一下internalFrame组件的的用法吗,要出现 以上 两种窗体,谢谢啦!

加载中
0
aoyanfeng
aoyanfeng
import java.awt.BorderLayout;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.SwingUtilities;

public class DesktopDemo {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                DesktopDemo demo = new DesktopDemo();
                demo.frame.setVisible(true);
            }
        });
    }
    private JFrame frame;
    public DesktopDemo(){
        frame = new JFrame("DesktopDemo");
        frame.setSize(200,200);
        frame.setLayout(new BorderLayout());
        JDesktopPane desktopPane = new JDesktopPane();
        frame.add(desktopPane, BorderLayout.CENTER);
        JInternalFrame internalFrame = new JInternalFrame("Children");
        internalFrame.setBounds(10, 10, 100, 100);
        internalFrame.setVisible(true);
        desktopPane.add(internalFrame);
    }
}
返回顶部
顶部