test.java

来自「j2ee关于BEANS的多个例子」· Java 代码 · 共 49 行

JAVA
49
字号
import javax.swing.*;
import java.awt.*;

public class Test extends JPanel
{
	JButton btn;
	private Font tFont;
	private String caption="大家好";
	private Color color;
	public Test()
	{
		btn=new JButton();
		this.add(btn);
		tFont=new Font("华文行楷",Font.ITALIC,20);
		color=new Color(255,0,0);
		btn.setBackground(color);
		btn.setFont(tFont);
		btn.setText(caption);
	}
	public void setTFont(String temp)
	{
//		System.out.println(temp);
		tFont=new Font(temp,Font.ITALIC,20);
		btn.setFont(tFont);
	}
	public String getTFont()
	{
		return tFont.getFontName();
	}
	public void setCaption(String temp)
	{
		caption=temp;
		btn.setText(caption);
	}
	public String getCaption()
	{
		return caption;
	}
	public void setColor(Color col)
	{
		this.color=col;
		setBackground(color);
//		setForeground(color);
	}
	public Color getColor()
	{
		return color;
	}
}

⌨️ 快捷键说明

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