java记事本毕业论文(求一个关于JAVA的论文)

1.求一个关于JAVA的论文

目 录一、概要设计……………………………………………………………3二、程序整体设计说明…………………………………………….…..4三、程序部分源代码及注释…………………………………………….9四、测试结果………………………………………………………….24五、设计心得…………………………………………………………25六、致 谢…………………………………………………………25七、参考文献…………………………………………………………25【摘 要】该程序是一个图形界面的java文档编辑器,其界面主要采用了awt包, 程序实现了文本编辑器的基本功能有:新建文件、打开文件、文件保存、文件另存为、剪切、复制、粘贴、删除、查找/替换、改变字体大小,另外还利用Time类的schedule方法实现了文件的定时自动更新功能,并创建备份文件,由于该编辑器是用的awt包,所以在技术上没有实现将Java的关键字以不同颜色显示功能。

【关键字】java 编辑器一、概要设计Java程序编辑器是:图形界面、线程、流与文件等技术的综合应用。图形界面的实现:考虑到简单、实用、高效等特点,就选择了AWT来完成实现,在选择组件上,文本编辑区就选用了TaxtArea作为主要的部件。

线程实现文件自动保存:在相关的参考书上查阅到在Time类中有一个schedule方法可以在后台自动完成一定的功能,而且调用起来相当简单,于是就用了Time类中的schedule方法来实现文件自动保存及备份功能。文件操作的实现:利用了字符文件流FileReader和FileWriter类来实现。

由于Java的特性,可能用任何一个编辑器来编辑,于是就将Windows中的记事本作为模仿对象,根据实现情况删减了其中的一些功能,如自动换行,设置字体,打印等功能。在设计类的时候,考虑到简单明了,就用了两个类,一个主类和一个默认属性类作为程序的整体框架,所有的对象和方法都是在默认属性类中创建和实现的,以及为各组件注册事件监听程序也是在默认属性类中实现的。

主类完成对象的实例化及显示。这们设计的优点是:条理清晰,容易理解,容易修改。

这样设计的缺点是:不利于共享类中的方法。二、程序整体设计说明2.1、程序框架图2.2、程序中所用类说明(1)用户自定义类类名:EditInstantiation作用:实例化对象继承的父类:WindowAdapter主要成员变量:Frame myFrm // 定义主窗体TextArea myText // 定义文本编辑区Dialog myDlgFind,myDlgFindont //查找及设置字体对话框TextField TFfind, TFreplace, TffontSize//查找对话框和字体窗体中的文本行Button BfontOK, Bfind, Breplace, Bnext, Bcancel //定义和创建各按钮Label Lf, Lr, Ls //定义和创建各标签MenuBar Mbbar //定义和创建主菜单Menu Mfile,Medit,Mformation,Mhelp //定义和创建主菜单中的选项Toolkit toolKitClipboard myCB //剪切板对象FileDialog myFDlg //定义文件对话框Choice ChfontName //定义和创建字体选择框private int VIindex = 1; //构成文件名后缀变量private String VSsubFixStr=".java"; //构成文件名扩展名变量private String VSmyFileName = "Document1",VSmyBFileName;//文件名及备份文件名变量private File VFmyFile=new File(VSmyFileName+VIindex+".java");//文件名变量private int VIsearchPosition=0; //查找位置指针private Timer VTtime; //实例化一个Time类private int VImin=1; // schedule方法中的一个时间参数private int VItype=JOptionPane.INFORMATION_MESSAGE;//提示对话框类型private String VStitle; //提示对话框标题private String VSmessage; //提示对话框信息private boolean VBchanged = true; //改变字体的一个标识private int VIfontSizeMin = 8, VIfontSizeMax = 40, VIfontSizeChangedStep = 2; //设置字体大小及步长主要成员方法:public void init() //初始化各部件菜单的定义和事件的监听public void displayEdit ()//显示窗体及调用Time中的schedule方法public void windowClosing () //关闭窗体public void save //保存文件方法a.内部类类名:KeyEvents作用:实现菜单的事件的响应功能继承的父类:KeyAdapter主要成员变量:无成员方法:actionPerformed()、keyPressed()b.内部类类名:FindKeyEvent作用:实现查找中各部件事件的响应功能继承的父类:无主要成员变量:无成员方法:actionPerformed ()c.内部类类名:fontEvent作用:实现字体中各部件事件的响应功能继承的父类:无主要成员变量:无成员方法:ItemListener(),ActionListener()(2)用户自定义类与Java类的继承关系图如下:自定义类 Java 类线程使用说明2.3、实现接口方法本程序用到的方法有:schedule其方法描述如下:schedule(事件,启动时间,间隔时间);2.4、线程应用本程序为文本编辑器,为实现自动更新,应用到了线程,每隔1分钟对文件进行自动更新2.5、异常处理说明(1)打开文件时的异常处理需要处理的异常:IOException处理方法:捕获异常后,显示捕获的异常(2)保存文件时的异常处理需要处理的异常:IOException处理方法:捕获异常后,显示捕获的异常2.6、程序运。

