|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
其实你不用Struts,spring这些工具,直接用jsp,servlet能够很方便地写出来,而且,可以根据个人的水平、爱好,有很多方案。而struts,spring这些工具的出来。
importjava.awt.*;
importjava.awt.event.*;
importjava.awt.*;
importjavax.swing.*;
importjava.lang.*;
importjava.text.*;
importjava.io.*;
importjava.util.*;
importjavax.accessibility.*;
importjava.awt.datatransfer.*;
//课设记事本
/**********************************************************/
publicclassNotepadextendsJFrameimplementsActionListener,MouseListener
{
JPanelcontentPane;
JMenuBarjMenuBar1=newJMenuBar();
//工具条
JToolBartoolBar=newJToolBar();
JButtonbutton1=newJButton(newImageIcon("new.gif"));
JButtonbutton2=newJButton(newImageIcon("open.gif"));
JButtonbutton3=newJButton(newImageIcon("save.gif"));
//文件菜单
JMenujMenuFile=newJMenu();
JMenuItemjMenuFileNew=newJMenuItem();
JMenuItemjMenuFileOpen=newJMenuItem();
JMenuItemjMenuFileSave=newJMenuItem();
JMenuItemjMenuFileSaveTo=newJMenuItem();
JMenuItemjMenuFileExit=newJMenuItem();
//匡助菜单
JMenujMenuHelp=newJMenu();
JMenuItemjMenuHelpAbout=newJMenuItem();
BorderLayoutborderLayout1=newBorderLayout();
//编纂菜单
JMenujMenuFileEdit=newJMenu();
JMenuItemjMenuFileCut=newJMenuItem();
JMenuItemjMenuFileCopy=newJMenuItem();
JMenuItemjMenuFilePaste=newJMenuItem();
JMenuItemjMenuFileDel=newJMenuItem();
//右键菜单
JMenuItemjMenuMouseCut=newJMenuItem("剪切");
JMenuItemjMenuMouseCopy=newJMenuItem("复制");
JMenuItemjMenuMousePaste=newJMenuItem("粘贴");
JMenuItemjMenuMouseDel=newJMenuItem("删除");
//格局菜单
JMenujMenuFileForm=newJMenu();
JMenuItemjMenuFileFindNext=newJMenuItem();
JMenuItemjMenuFileSelect=newJMenuItem("全选");
JMenuItemjMenuFileTime=newJMenuItem("工夫/日期(D)");
//JMenuItemjMenuFileLine=newJMenuItem("主动换行");
JMenuItemjMenuFileFont=newJMenuItem();
JMenuItemjcolor=newJMenuItem("色彩...");
JCheckBoxjMenuCheckBox=newJCheckBox("主动换行",true);
JTextAreajTextArea1=newJTextArea(15,15);
JLabelstatubar=newJLabel("形态栏");
JPopupMenupm=newJPopupMenu();
Calendarcal=Calendar.getInstance();
//变量声明
Stringfilename;
Stringfilepath;
Stringstrtext="";
booleanbsaved=false;
JFileChooserjFileChooser=newJFileChooser();
JColorChooserjColor=newJColorChooser();
FileDialogfiledialog_save;
BufferedWriterout;
FileWritertofile;
Clipboardcb=Toolkit.getDefaultToolkit().getSystemClipboard();
intn;
inti;
intt;
booleancheck=true;
FileDialogdog;
/**********************************************************/
//组件初始化
publicNotepad(){
contentPane=(JPanel)this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setBounds(110,100,500,450);
this.setFont(newFont("宋体",Font.PLAIN,8));
this.setTitle("记事本");
jTextArea1.setDoubleBuffered(false);
jTextArea1.setToolTipText("记事本");
jTextArea1.setVerifyInputWhenFocusTarget(true);
jTextArea1.setText("");
contentPane.add(statubar,borderLayout1.SOUTH);
toolBar.add(button1);
toolBar.add(button2);
toolBar.add(button3);
jMenuFile.setText("文件");
jMenuFileExit.setText("加入");
jMenuHelp.setText("匡助");
jMenuHelpAbout.setText("关于");
jMenuFileNew.setText("新建(N)");
jMenuFileNew.setMnemonic(KeyEvent.VK_N);
KeyStrokekeynew=KeyStroke.getKeyStroke(KeyEvent.VK_N,Event.CTRL_MASK);
jMenuFileNew.setAccelerator(keynew);
jMenuFileOpen.setText("翻开(O)...");
jMenuFileOpen.setMnemonic(KeyEvent.VK_O);
KeyStrokekeyopen=KeyStroke.getKeyStroke(KeyEvent.VK_O,Event.CTRL_MASK);
jMenuFileOpen.setAccelerator(keyopen);
jMenuFileSave.setText("保留(S)");
jMenuFileSave.setMnemonic(KeyEvent.VK_S);
KeyStrokekeysave=KeyStroke.getKeyStroke(KeyEvent.VK_S,Event.CTRL_MASK);
jMenuFileSave.setAccelerator(keysave);
jMenuFileSaveTo.setText("另存为(A)");
jMenuFileEdit.setText("编纂");
jMenuFileCut.setText("剪切(T)");
jMenuFileCut.setMnemonic(KeyEvent.VK_X);
KeyStrokekeycut=KeyStroke.getKeyStroke(KeyEvent.VK_O,Event.CTRL_MASK);
jMenuFileCut.setAccelerator(keycut);
jMenuFileCopy.setText("复制(C)");
jMenuFileCopy.setMnemonic(KeyEvent.VK_C);
KeyStrokekeycopy=KeyStroke.getKeyStroke(KeyEvent.VK_C,Event.CTRL_MASK);
jMenuFileCopy.setAccelerator(keycopy);
jMenuFilePaste.setText("粘贴(P)");
jMenuFilePaste.setMnemonic(KeyEvent.VK_V);
KeyStrokekeypaste=KeyStroke.getKeyStroke(KeyEvent.VK_V,Event.CTRL_MASK);
jMenuFilePaste.setAccelerator(keypaste);
jMenuFileDel.setText("删除(L)");
jMenuFileFindNext.setText("查找");
jMenuFileFindNext.setMnemonic(KeyEvent.VK_F);
KeyStrokekeyfind=KeyStroke.getKeyStroke(KeyEvent.VK_F,Event.CTRL_MASK);
jMenuFileFindNext.setAccelerator(keyfind);
jMenuFileForm.setText("格局");
jMenuFileFont.setText("字体");
//jMenuFileLine.setText("主动换行");
//jMenuCheckBox.setText("主动换行");
jMenuBar1.add(jMenuFile);
jMenuBar1.add(jMenuFileEdit);
jMenuBar1.add(jMenuFileForm);
jMenuBar1.add(jMenuHelp);
jMenuFile.add(jMenuFileNew);
jMenuFile.add(jMenuFileOpen);
jMenuFile.add(jMenuFileSave);
jMenuFile.add(jMenuFileSaveTo);
jMenuFile.addSeparator();
jMenuFile.add(jMenuFileExit);
jMenuFileEdit.add(jMenuFileCut);
jMenuFileEdit.add(jMenuFileCopy);
jMenuFileEdit.add(jMenuFilePaste);
jMenuFileEdit.add(jMenuFileDel);
jMenuFileEdit.addSeparator();
//jMenuFileEdit.add(jMenuFileFind);
jMenuFileEdit.add(jMenuFileFindNext);
jMenuFileEdit.add(jMenuFileSelect);
jMenuFileEdit.add(jMenuFileTime);
//jMenuFileForm.add(jMenuFileLine);
jMenuFileForm.add(jMenuFileFont);
jMenuFileForm.add(jcolor);
jMenuFileForm.add(jMenuCheckBox);
jMenuHelp.add(jMenuHelpAbout);
contentPane.add(jTextArea1,BorderLayout.CENTER);
//鼠标菜单
jTextArea1.add(pm);
pm.add(jMenuMouseCut);
pm.add(jMenuMouseCopy);
pm.add(jMenuMousePaste);
pm.add(jMenuMouseDel);
//转动条控件
JScrollPanescroller=newJScrollPane();
JViewportport=scroller.getViewport();
contentPane.add("Center",scroller);
contentPane.add("North",toolBar);
port.add(jTextArea1);
this.setJMenuBar(jMenuBar1);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//增加菜单中的监听器
jTextArea1.addMouseListener(this);
File_new_actionAdapterfnew=newFile_new_actionAdapter();
jMenuFileNew.addActionListener(fnew);
button1.addActionListener(fnew);
File_open_actionAdapterfopen=newFile_open_actionAdapter();
jMenuFileOpen.addActionListener(fopen);
button2.addActionListener(fopen);
File_save_actionAdapterfsave=newFile_save_actionAdapter();
jMenuFileSave.addActionListener(fsave);
button3.addActionListener(fsave);
File_saveto_actionAdapterfsaveto=newFile_saveto_actionAdapter();
jMenuFileSaveTo.addActionListener(fsaveto);
File_close_actionAdapterfclose=newFile_close_actionAdapter();
jMenuFileExit.addActionListener(fclose);
jMenuFileCut.addActionListener(this);
jMenuFileCopy.addActionListener(this);
jMenuFilePaste.addActionListener(this);
jMenuFileDel.addActionListener(this);
//鼠标事务
jMenuMouseCut.addActionListener(this);
jMenuMouseCopy.addActionListener(this);
jMenuMousePaste.addActionListener(this);
jMenuMouseDel.addActionListener(this);
jMenuFileFindNext.addActionListener(this);
jMenuFileSelect.addActionListener(this);
jMenuFileTime.addActionListener(this);
jMenuFileFont.addActionListener(this);
//jMenuFileLine.addActionListener(this);
jMenuCheckBox.addActionListener(this);
jcolor.addActionListener(this);
jMenuHelpAbout.addActionListener(this);
show();
validate();
}
Java到底会发战成什么样,让我们拭目以待吧,我始终坚信着java会更好。以上都是俺个人看法,欢迎大家一起交流. |
|