TOP

Java制作MDI窗體源代碼
2014-11-18 14:54:40 】 瀏覽:10206
Tags:

由于實際需要做一個MDI窗體优乐棋牌app下载,百度里面找到一個不錯的源代碼給大家分享一下。


import javax.swing.*;
import java.awt.event.*;
import java.awt.*;


class JInternalFrame1 extends JFrame implements ActionListener{

JDesktopPane desktopPane;
int count = 1;

public JInternalFrame1() {
super("JInternalFrame1");
Container contentPane = this.getContentPane();
contentPane.setLayout(new BorderLayout());

JButton b = new JButton("Create New Internal Frames");
b.addActionListener(this);//當用戶按下按鈕時,將運行actionPerformed()中的程序
contentPane.add(b, BorderLayout.SOUTH);

desktopPane = new JDesktopPane();
contentPane.add(desktopPane);


setSize(350, 350);
show();

addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}

public void actionPerformed(ActionEvent e)
{
JInternalFrame internalFrame = new JInternalFrame(
"Internal Frame "+(count++), true, true, true, true);


internalFrame.setLocation( 20,20);
internalFrame.setSize(200,200);
internalFrame.setVisible(true);