📄 buttoncommon.java
字号:
package librarymanagement.view.common;
import java.awt.Insets;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import librarymanagement.action.MainFrameToolBarAction;
/**
* 公共的构建Button的类,继承了JButton
* @author 虎兴龙
*/
public class ButtonCommon extends JButton{
/**
* 构建只有背景图片的按钮
* @param icon
*/
public ButtonCommon(Icon icon){
super(icon);
}
/**
* 构建带有事件的 JButton
* @param a Action对象
*/
public ButtonCommon(Action a){
}
/**
* 构建图形按钮
* @param icon ImageIcon对象
* @param text 按钮提示信息
*/
public ButtonCommon(Icon icon,String text){
super(icon);
this.setToolTipText(text);
}
/**
*
* @param text 按钮名称
*/
public ButtonCommon(String text){
super(text);
}
/**
*
* @param text 按钮名称
* @param iconimage 按钮图片
*/
public ButtonCommon(String text,Icon iconimage){
super(text,iconimage);
this.setHorizontalTextPosition(SwingConstants.CENTER);
this.setVerticalTextPosition(SwingConstants.BOTTOM);
}
/**
* 构建既有图形又有标题的按钮
* @param text 按钮名称
* @param iconimageName 按钮图片路径
*/
public ButtonCommon(String text,String iconimageName){
super(text);
Icon noSelectImage=new ImageIcon(iconimageName);
this.setIcon(noSelectImage);
this.setRolloverEnabled(true);
this.setRolloverIcon(noSelectImage);
this.setHorizontalTextPosition(SwingConstants.CENTER);
this.setVerticalTextPosition(SwingConstants.BOTTOM);
this.setMargin(new Insets(0,0,0,0));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -