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

📄 jtoolbutton.java

📁 这也是我在论坛上看见的一个程序。感觉非常好
💻 JAVA
字号:
package com.sunking.tp.swing;import javax.swing.*;import java.beans.*;import java.awt.event.*;import com.sunking.tp.tool.*;import com.sunking.tp.framework.*;/** * * <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 JToolButton extends JToggleButton implements ActionListener,PropertyChangeListener{    private static final long serialVersionUID = -3000000000000000007L;    Desktop desk;    Tool tool;    /**     * @param desk  绘图桌面     * @param tool  工具     */    public JToolButton(Desktop desk,Tool tool) {        this.desk = desk;        this.tool = tool;        addActionListener(this);        init(tool);        tool.addPropertyChangeListener(this);        setFocusable(false);    }    void init(Tool tool){        setText(tool.getLabel());        setToolTipText(tool.getToolTip());        setIcon(tool.getIcon());        setEnabled(tool.isEnabled());        setSelected(tool.isSelected());    }    public void actionPerformed(ActionEvent e) {        desk.setTool(tool);    }    /**     *     * @param e     */    public void propertyChange(PropertyChangeEvent e){        String property = e.getPropertyName();        Object newValue = e.getNewValue();        if(property.equals(Tool.ENABLED_PROPERTY)){            if(!newValue.equals(Tool.NULL_VALUE)){                setEnabled(((Boolean)newValue).booleanValue());            }        }else if(property.equals(Tool.ICON_PROPERTY)){            if(!newValue.equals(Tool.NULL_VALUE)){                setIcon((Icon)e.getNewValue());                setSelectedIcon((Icon)e.getNewValue());            }else{                setIcon(null);            }        }else if(property.equals(Tool.LABEL_PROPERTY)){            if(!newValue.equals(Tool.NULL_VALUE)){                setText(e.getNewValue().toString());            }else{                setText(null);            }        }else if(property.equals(Tool.TOOLTIP_PROPERTY)){            if(!newValue.equals(Tool.NULL_VALUE)){                setToolTipText(e.getNewValue().toString());            }else{                setToolTipText(null);            }        }else if(property.equals(Tool.SELECT_PROPERTY)){            setSelected(((Boolean)newValue).booleanValue());        }    }}

⌨️ 快捷键说明

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