十四周总结以及实验报告
实验报告:
package Demo;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFrame ;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax. swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
public class Notepad {
public static void main (String[] args) {
JFrame frame = new JFrame ("Welcome To MLDN") ; // 定义窗体
JTextArea text = new JTextArea () ; //定义文本域
text. setEditable (true) ;//定义文本组件可编辑
frame . getContentPane () .add (new JScrollPane(text)); // 在面板中加入文本框及滚动条
JMenu menuFile = new JMenu ("文件") ;//定义JMenu组件
menuFile. setIcon (new ImageIcon("d:" + File. separator + "icons"+ File.separator + "file.gif")) ;//定义显示图标
JMenuBar menuBar = new JMenuBar () ;//定义JMenuBar
JMenuItem newItem = new JMenuItem ("新建",new ImageIcon("d:" + File. separator + "icons" + File. separator + "new.gif")) ; //创建JMenuItem
JMenuItem openItem = new JMenuItem("打开",new ImageIcon("d:" + File. separator + "icons"+ File. separator + "open.gif")) ; //创建JMenuI tem
JMenuItem closeItem = new JMenuItem ("关闭" ,new ImageIcon("d:" + File. separator + " icons"+ File. separator + "close.gif")) ; //创建JMenuI tem
JMenuItem exitItem = new JMenuItem ("退出",new ImageIcon("d:" + File. separator + " icons"+ File. separator + "exit.gif")) ; //创建JMenuI tem
newItem.setMnemonic('N') ; //设置快捷键N
openItem.setMnemonic('O') ; //设置快捷键O
closeItem.setMnemonic('C') ; //设置快捷键C
exitItem.setMnemonic ('E') ;//设置快捷键E
newItem.setAccelerator (KeyStroke.getKeyStroke('N',java.awt.Event.CTRL_MASK)); //Ctrl+N
openItem.setAccelerator (KeyStroke.getKeyStroke('O',java.awt.Event.CTRL_MASK)) ; //Ctrl+0
closeItem.setAccelerator (KeyStroke.getKeyStroke('C',java.awt . Event.ALT_MASK) ) ;//Alt+C
exitItem.setAccelerator (KeyStroke.getKeyStroke('E',java.awt .Event.ALT_MASK) ) ;//Alt+E
menuFile.add (newItem) ;//Alt+E
menuFile.add (newItem) ;//加入菜单项
menuFile.add (openItem) ;//加入菜单项
menuFile.add (closeItem) ;//加入菜单项
menuFile.addSeparator () ;//加入分隔线
menuFile.add (exitItem) ;//加入菜单项
menuBar.add (menuFile) ;//加入JMenu
frame.addWindowListener (new WindowAdapter () {//加入事件监听
public void windowClosing (WindowEvent arg0) { // 覆写窗口关闭方法
System.exit(1) ;
}});//系统退出
frame . setJMenuBar (menuBar) ;//在窗体中加入.JMenuBa r组件
frame . setVisible (true) ;//显示组件
frame. setSize(300,180) ;//定义窗体大小
frame. setLocation(300,200) ;//设置显示位置
}
}
总结:
这周我们学习了jdbc的基础内容