第五周作业

[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <pre code_snippet_id="277015" snippet_file_name="blog_20140405_1_6365875" name="code" class="java">import java.awt.Container;  
  2. import java.awt.Font;  
  3. import java.awt.Graphics;  
  4.   
  5. import javax.swing.JFrame;  
  6. import javax.swing.JPanel;  
  7. public class FontSet   
  8. {  
  9.     public static void main(String args[])  
  10.     {  
  11.         FontFrame frame= new FontFrame();  
  12.         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
  13.         frame.show();     
  14.     }  
  15. }  
  16. class FontFrame extends JFrame  
  17. {  
  18. public FontFrame()  
  19. {  
  20.     setTitle("设置字体");  
  21.     setSize(WIDTH,HEIGHT);  
  22.     FontPanel panel =  new FontPanel();  
  23. Container contentPane =getContentPane();  
  24. contentPane.add(panel);       
  25. }  
  26. public static final int WIDTH =300;  
  27. public static final int HEIGHT =140;  
  28. }  
  29. class FontPanel extends JPanel  
  30. {  
  31.     public void paintComponent(Graphics g)  
  32.   
  33. {  
  34.         super.paintComponent(g);  
  35.         //设置字体  
  36.         Font f =new Font("宋体",Font.BOLD+Font.ITALIC,20);  
  37.         g.setFont(f);  
  38.         //显示文本  
  39.         g.drawString("java 欢迎您!",x,y);  
  40.           
  41.     }  
  42. public int x=55;  
  43. public int y=50;  
  44. }</pre>  
  45. <pre></pre>  
  46. <pre></pre>  
  47. <pre></pre>  
  48. <pre></pre>  
  49. <pre></pre>  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值