基于android记事本毕业论文,Java毕业论文,JAVA记事本

2.java编写的记事本开发文档如何写我们用Java编写了一个记事本 爱问知

class Pop_undo_actionAdapter implements Java。

awt。event。

ActionListener{ Jsb adaptee; Pop_undo_actionAdapter(Jsb adaptee){ this。 adaptee=adaptee; } public void actionPerformed(ActionEvent e){ adaptee。

pop_undo_actionPerformed(e); } } class Pop_cut_actionAdapter implements java。 awt。

event。ActionListener{ Jsb adaptee; Pop_cut_actionAdapter(Jsb adaptee){ this。

adaptee=adaptee; } public void actionPerformed(ActionEvent e){ adaptee。 pop_cut_actionPerformed(e); } } class Pop_copy_actionAdapter implements java。

awt。event。

ActionListener{ Jsb adaptee; Pop_copy_actionAdapter(Jsb adaptee){ this。 adaptee=adaptee; } public void actionPerformed(ActionEvent e){ adaptee。

pop_copy_acionPerformed(e); } } class Pop_paste_actionAdapter implements java。 awt。

event。ActionListener{ Jsb adaptee; Pop_paste_actionAdapter(Jsb adaptee){ this。

adaptee=adaptee; } public void actionPerformed(ActionEvent e){ adaptee。 pop_paste_actionPerformed(e); } } class Pop_delete_actionAdapter implements java。

awt。event。

ActionListener{ Jsb adaptee; Pop_delete_actionAdapter(Jsb adaptee){ this。 adaptee=adaptee; } public void actionPerformed(ActionEvent e){ adaptee。

pop_delete_actionPerformed(e); } } /******************* Event class end **********************************/ /************************************************************* * title: DlgText。 java * author: jeason * date: 2004-12-21 **************************************************************/ package jeason; import java。

awt。*; import java。

awt。event。

*; import javax。swing。

