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

📄 clientbutton.java

📁 java版QQ聊天,实现用户登录验证
💻 JAVA
字号:

package com.qq;

import javax.swing.JButton;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.SwingConstants;
import java.awt.Font;

public class ClientButton extends JButton{
	public final static int SHORT = 0;
	public final static int LONG = 1;
	
	private final static Icon ClientBtnIcon[][] = {
		{
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Short_Normal.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Short_Select.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Short_Rollover.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Short_Pressed.gif"))
		},{
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Long_Normal.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Long_Select.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Long_Rollover.gif")),
			new ImageIcon(ClientButton.class.getResource("img/qqImage/ClientBtnImage/Long_Pressed.gif"))
		}
	};
	
	private final static Font ClientBtnFont = new Font("SansSerif",Font.PLAIN,12);
	
	public ClientButton(String text, int type, boolean defaultButton){
		super(text);
		
		if(!defaultButton){
			this.setIcon(ClientBtnIcon[type][0]);
		}	
		else{
			this.setIcon(ClientBtnIcon[type][1]);
		}	
		this.setRolloverIcon(ClientBtnIcon[type][2]);
		this.setPressedIcon(ClientBtnIcon[type][3]);
		
		this.setBorder(null);
		this.setFocusable(false);
		this.setFont(ClientBtnFont);
		this.setHorizontalTextPosition(SwingConstants.CENTER);
		this.setVerticalTextPosition(SwingConstants.CENTER);	
	}
}

⌨️ 快捷键说明

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