📄 test.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -