这个程序了不得,基本控件全包含进去了。。。真佩服这个程序的作者
package ch02.section02;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import javax.swing.border.*;
import javax.swing.table.*;
public class SwingTest extends JFrame{
public SwingTest(){
MenuTest menuTest=new MenuTest();
LeftPanel leftPanel=new LeftPanel();
RightPanel rightPanel=new RightPanel();
BottomPanel bottomPanel=new BottomPanel();
CenterPanel centerPanel=new CenterPanel();
Container c=this.getContentPane();
this.setJMenuBar(menuTest);
c.add(leftPanel,BorderLayout.WEST);
c.add(rightPanel,BorderLayout.EAST);
c.add(centerPanel,BorderLayout.CENTER);
c.add(bottomPanel,BorderLayout.SOUTH);
this.addWindowListener(new WindowAdapter(){
public void WindowClosing(WindowEvent e){
dispose();
System.exit(0);
}
});
setSize(700,500);
setTitle("Swing 组件大全简体版");
setUndecorated(true);
setLocation(200,150);
show();
}
class MenuTest extends JMenuBar{
private JDialog aboutDialog;
public MenuTest(){
JMenu fileMenu=new JMenu("文件");
JMenuItem exitMenuItem=new JMenuItem("退出",KeyEvent.VK_E);
JMenuItem aboutMenuItem=new JMenuItem("关于..",KeyEvent.VK_A);
fileMenu.add(exitMenuItem);
fileMenu.add(aboutMenuItem);
this.add(fileMenu);
aboutDialog=new JDialog();
initAboutDialog();
exitMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
System.exit(0);
}
});
aboutMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
aboutDialog.show();
}
});
}