⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 noneditabletextareadialog.java

📁 FuncPlotter is a combined Java application and applet for displaying two-dimensional plots of explic
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*====================================================================*\NonEditableTextAreaDialog.javaNon-editable text area dialog box class.------------------------------------------------------------------------This file is part of FuncPlotter, a combined Java application and appletfor plotting explicit functions in one variable.Copyright 2005-2007 Andy Morgan-Richards.FuncPlotter is free software: you can redistribute it and/or modify itunder the terms of the GNU General Public License as published by theFree Software Foundation, either version 3 of the License, or (at youroption) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public License alongwith this program.  If not, see <http://www.gnu.org/licenses/>.\*====================================================================*/// PACKAGEpackage gui;//----------------------------------------------------------------------// IMPORTSimport exception.AppException;import java.awt.Dialog;import java.awt.Dimension;import java.awt.FontMetrics;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.GridLayout;import java.awt.Insets;import java.awt.Point;import java.awt.Window;import java.awt.datatransfer.StringSelection;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.util.Hashtable;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JComponent;import javax.swing.JDialog;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.KeyStroke;import util.KeyAction;//----------------------------------------------------------------------// NON-EDITABLE TEXT AREA DIALOG BOX CLASSpublic class NonEditableTextAreaDialog    extends JDialog    implements ActionListener{//////////////////////////////////////////////////////////////////////////  Constants////////////////////////////////////////////////////////////////////////    private static final    String  CLEAR_STR           = "Clear";    private static final    String  COPY_STR            = "Copy";    private static final    String  CLOSE_STR           = "Close";    private static final    String  CLEAR_TOOL_TIP_STR  = "Clear text (Alt+X)";    private static final    String  COPY_TOOL_TIP_STR   = "Copy text to clipboard (Alt+C)";    private static final    String  CLIPBOARD_ERROR_STR = "Clipboard Error";    // Commands    private interface Command    {        String  CLEAR   = "clear";        String  COPY    = "copy";        String  CLOSE   = "close";    }    private static final    KeyAction.CommandMap[]  KEY_COMMANDS    =    {        new KeyAction.CommandMap( KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0 ),                                  Command.CLOSE )    };//////////////////////////////////////////////////////////////////////////  Enumeration types////////////////////////////////////////////////////////////////////////    // ERROR IDENTIFIERS    private enum ErrorId        implements AppException.Id    {    ////////////////////////////////////////////////////////////////////    //  Constants    ////////////////////////////////////////////////////////////////////        CLIPBOARD_UNAVAILABLE        ( "The clipboard is currently unavailable." );    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        private ErrorId( String message )        {            this.message = message;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance methods : AppException.Id interface    ////////////////////////////////////////////////////////////////////        public String getMessage( )        {            return message;        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance variables    ////////////////////////////////////////////////////////////////////        private String  message;    }    //==================================================================//////////////////////////////////////////////////////////////////////////  Member classes : inner classes////////////////////////////////////////////////////////////////////////    // WINDOW EVENT HANDLER CLASS    private class WindowEventHandler        extends WindowAdapter    {    ////////////////////////////////////////////////////////////////////    //  Constructors    ////////////////////////////////////////////////////////////////////        private WindowEventHandler( )        {        }        //--------------------------------------------------------------    ////////////////////////////////////////////////////////////////////    //  Instance methods : overriding methods    ////////////////////////////////////////////////////////////////////        public void windowClosing( WindowEvent event )        {            doClose( );        }        //--------------------------------------------------------------    }    //==================================================================//////////////////////////////////////////////////////////////////////////  Constructors////////////////////////////////////////////////////////////////////////    protected NonEditableTextAreaDialog( Window owner,                                         String titleStr,                                         int    numColumns,                                         int    numRows,                                         String text )    {        this( owner, titleStr, numColumns, numRows, text, false );    }    //------------------------------------------------------------------    protected NonEditableTextAreaDialog( Window  owner,                                         String  titleStr,                                         int     numColumns,                                         int     numRows,                                         String  text,                                         boolean canClear )    {        super( owner, titleStr, Dialog.ModalityType.APPLICATION_MODAL );        init( owner, numColumns, numRows, text, canClear );    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods : ActionListener interface////////////////////////////////////////////////////////////////////////    public void actionPerformed( ActionEvent event )    {        try        {            String command = event.getActionCommand( );            String methodName = Constants.COMMAND_METHOD_PREFIX +                                        command.substring( 0, 1 ).toUpperCase( ) + command.substring( 1 );            int index = methodName.indexOf( '.' );            if ( index < 0 )                Util.getDeclaredMethod( getClass( ), methodName, false ).invoke( this );            else                Util.getDeclaredMethod( getClass( ), methodName.substring( 0, index ), true ).                                                        invoke( this, methodName.substring( index + 1 ) );        }        catch ( Exception e )        {            e.printStackTrace( );        }    }    //------------------------------------------------------------------//////////////////////////////////////////////////////////////////////////  Instance methods////////////////////////////////////////////////////////////////////////    public boolean isCleared( )    {        return cleared;    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -