?? jtoolbutton.java
字號:
package com.sunking.tp.swing;
import java.beans.*;
import java.awt.event.*;
import javax.swing.*;
import com.sunking.tp.framework.*;
import com.sunking.tp.tool.*;
/**
*
* <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 + -