*; public class Dlgtext extends JDialog{ private boolean check=false; JLabel text=new JLabel( ); JButton BTnOk=new JButton( ); JButton btnNo=new JButton( ); FlowLayout flowLayout1=new FlowLayout(); Dlgtext(){ this(null,"",false); } Dlgtext(Frame frame, String title, boolean modal){ super(frame,title,modal); text。 setText(" 你要保存吗? "); text。

setSize(200,60); this。setSize(200,80); this。

setModal(true); btnOk。setText("确定(Y)"); btnOk。

setMnemonic(´Y´);。

毕业论文,记事本,java

3.java的一个简单记事本程序设计

这个功能要全些!import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.dbswing.*;import java.io.*;import javax.swing.text.*;import javax.swing.event.*;/*** Title: * Description: * Copyright: Copyright (c) 2005* Company: * @author not attributable* @version 1.0*/public class Frame1 extends JFrame {JPanel contentPane;JMenuBar jMenuBar1 = new JMenuBar();JMenu jMenuFile = new JMenu();JMenuItem jMenuFileExit = new JMenuItem();JMenu jMenuHelp = new JMenu();JMenuItem jMenuHelpAbout = new JMenuItem();JLabel statusBar = new JLabel();BorderLayout borderLayout1 = new BorderLayout();JScrollPane jScrollPane1 = new JScrollPane();JTextArea jTextArea1 = new JTextArea();JMenu jMenu1 = new JMenu();JMenu jMenu2 = new JMenu();JMenuItem jMenuItem1 = new JMenuItem();JMenuItem jMenuItem2 = new JMenuItem();JMenuItem jMenuItem3 = new JMenuItem();JMenuItem jMenuItem4 = new JMenuItem();JMenuItem jMenuItem5 = new JMenuItem();JMenuItem jMenuItem6 = new JMenuItem();JMenuItem jMenuItem7 = new JMenuItem();JMenuItem jMenuItem9 = new JMenuItem();JMenuItem jMenuItem10 = new JMenuItem();JMenuItem jMenuItem11 = new JMenuItem();FontChooser fontChooser1 = new FontChooser();JCheckBoxMenuItem jCheckBoxMenuItem1 = new JCheckBoxMenuItem();JFileChooser jFileChooser1 = new JFileChooser();String currentFileName=null;boolean motified=false;Document document1;//Construct the framepublic Frame1() {enableEvents(AWTEvent.WINDOW_EVENT_MASK);try {jbInit();}catch(Exception e) {e.printStackTrace();}}//Component initializationprivate void jbInit() throws Exception {contentPane = (JPanel) this.getContentPane();document1 = jTextArea1.getDocument();contentPane.setLayout(borderLayout1);this.setSize(new Dimension(600, 400));this.setTitle("文本编辑器");statusBar.setText(" ");jMenuFile.setText("文件");jMenuFileExit.setText("退出");jMenuFileExit.addActionListener(new Frame1_jMenuFileExit_ActionAdapter(this));jMenuHelp.setText("帮助");jMenuHelpAbout.setText("关于");jMenuHelpAbout.addActionListener(new Frame1_jMenuHelpAbout_ActionAdapter(this));jTextArea1.setText("");jMenu1.setText("编辑");jMenu2.setText("格式");jMenuItem4.setText("新建");jMenuItem4.addActionListener(new Frame1_jMenuItem4_actionAdapter(this));jMenuItem3.setText("打开");jMenuItem3.addActionListener(new Frame1_jMenuItem3_actionAdapter(this));jMenuItem2.setText("保存");jMenuItem2.addActionListener(new Frame1_jMenuItem2_actionAdapter(this));jMenuItem1.setText("另存为");jMenuItem1.addActionListener(new Frame1_jMenuItem1_actionAdapter(this));jMenuItem5.setText("剪切");jMenuItem5.addActionListener(new Frame1_jMenuItem5_actionAdapter(this));jMenuItem6.setText("复制");jMenuItem6.addActionListener(new Frame1_jMenuItem6_actionAdapter(this));jMenuItem7.setText("粘贴");jMenuItem7.addActionListener(new Frame1_jMenuItem7_actionAdapter(this));jMenuItem9.setText("字体");jMenuItem9.addActionListener(new Frame1_jMenuItem9_actionAdapter(this));jMenuItem10.setText("前景色");jMenuItem10.addActionListener(new Frame1_jMenuItem10_actionAdapter(this));jMenuItem11.setText("背景色");fontChooser1.setFrame(this);fontChooser1.setTitle("字体");jCheckBoxMenuItem1.setText("自动换行");jCheckBoxMenuItem1.addActionListener(new Frame1_jCheckBoxMenuItem1_actionAdapter(this));document1.addDocumentListener(new Frame1_document1_documentAdapter(this));jMenuFile.add(jMenuItem4);jMenuFile.add(jMenuItem3);jMenuFile.add(jMenuItem2);jMenuFile.add(jMenuItem1);jMenuFile.addSeparator();jMenuFile.add(jMenuFileExit);jMenuHelp.add(jMenuHelpAbout);jMenuBar1.add(jMenuFile);jMenuBar1.add(jMenu1);jMenuBar1.add(jMenu2);jMenuBar1.add(jMenuHelp);this.setJMenuBar(jMenuBar1);contentPane.add(statusBar, BorderLayout.SOUTH);contentPane.add(jScrollPane1, BorderLayout.CENTER);jScrollPane1.getViewport().add(jTextArea1, null);jMenu1.add(jMenuItem5);jMenu1.add(jMenuItem6);jMenu1.add(jMenuItem7);jMenu2.add(jCheckBoxMenuItem1);jMenu2.add(jMenuItem9);jMenu2.add(jMenuItem10);jMenu2.add(jMenuItem11);}//File | Exit action performedpublic void jMenuFileExit_actionPerformed(ActionEvent e) {if(giveUp())System.exit(0);}//Help | About action performedpublic void jMenuHelpAbout_actionPerformed(ActionEvent e) {Frame1_AboutBox dlg = new Frame1_AboutBox(this);。

4.如何用JAVA程序编写一个记事本

import java.io.*; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.undo.CannotRedoException; import javax.swing.undo.UndoManager; import java.util.Date; import java.text.SimpleDateFormat; public class Notepad extends JFrame { // 菜单 JMenuBar menub = new JMenuBar(); // 显示纯文本的多行区域 JTextArea text = new JTextArea(); JMenu files = new JMenu("文件(F)"); JMenu edit = new JMenu("编辑(E)"); JMenu formats = new JMenu("格式(O)"); JMenu help = new JMenu("帮助(H)"); JMenuItem newFile = new JMenuItem("新建(N)"); JMenuItem open = new JMenuItem("打开(O)"); JMenuItem save = new JMenuItem("保存(S)"); JMenuItem saveAs = new JMenuItem("另存为(A)"); JMenuItem exit = new JMenuItem("退出(X)"); JMenuItem undo = new JMenuItem("撤销(U)"); JMenuItem cut = new JMenuItem("剪切(T)"); JMenuItem copy = new JMenuItem("复制(C)"); JMenuItem paste = new JMenuItem("粘贴(P)"); JMenuItem selectAll = new JMenuItem("全选(A)"); JMenuItem timeDate = new JMenuItem("时间/日期(D)"); JCheckBoxMenuItem lineWrap = new JCheckBoxMenuItem("自动换行(M)"); JMenuItem fonts = new JMenuItem("字体"); JMenuItem about = new JMenuItem("关于记事本(A)"); JFrame th = this; String name; String openedPath = null; boolean opened = false; boolean reworked = false; UndoManager undoManager = new UndoManager(); // 初始化窗体 public Notepad(String name) { super(name); this.name = name; int x, y; // 得到用户屏幕大小 Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); x = (size.width - 600) / 2; y = (size.height - 400) / 2; setSize(600, 400); // 让程序界面显示在屏幕中央 setLocation(x, y); // 将此窗口的最小大小设置为一个常量值。

setMinimumSize(new Dimension(250, 150)); (EXIT_ON_CLOSE); } // 初始化布局 void init() { files.setMnemonic('F'); edit.setMnemonic('E'); formats.setMnemonic('O'); help.setMnemonic('H'); newFile.setMnemonic('N'); open.setMnemonic('O'); save.setMnemonic('S'); saveAs.setMnemonic('A'); exit.setMnemonic('X'); undo.setMnemonic('U'); cut.setMnemonic('T'); copy.setMnemonic('C'); paste.setMnemonic('P'); selectAll.setMnemonic('A'); timeDate.setMnemonic('D'); lineWrap.setMnemonic('M'); about.setMnemonic('A'); // 为控件添加助记符 newFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK)); open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK)); exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, InputEvent.CTRL_MASK)); cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_MASK)); copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK)); paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_MASK)); selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK)); // 为控件添加快捷键 timeDate.setAccelerator(KeyStroke.getKeyStroke("F5")); files.add(newFile); files.add(open); files.add(save); files.add(saveAs); files.addSeparator(); files.add(exit); edit.add(undo); edit.addSeparator(); edit.add(cut); edit.add(copy); edit.add(paste); edit.addSeparator(); edit.add(selectAll); edit.add(timeDate); formats.add(lineWrap); formats.add(fonts); help.add(about); menub.add(files); menub.add(edit); menub.add(formats); menub.add(help); setJMenuBar(menub); getContentPane().add(new JScrollPane(text)); Listen listen = new Listen(); Listen1 listen1 = new Listen1(); // 为控件添加事件侦听器 newFile.addActionListener(listen); undo.addActionListener(listen); open.addActionListener(listen); save.addActionListener(listen); saveAs.addActionListener(listen); exit.addActionListener(listen); cut.addActionListener(listen); copy.addActionListener(listen); paste.addActionListener(listen); selectAll.addActionListener(listen); timeDate.addActionListener(listen); lineWrap.addActionListener(listen); about.addActionListener(listen); open.addActionListener(listen1); save.addActionListener(listen1); saveAs.addActionListener(listen1); // 暂时没有实现的功能 :设置字体 //undo功能没有实现 fonts.setEnabled(false); } class Listen implements ActionListener { // 实现用于一般操作的事件侦听器 public void actionPerformed(ActionEvent e) { Object source = e.getSource(); if (。

5.java编写简单的记事本程序

给你个做好了的Java的源程序的记事本,自己看看就行了的,不怎么难的···文件名 MyNotepad .javaimport java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*;public class MyNotepad implements ActionListener{ private JFrame frame=new JFrame("新记事本"); private JTextArea jta=new JTextArea(); private String result=""; private boolean flag=true; private File f; private JButton jb=new JButton("开始"); private JTextField jtf=new JTextField(15); private JTextField jt=new JTextField(15); private JButton jbt=new JButton("替换为"); private JButton jba=new JButton("全部替换"); private Icon ic=new ImageIcon("D:\\java课堂笔记\\GUI\\11.gif"); private String value; private int start=0; private JFrame jf=new JFrame("查找"); private JFrame jfc=new JFrame("替换"); @Override public void actionPerformed(ActionEvent e) { String comm=e.getActionCommand(); if("新建".equals(comm)){ if(!(frame.getTitle().equals("新记事本"))){ if(!flag){ write(); newNew(); }else{ JFileChooser jfc=new JFileChooser("D:\\java课堂笔记"); int returnVal = jfc.showDialog(null,"保存为"); if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性 f=jfc.getSelectedFile(); flag=false; write(); } } }else if(!(jta.getText().isEmpty())){ JFileChooser jfc=new JFileChooser("D:\\java课堂笔记"); int returnVal = jfc.showDialog(null,"保存为"); if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性 f=jfc.getSelectedFile(); flag=false; write(); newNew(); } }else{ newNew(); } }else if("打开".equals(comm)){ JFileChooser jfc=new JFileChooser("D:\\java课堂笔记"); jfc.setDialogType(JFileChooser.OPEN_DIALOG); int returnVal = jfc.showOpenDialog(null); if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性 f=jfc.getSelectedFile(); frame.setTitle(f.getName()); result=read(); flag=false; value=result; jta.setText(result); } }else if("保存".equals(comm)){ JFileChooser jfc=new JFileChooser("D:\\java课堂笔记"); if(flag){ int returnVal = jfc.showDialog(null,"保存为"); if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性 f=jfc.getSelectedFile(); flag=false; write(); } }else{ write(); } }else if("另存".equals(comm)){ JFileChooser jfc=new JFileChooser("D:\\java课堂笔记"); int returnVal = jfc.showDialog(null,"另存"); if(returnVal == JFileChooser.APPROVE_OPTION) {//选择文件后再执行下面的语句,保证了程序的健壮性 f=jfc.getSelectedFile(); write(); } }else if("退出".equals(comm)){ System.exit(0); }else if("撤销".equals(comm)){ jta.setText(value); }else if("剪切".equals(comm)){ value=jta.getText(); jta.cut(); }else if("复制".equals(comm)){ jta.copy(); }else if("粘贴".equals(comm)){ value=jta.getText(); jta.paste(); }else if("删除".equals(comm)){ value=jta.getText(); jta.replaceSelection(null); }else if("全选".equals(comm)){ jta.selectAll(); }else if("查找".equals(comm)){ value=jta.getText(); jf.add(jtf,BorderLayout.CENTER); jf.add(jb,BorderLayout.SOUTH); jf.setLocation(300,300); jf.pack(); jf.setVisible(true); jf.(JFrame.DISPOSE_ON_CLOSE); }else if("替换".equals(comm)){ value=jta.getText(); GridLayout gl=new GridLayout(3,3); JLabel jl1=new JLabel("查找内容:"); JLabel jl2=new JLabel("替换为:"); jfc.setLayout(gl); jfc.add(jl1); jfc.add(jtf); jfc.add(jb); jfc.add(jl2); jfc.add(jt); jfc.add(jbt); JLabel jl3=new JLabel(); JLabel jl4=new JLabel(); jfc.add(jl3); jfc.add(jl4); jfc.add(jba); jfc.setLocation(300,300); jfc.pack(); jfc.setVisible(true); jfc.(JFrame.DISPOSE_ON_CLOSE); }else if("版本".equals(comm)){ JDialog jd=new JDialog(frame,"关于对话框"); jd.setSize(200,200); JLabel l=new JLabel("哈哈哈哈哈哈哈哈哈哈呵呵呵呵呵呵呵呵呵呵呵呵呵"); jd.add(l,BorderLayout.CENTER); jd.setLocation(100,200); jd.setSize(300,300); jd.setVisible(true);// jd.pack(); jd.(JDialog.DISPOSE_ON_CLOSE); }else if("开始".equals(comm)||"下一个".equals(comm)){ String temp=jtf.getText(); int s=value.indexOf(temp,start); if(value.indexOf。

6.java程序设计实训报告

简单的计算器编程 import java.awt.*;import java.awt.event.*;import javax.swing.*;public class Calculator{ public static void main(String[] args) { CalculatorFrame frame = new CalculatorFrame(); frame.(JFrame.EXIT_ON_CLOSE); frame.show(); }}/** A frame with a calculator panel.*/class CalculatorFrame extends JFrame{ public CalculatorFrame() { setTitle("Calculator"); Container contentPane = getContentPane(); CalculatorPanel panel = new CalculatorPanel(); contentPane.add(panel); pack(); }}/** A panel with calculator buttons and a result display.*/class CalculatorPanel extends JPanel{ public CalculatorPanel() { setLayout(new BorderLayout()); result = 0; lastCommand = "="; start = true; // add the display display = new JLabel("0"); add(display, BorderLayout.NORTH); ActionListener insert = new InsertAction(); ActionListener command = new CommandAction(); // add the buttons in a 4 x 4 grid panel = new JPanel(); panel.setLayout(new GridLayout(4, 4)); addButton("7", insert); addButton("8", insert); addButton("9", insert); addButton("/", command); addButton("4", insert); addButton("5", insert); addButton("6", insert); addButton("*", command); addButton("1", insert); addButton("2", insert); addButton("3", insert); addButton("-", command); addButton("0", insert); addButton(".", insert); addButton("=", command); addButton("+", command); add(panel, BorderLayout.CENTER); } /** Adds a button to the center panel. @param label the button label @param listener the button listener */ private void addButton(String label, ActionListener listener) { JButton button = new JButton(label); button.addActionListener(listener); panel.add(button); } /** This action inserts the button action string to the end of the display text. */ private class InsertAction implements ActionListener { public void actionPerformed(ActionEvent event) { String input = event.getActionCommand(); if (start) { display.setText(""); start = false; } display.setText(display.getText() + input); } } /** This action executes the command that the button action string denotes. */ private class CommandAction implements ActionListener { public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); if (start) { if (command.equals("-")) { display.setText(command); start = false; } else lastCommand = command; } else { calculate(Double.parseDouble(display.getText())); lastCommand = command; start = true; } } } /** Carries out the pending calculation. @param x the value to be accumulated with the prior result. */ public void calculate(double x) { if (lastCommand.equals("+")) result += x; else if (lastCommand.equals("-")) result -= x; else if (lastCommand.equals("*")) result *= x; else if (lastCommand.equals("/")) result /= x; else if (lastCommand.equals("=")) result = x; display.setText("" + result); } private JLabel display; private JPanel panel; private double result; private String lastCommand; private boolean start;} 采用 啊。

7.怎样用java编写一个记事本 ,具体步骤

import java.awt.BorderLayout; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JDialog; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTextPane; import javax.swing.JToolBar; public class TextEditorFrame extends JFrame { File file = null; Color color = Color.red; TextEditorFrame() { initTextPane(); initAboutDialog(); initToolBar(); initMenu(); } void initTextPane() { getContentPane().add(new JScrollPane(text)); } JTextPane text = new JTextPane(); // 这是用来做文本框的 JFileChooser filechooser = new JFileChooser(); // 文件选择框 JColorChooser colorchooser = new JColorChooser();// JDialog about = new JDialog(this); // 关于对话框 JMenuBar menubar = new JMenuBar();// 菜单 JMenu[] menus = new JMenu[] { new JMenu("文件"), new JMenu("编辑"), new JMenu("帮助") }; JMenuItem menuitems[][] = new JMenuItem[][] { { new JMenuItem("新建"), new JMenuItem("打开"), new JMenuItem("保存"), new JMenuItem("退出") }, {new JMenuItem("复制"), new JMenuItem("剪切"), new JMenuItem("粘贴"), new JMenuItem("颜色") }, { new JMenuItem("关于") } }; void initMenu() { for (int i = 0; i < menus.length; i++) { menubar.add(menus[i]); for (int j = 0; j < menuitems[i].length; j++) { menus[i].add(menuitems[i][j]); menuitems[i][j].addActionListener(action); } } this.setJMenuBar(menubar); } ActionListener action = new ActionListener() { // when here have not wrong: public void actionPerformed(ActionEvent e) { JMenuItem mi = (JMenuItem) e.getSource(); String id = mi.getText(); if (id.equals("新建")) { text.setText(""); file = null; } else if (id.equals("打开")) { if (file != null) filechooser.setSelectedFile(file); int returnVal = filechooser .showOpenDialog(TextEditorFrame.this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = filechooser.getSelectedFile(); openFile(); } } else if (id.equals("保存")) { if (file != null) filechooser.setSelectedFile(file); int returnVal = filechooser .showSaveDialog(TextEditorFrame.this); if (returnVal == JFileChooser.APPROVE_OPTION) { file = filechooser.getSelectedFile(); saveFile(); } } else if (id.equals("退出")) { TextEditorFrame f = new TextEditorFrame(); int s = JOptionPane.showConfirmDialog(f, "你真的要结束吗", "结束程序", JOptionPane.YES_NO_CANCEL_OPTION); if (s == JOptionPane.YES_OPTION) System.exit(0); } else if (id.equals("剪切")) { text.cut(); } else if (id.equals("复制")) { text.copy(); } else if (id.equals("粘贴")) { text.paste(); } else if (id.equals("color")) { color = JColorChooser.showDialog(TextEditorFrame.this, "", color); text.setForeground(color); } else if (id.equals("关于")) { about.setSize(200, 150); about.show(); } } }; void saveFile() { try { FileWriter fw = new FileWriter(file); fw.write(text.getText()); fw.close(); } catch (Exception e) { e.printStackTrace(); } } void openFile() { try { FileReader fr = new FileReader(file); int len = (int) file.length(); char[] buffer = new char[len]; fr.read(buffer, 0, len); fr.close(); text.setText(new String(buffer)); } catch (Exception e) { e.printStackTrace(); } } void initAboutDialog() { about.getContentPane().add(new JLabel("作者-覃树新:记事本Q1.0版本")); about.setModal(true); about.setSize(200, 100); } JToolBar toolbar = new JToolBar();// 我来加上工具条 JButton[] buttons = new JButton[] { new JButton("", new ImageIcon("qin.jpg")), new JButton("", new ImageIcon("shu.jpg")), new JButton("", new ImageIcon("xin.jpg")) }; void initToolBar() { for (int i = 0; i < buttons.length; i++) toolbar.add(buttons[i]); buttons[0].setToolTipText("复制"); buttons[0].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { text.copy(); } }); buttons[1].setToolTipText("剪切"); buttons[1].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { text.cut(); } }); buttons[2].setToolTipText("粘贴"); buttons[2].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { text.paste(); } }); this.getContentPane().add(toolbar, BorderLayout.NORTH); } public static void main(。

java记事本毕业论文

转载请注明出处众文网 » java记事本毕业论文(求一个关于JAVA的论文)

资讯

毕业论文任务书百度(毕业论文任务书怎么写)

阅读(45)

本文主要为您介绍毕业论文任务书百度,内容包括毕业论文任务书怎么写,毕业论文任务书主要内容,毕业论文任务书论文的主要内容怎么写。论文任务书怎么写课题的内容和要求课题内容:主要写作课题目的意义,用简洁、概括性的语言来表达课题的内容;课

资讯

毕业论文开题报告评定表(论文开题报告表格式)

阅读(72)

本文主要为您介绍毕业论文开题报告评定表,内容包括论文开题报告表格式,谁能给我个开题报告范文?,自动化毕业论文开题报告表。论文题目(小二号黑体加粗,居中)国贸0509(05730336)郝雪文(四号黑体,居中)1 研究背景(小二号黑体,居中,段前距1行)1.

资讯

毕业论文壮族敬酒歌(壮族歌圩论文怎样写!拜托各位了3Q)

阅读(66)

本文主要为您介绍毕业论文壮族敬酒歌,内容包括壮族敬客人酒的风俗是什么?,壮族迎客歌歌词,壮族敬酒山歌对唱。在壮乡,民歌无处不在。妊娠时胎教唱“怀胎歌”,出生时接生婆唱“接生歌”,满月有“满月歌”,外婆送背带时唱的是“背带歌”,成人后唱

资讯

毕业论文课程意义(写毕业论文的目的与意义)

阅读(50)

本文主要为您介绍毕业论文课程意义,内容包括写毕业论文的目的与意义,毕业论文指导课的意义等?,论文的目的与意义。撰写毕业论文是检验学生在校学习成果的重要措施,也是提高教学质量的重要环节。大学生在毕业前都必须完成毕业论文的撰写任务

资讯

毕业论文没过会怎样(论文不过能拿毕业证吗)

阅读(50)

本文主要为您介绍毕业论文没过会怎样,内容包括毕业论文不合格有什么后果,大学毕业论文通不过有什么后果?,如果毕业论文不合格,会有什么后果?。论文答辩不过能毕业,但是毕业论文答辩没过不能拿到毕业证的,不过一般答辩有两次机会的,最后一次通

资讯

毕业论文调查问卷最少多少(调查问卷至少需要多少份才算有效)

阅读(85)

本文主要为您介绍毕业论文调查问卷最少多少,内容包括毕业论文调查问卷的数量一般是多少???,毕业论文调查问卷一般多少问题合适,毕业论文一般发放多少问卷调查才算是合理的啊?。没有固定的数量,要看回收率有多少,达到百分之90的回收率就可以了

资讯

毕业论文能否提前发表(论文提前发表的好处)

阅读(59)

本文主要为您介绍毕业论文能否提前发表,内容包括论文提前发表的好处,论文有什么理由可以提前发表?,我能提前写毕业论文吗?。论文提前发表的好处:提前一年发表更有说服力。2、评职时会加2-3分的印象分。3、出刊后上期刊网,网站上点击率高也会

资讯

毕业论文数字密码锁(急求题目为:“数字密码锁设计”的论文)

阅读(78)

本文主要为您介绍毕业论文数字密码锁,内容包括急求题目为:“数字密码锁设计”的论文,大神们,我毕业论文做的是单片机电子密码锁,结果老师让说明怎样,电子密码锁设计论文。电子密码锁摘要 本文的电子密码锁利用数字逻辑电路,实现对门的电子控

资讯

毕业论文问卷设计(如何将调查问卷放入毕业论文)

阅读(48)

本文主要为您介绍毕业论文问卷设计,内容包括论文设计问卷是啥呢,想写调查问卷型的毕业论文,有关人力资源的,该怎么设计问卷?,毕业论文需要用到调查问卷,我想问,我可以用别人毕业论文中的问卷。一般都是放在文章末尾的附录的,没有强制规定。

资讯

毕业论文如何调查数据(毕业论文没有调查数据怎么办?)

阅读(53)

本文主要为您介绍毕业论文如何调查数据,内容包括毕业论文中引用别人的调查数据应该怎样标明,毕业论文没有调查数据怎么办?,本科论文的数据分析怎么做?相关性分析,假设检验,回归分析需要那。毕业论文没有调查数据,则会导致论文内容的不严谨。

资讯

毕业论文实验试剂表格(学术论文中插入表格的格式是怎样的)

阅读(53)

本文主要为您介绍毕业论文实验试剂表格,内容包括论文中仪器试剂表格怎么写,毕业论文附录格式??详细,请回答下列问题.试管组别实验处理加入3%H2O2(mL)温度加入试剂试。学术论文中插入表格的格式是一律使用三线表(不划竖线),五号字,汉字宋体。三

资讯

毕业论文任务书百度(毕业论文任务书怎么写)

阅读(45)

本文主要为您介绍毕业论文任务书百度,内容包括毕业论文任务书怎么写,毕业论文任务书主要内容,毕业论文任务书论文的主要内容怎么写。论文任务书怎么写课题的内容和要求课题内容:主要写作课题目的意义,用简洁、概括性的语言来表达课题的内容;课

资讯

毕业论文开题报告评定表(论文开题报告表格式)

阅读(72)

本文主要为您介绍毕业论文开题报告评定表,内容包括论文开题报告表格式,谁能给我个开题报告范文?,自动化毕业论文开题报告表。论文题目(小二号黑体加粗,居中)国贸0509(05730336)郝雪文(四号黑体,居中)1 研究背景(小二号黑体,居中,段前距1行)1.

资讯

毕业论文壮族敬酒歌(壮族歌圩论文怎样写!拜托各位了3Q)

阅读(66)

本文主要为您介绍毕业论文壮族敬酒歌,内容包括壮族敬客人酒的风俗是什么?,壮族迎客歌歌词,壮族敬酒山歌对唱。在壮乡,民歌无处不在。妊娠时胎教唱“怀胎歌”,出生时接生婆唱“接生歌”,满月有“满月歌”,外婆送背带时唱的是“背带歌”,成人后唱

资讯

毕业论文课程意义(写毕业论文的目的与意义)

阅读(50)

本文主要为您介绍毕业论文课程意义,内容包括写毕业论文的目的与意义,毕业论文指导课的意义等?,论文的目的与意义。撰写毕业论文是检验学生在校学习成果的重要措施,也是提高教学质量的重要环节。大学生在毕业前都必须完成毕业论文的撰写任务

资讯

毕业论文答辩模板百度云(韩国拍卖会的成交率有多少?)

阅读(58)

本文主要为您介绍毕业论文答辩模板百度云,内容包括<pclass="MsoNormal">吃哪些感冒药不影响乳汁的?,<pclass="MsoNormal">小腿操产后新妈妈美腿操小?,毕业论文答辩ppt模板怎么下载?。主要看什么拍卖行拍卖。有名气的拍卖机构才能保证成交率