http://community.csdn.net/Expert/TopicView.asp?id=3864657
http://www.cjsdn.net/post/view?bid=30&id=138321&sty=1
软件环境: Hibernate 2.1.8
Hibernate Console 2.1
MySQL 4.1.10a-nt与Oracle 9i 配置文件: #Hibernate Console properties #Fri Mar 18 20:52:44 CST 2005 console.custom.classpath=Z\:\\Java\\classes console.hbm.xml=Z\:\\Java\\classes\\hibernate.cfg.xml console.hibernate.properties= 错误提示信息: Hibernate8IDE(Console)查询结果如何才能够显示中文结果?现在都是方框,何解? 你的分析: 是不是取出中文之后也要进行编码转换?
查看源码: 在HQLQueryPage类的getList()方法中增加一条System.out.println(element);来查看信息,显示正确是中文。。。何解?
QueryPageView类的makeUpdatePropertyAction方法中加句System.out.println(o);
鼠标点中选择的内容,也是显示为正确的中文啊。何解?
凡是方框的都是字体没设成中文字体,凡是问号的都是转码不对。
终于找到最终解决问题的方法了。
如下进行修改: 1、net.sf.hibernate.console.Start里增加函数: public static void setUIFont(javax.swing.plaf.FontUIResource f) { java.util.Enumeration keys = UIManager.getDefaults().keys(); while(keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); if(value instanceof javax.swing.plaf.FontUIResource) { UIManager.put(key,f); } } }
2、在main函数中调用 setUIFont(new javax.swing.plaf.FontUIResource("宋体",Font.PLAIN,12));
3、编译,重新打包,运行,Good Luck
在设计Application的时间我曾经为了统一设置字体都用过这个了,怎么就没有转过弯来
如下:
setUIFont(new FontUIResource("宋体",Font.PLAIN,12));
public static void setUIFont(javax.swing.plaf.FontUIResource f) { //取得所有的缺省UIResource属性键。 java.util.Enumeration keys = UIManager.getDefaults().keys(); while(keys.hasMoreElements()) { Object key = keys.nextElement(); Object value = UIManager.get(key); //判断键值是否为FontUIResource,如果是则将其设为指定FontUIResource。 if(value instanceof javax.swing.plaf.FontUIResource) { UIManager.put(key,f); } } }