Java开发记事本(完整版)

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

右键菜单图打印图设置背景颜色、字体样式、字体颜色图行号!主要代码packagecom.sxt.nodepad.view;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Component;importjava.awt.Container;importjava.awt.Dimension;importjava.awt.Event;importjava.awt.EventQueue;importjava.awt.FlowLayout;importjava.awt.Font;importjava.awt.Graphics;importjava.awt.GridLayout;importjava.awt.PrintJob;importjava.awt.datatransfer.Clipboard;importjava.awt.datatransfer.DataFlavor;importjava.awt.datatransfer.StringSelection;importjava.awt.datatransfer.Transferable;importjava.awt.datatransfer.UnsupportedFlavorException;importjava.awt.event.ActionEvent;importjava.awt.event.ActionListener;importjava.awt.event.InputEvent;importjava.awt.event.KeyAdapter;importjava.awt.event.KeyEvent;importjava.awt.event.MouseAdapter;importjava.awt.event.MouseEvent;importjava.awt.event.WindowAdapter;importjava.awt.event.WindowEvent;importjava.awt.print.PageFormat;importjava.awt.print.PrinterJob;importjava.io.BufferedReader;importjava.io.File;importjava.io.FileInputStream;importjava.io.FileNotFoundException;importjava.io.FileWriter;importjava.io.IOException;importjava.io.InputStreamReader;importjava.util.Calendar;importjava.util.GregorianCalendar;importjavax.swing.BorderFactory;importjavax.swing.ButtonGroup;importjavax.swing.JButton;importjavax.swing.JCheckBox;importjavax.swing.JCheckBoxMenuItem;importjavax.swing.JColorChooser;importjavax.swing.JDialog;importjavax.swing.JFileChooser;importjavax.swing.JFrame;importjavax.swing.JLabel;importjavax.swing.JMenu;importjavax.swing.JMenuBar;importjavax.swing.JMenuItem;importjavax.swing.JOptionPane;importjavax.swing.JPanel;importjavax.swing.JPopupMenu;importjavax.swing.JRadioButton;importjavax.swing.JScrollPane;importjavax.swing.JSeparator;importjavax.swing.JTextArea;importjavax.swing.JTextField;importjavax.swing.JToolBar;importjavax.swing.KeyStroke;importjavax.swing.UIManager;importjavax.swing.UnsupportedLookAndFeelException;importjavax.swing.border.EmptyBorder;importjavax.swing.event.CaretEvent;importjavax.swing.event.CaretListener;importjavax.swing.undo.UndoManager;importcom.sxt.nodepad.util.Clock;importcom.sxt.nodepad.util.MQFontChooser;importcom.sxt.nodepad.util.SystemParam;importcom.sxt.nodepad.util.TestLine;publicclassNotepadMainFrameextendsJFrameimplementsActionListener{/***序列号*/privatestaticfinallongserialVersionUID=8585210209467333480L;privateJPanelcontentPane;privateJTextAreatextArea;privateJMenuItemitemOpen;privateJMenuItemitemSave;//1:新建//2:修改过//3:保存过的intflag=0;//当前文件名StringcurrentFileName=null;PrintJobp=null;//声明一个要打印的对象Graphicsg=null;//要打印的对象//当前文件路径StringcurrentPath=null;//背景颜色JColorChooserjcc1=null;Colorcolor=Color.BLACK;//文本的行数和列数intlinenum=1;intcolumnnum=1;//撤销管理器publicUndoManagerundoMgr=newUndoManager();//剪贴板publicClipboardclipboard=newClipboard(系统剪切板);privateJMenuItemitemSaveAs;privateJMenuItemitemNew;privateJMenuItemitemPage;privateJSeparatorseparator;privateJMenuItemitemPrint;privateJMenuItemitemExit;privateJSeparatorseparator_1;privateJMenuitemEdit;privateJMenuitFormat;privateJMenuitemCheck;privateJMenuitemHelp;privateJMenuItemitemSearchForHelp;privateJMenuItemitemAboutNotepad;privateJMenuItemitemUndo;privateJMenuItemitemCut;privateJMenuItemitemCopy;privateJMenuItemitemPaste;privateJMenuItemitemDelete;privateJMenuItemitemFind;privateJMenuItemitemFindNext;privateJMenuItemitemReplace;privateJMenuItemitemTurnTo;privateJMenuItemitemSelectAll;privateJMenuItemitemTime;privateJMenuItemitemFont;privateJMenuItemitemColor;privateJMenuItemitemFontColor;privateJCheckBoxMenuItemitemNextLine;privateJScrollPanescrollPane;privateJCheckBoxMenuItemitemStatement;privateJToolBartoolState;publicstaticJLabellabel1;privateJLabellabel2;/***Launchtheapplication.*/publicstaticvoidmain(String[]args){EventQueue.invokeLater(newRunnable(){publicvoidrun(){try{NotepadMainFrameframe=newNotepadMainFrame();frame.setVisible(true);}catch(Exceptione){e.printStackTrace();}}});}GregorianCalendarc=newGregorianCalendar();inthour=c.get(Calendar.HOUR_OF_DAY);intmin=c.get(Calendar.MINUTE);intsecond=c.get(Calendar.SECOND);privateJPopupMenupopupMenu;privateJMenuItempopM_Undo;privateJMenuItempopM_Cut;privateJMenuItempopM_Copy;privateJMenuItempopM_Paste;privateJMenuItempopM_Delete;privateJMenuItempopM_SelectAll;privateJMenuItempopM_toLeft;privateJMenuItempopM_showUnicode;privateJMenuItempopM_closeIMe;privateJMenuItempopM_InsertUnicode;privateJMenuItempopM_RestartSelect;privateJSeparatorseparator_2;privateJSeparatorseparator_3;privateJSeparatorseparator_4;privateJSeparatorseparator_5;privateJMenuItemitemRedo;privateJSeparatorseparator_6;privateJSeparatorseparator_7;privateJSeparatorseparator_8;privateJMenuItempopM_Redo;/***Createtheframe.*/publicNotepadMainFrame(){try{UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}catch(ClassNotFoundExceptione1){e1.printStackTrace();}catch(InstantiationExceptione1){e1.printStackTrace();}catch(IllegalAccessExceptione1){e1.printStackTrace();}catch(UnsupportedLookAndFeelExceptione1){e1.printStackTrace();}setTitle(无标题);se

1 / 54
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功