第五周—字体设置
2014-04-05 22:46
211 查看
import java.awt.Container; import java.awt.Font; import java.awt.Graphics; import javax.swing.JFrame; import javax.swing.JPanel; public class FontSet { public static void main(String args[]) { FontFrame frame= new FontFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); } } class FontFrame extends JFrame { public FontFrame() { setTitle("设置字体"); setSize(WIDTH,HEIGHT); FontPanel panel = new FontPanel(); Container contentPane =getContentPane(); contentPane.add(panel); } public static final int WIDTH =300; public static final int HEIGHT =140; } class FontPanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); //设置字体 Font f =new Font("宋体",Font.BOLD+Font.ITALIC,20); g.setFont(f); //显示文本 g.drawString("java 欢迎您!",x,y); } public int x=55; public int y=50; }
相关文章推荐
- 第五周作业-字体设置
- 第五周作业:字体设置
- 第五周作业——字体设置
- VC++中的字体设置
- linux字体设置
- 动态设置Edit控件的背景及字体颜色
- MFC控件中字体的设置
- idea如何设置字体大小
- Android XML文件中设置字体
- IOS 字体设置
- android 字体设置为楷体
- Eclipse背景颜色及字体大小设置
- poi设置excel表格边框、字体等
- Qt5.9设置pushButton按钮背景色和字体颜色
- 动态设置字体大小
- 设置console字体
- CSS3的REM设置字体大小
- Android编程中TextView字体属性设置方法(大小、字体、下划线、背景色)
- idea 设置字体
- iOS 设置的字体的大小与PS字体大小的关系