package com.beyole.util;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
public class test5 {
public static void main(String[] args) {
JFrame frame=new JFrame();
JButton button=new JButton("Click Me!");//new出一个按钮的对象
Font font=new Font("Serief",Font.BOLD,28);//设置字体
button.setFont(font);//设置按钮字体
frame.add(button);//向容器加入组件
frame.setSize(300,100);
frame.setLocation(300,200);
frame.setVisible(true);
}
}
对于JButton而言,在这个程序中的作用和JLabel的作用是差不多的。
程序截图:
原文:http://blog.csdn.net/xuejiawei123/article/details/27178749