package com.course.UI; |
import java.awt.BorderLayout; |
import java.awt.Container; |
import java.awt.EventQueue; |
import javax.swing.JDesktopPane; |
import javax.swing.JFrame; |
import javax.swing.JPanel; |
import javax.swing.border.EmptyBorder; |
import javax.swing.JMenuBar; |
import javax.swing.JMenu; |
import javax.swing.JMenuItem; |
import javax.swing.JOptionPane; |
import java.awt.event.ActionListener; |
import java.awt.event.ActionEvent; |
public class MainWindow extends JFrame { |
/** |
* Launch the application. |
*/ |
public static void main(String[] args) { |
EventQueue.invokeLater( new Runnable() { |
public void run() { |
try { |
MainWindow frame = new MainWindow(); |
frame.setVisible( true ); |
} catch (Exception e) { |
e.printStackTrace(); |
} |
} |
}); |
} |
/** |
* Create the frame. |
*/ |
public MainWindow() { |
setTitle( "\u8BFE\u7A0B\u7BA1\u7406\u7CFB\u7EDF" ); |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
setBounds( 100 , 100 , 800 , 600 ); |
setLocationRelativeTo( null ); |
JDesktopPane desktopPane= new JDesktopPane(); |
|
Container content=getContentPane(); |
content.add(desktopPane,BorderLayout.CENTER); |
JMenuBar menuBar = new JMenuBar(); |
setJMenuBar(menuBar); |
|
JMenu m_courseType = new JMenu( "\u8BFE\u7A0B\u7C7B\u522B" ); |
menuBar.add(m_courseType); |
|
JMenuItem mi_addCouseType = new JMenuItem( "\u6DFB\u52A0\u8BFE\u7A0B\u7C7B\u522B" ); |
m_courseType.add(mi_addCouseType); |
|
JMenuItem mi_courseTypeManage = new JMenuItem( "\u8BFE\u7A0B\u7C7B\u522B\u7BA1\u7406" ); |
m_courseType.add(mi_courseTypeManage); |
|
JMenu m_courseManage = new JMenu( "\u8BFE\u7A0B\u7BA1\u7406" ); |
menuBar.add(m_courseManage); |
|
JMenuItem mi_addcourse = new JMenuItem( "\u6DFB\u52A0\u8BFE\u7A0B" ); |
m_courseManage.add(mi_addcourse); |
|
JMenuItem mi_courseManage = new JMenuItem( "\u8BFE\u7A0B\u7BA1\u7406" ); |
m_courseManage.add(mi_courseManage); |
|
JMenu m_about = new JMenu( "\u5173\u4E8E" ); |
menuBar.add(m_about); |
|
JMenuItem mi_author = new JMenuItem( "\u4F5C\u8005" ); |
mi_author.addActionListener( new ActionListener() { |
public void actionPerformed(ActionEvent arg0) { |
AuthorWindow authorWindow= new AuthorWindow(); |
authorWindow.setVisible( true ); |
desktopPane.add(authorWindow); |
} |
}); |
m_about.add(mi_author); |
|
JMenuItem mi_exit = new JMenuItem( "\u9000\u51FA" ); |
mi_exit.addActionListener( new ActionListener() { |
public void actionPerformed(ActionEvent arg0) { |
int result=JOptionPane.showConfirmDialog( null , "是否要退出系统!" ); |
if (result== 0 ) |
MainWindow. this .dispose(); |
} |
}); |
m_about.add(mi_exit); |
|
}} |