changetexttool.java

来自「用java实现的画图程序」· Java 代码 · 共 38 行

JAVA
38
字号
package com.sunking.tp.tool;import com.sunking.tp.framework.*;import java.awt.*;import javax.swing.*;/** * * <p>Title: </p> * <p>Description: 改变文本工具</p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author <a href="mailto:sunkingxie@hotmail.com">SunKing</a> * @version 1.0 */public class ChangeTextTool extends AbstractTool {    public ChangeTextTool(Desktop desk,javax.swing.Icon icon){        super(desk);        setToolTip("Change the text of selection.");        setIcon(icon);    }    /**     *启动工具     */    public void enabledTool(){        super.enabledTool();        JTPComponent source[] = desk.getSelectionJTPComponent();        if(source!=null&&source.length>0){            String strInput=JOptionPane.showInputDialog(                    SwingUtilities.getWindowAncestor((Component)desk),                    "Please input text...",source[0].getText());            if(strInput != null){                for (int i = 0; i < source.length; i++) {                    source[i].setText(strInput);                }            }        }        desk.setTool(null);    }}

⌨️ 快捷键说明

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