Java Implementation Notepad Java Notepad source code and implementation __swing

Source: Internet
Author: User

Today to introduce you about how to implement Notepad in Java, is a very good case of learning Java Swing, the following first look at the results of the operation (download the address below):


Here we look at the source code:

[java]  View Plain  copy  import java.awt.*;    import java.awt.event.*;     import java.text.*;    import java.util.*;    import  java.io.*;    import javax.swing.undo.*;    import  javax.swing.border.*;    import javax.swing.*;    import  javax.swing.text.*;    import javax.swing.event.*;   import  java.awt.datatransfer.*;         public class notepad extends  jframe implements actionlistener,documentlistener   {   //Menu        JMenu fileMenu,editMenu,formatMenu,viewMenu,helpMenu;        //Right-click Popup        JPopupMenu popupMenu;        jmenuitem popupmenu_undo,popupmenu_cut,popupmenu_copy,popupmenu_paste,popupmenu_delete,popupmenu_selectall;       / /"File" menu items        jmenuitem filemenu_new,filemenu_open,filemenu_save,filemenu_ saveas,filemenu_pagesetup,filemenu_print,filemenu_exit;       //"Edit" menu item         jmenuitem editmenu_undo,editmenu_cut,editmenu_copy,editmenu_paste,editmenu_ Delete,editmenu_find,editmenu_findnext,editmenu_replace,editmenu_goto,editmenu_selectall,editmenu_timedate;        //"format" menu items        JCheckBoxMenuItem  formatmenu_linewrap;       JMenuItem formatMenu_Font;        //"View" menu items        JCheckBoxMenuItem viewMenu_Status;        //"Help" menu items        jmenuitem helpmenu_helptopics , helpmenu_aboutnotepad;       //"text" Edit area        JTextArea  editarea;       //status bar label        JLabel  statuslabel;       //system Clipboard        Toolkit  Toolkit=toolkit.getdefaulttoolkit ();       clipboard clipboard= Toolkit.getsystemclipboard ();       //Create the Undo Operation Manager (related to the undo operation)         protected undomanager undo=new undomanager ();        Protected undoableeditlistener undohandler=new undohandler ();        //Other variables        string oldvalue;//store the original contents of the edit area to compare the text for changes

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.