在战牛刀(颠倒的字体);

废话不多说..直入正题
效果图:

 

package BackwardsJLabel;

import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;

import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import sun.security.action.GetPropertyAction;

public class BackwardsJLabel extends JLabel {
  
 
public BackwardsJLabel () super(); }
 
public BackwardsJLabel (Icon image) {super (image);}
 
public BackwardsJLabel (Icon image, int align) {super (image, align);}
 
public BackwardsJLabel (String text) super (text);}
 
public BackwardsJLabel (String text, Icon icon, int align) {
  
super (text, icon, align); 
 }
 
 
public BackwardsJLabel (String text, int align) 
super (text, align);
}

 
public void paint (Graphics g) {
  
if (g instanceof Graphics2D) {
   Graphics2D g2 
= (Graphics2D) g;
   AffineTransform flipTrans 
= new AffineTransform();
   
double widthD = (double) getWidth();
   flipTrans.setToTranslation (widthD, 
0);
   flipTrans.scale (
-1.01);
   g2.transform (flipTrans);
   
super.paint(g);
  }
 else 
   
super.paint(g); 
  }
 
 }
 
 
public static void main (String[] args) {
  BackwardsJLabel field 
=
   
new BackwardsJLabel ("谁能到懂我说的话?能看懂的赶紧留帖!!");
  field.setFont(
new Font("宋体",0,12));
  JFrame frame 
= new JFrame("颠倒的JLabel");
  frame.getContentPane().add (field);
  frame.pack();
  frame.setVisible(
true);
 }

}


posted on 2008-05-20 13:05 相信 阅读(508) 评论(4)  编辑  收藏 所属分类: Swing文章

评论

# re: 在战牛刀(颠倒的字体); 2008-05-21 19:17 lzw

这个太差劲了,能不能改成垂直显示文字的?  回复  更多评论   

# re: 在战牛刀(颠倒的字体); 2008-05-21 19:19 相信

...源代码已经开放了

我只把思路写出来
并不能符合每个人想要的效果

你可以自己更改我的代码..  回复  更多评论   

# re: 在战牛刀(颠倒的字体); 2008-05-23 15:26 盗版 耶稣

呵呵...  回复  更多评论   

# re: 在战牛刀(颠倒的字体); 2008-05-29 16:14 晴天

继续努力哈  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航:
 
<2008年5月>
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

统计

公告

不显示applet

常用链接

留言簿(16)

我参与的团队

随笔档案

文章分类

文章档案

新闻档案

相册

swingchina 专业搞Swing的网站

搜索

最新评论

阅读排行榜

评论排行榜