怎樣才能在label上顯示中文 你用的是jb么?将jb的字体改为宋体什么的,label上就可以显示中文了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不是吧. . . label有自己默认的Font的,如果那个Font不支持中文. 你改JB的字体有什么用? 有一个这样的方法:1.首先 private static ResourceBundle resources; static { try { resources = ResourceBundle.getBundle("resources.Notepad", Locale.getDefault()); } catch (MissingResourceException mre) { System.err.println("resources/Notepad.properties not found"); System.exit(1); } }2.如下用,String vpFlag = resources.getString("ViewportBackingStore");3,然后,add(new Label(vpFlag));说明:../resources/Notepad.properties文件文件有这样一行ViewportBackingStore="中国队加油" new JLabel("Hello!Swing World",new ImageIcon("fox.gif"),JLabel.CENTER)当作为应用程序运行时正常,当作为小应用程序运行时提示错误,文件fox.gif不能读取.其中fox.gif放到同一虚拟目录下。请问怎么办? Hello.java/**<Applet code=Hello width=300 height=150>*</Applet>*/import javax.swing.*;import java.awt.event.*;public class Hello extends JApplet { public void init() { getContentPane().add(new JLabel("Hello!Swing World",new ImageIcon("fox.gif"),JLabel.CENTER)); }public static void main(String[] args) { JFrame f=new JFrame("Hello"); Hello helloApplet=new Hello(); helloApplet.init(); f.getContentPane().add(helloApplet); f.addWindowListener(new WindowEventHandler()); f.setSize(300,150); f.show(); }}class WindowEventHandler extends WindowAdapter { public void windowClosing(WindowEvent e){ System.exit(0); }} test.htm<html><head><title>Java Applet Example</title></head><body><center><applet code="Hello.class" width=300 height=200></applet></center></body></html> 把原来Label上的英文String 替换为 中文String. 如String English="english"; 换为String English="英文"; 注意在KAVA环境中要用copy才能将“英文”二字拷到里面去 而不能直接输入。 如何比较两个Date对象哪个时间早晚?(本人初学,很小白的问题) 求教一个简单的JAVA算法 向下转型 请教:java的不同类中的函数可否线程同步? package和import 源代码阅读 socket发送与接收16进制数据的郁闷问题 《java编程指南 》这本书好吗? HELP ME! 大家帮帮忙,怎么能实现这里的提问按钮的这种功能,点一次就不可用? 如何在JB6中使用jfreechart? 关于Java混编译器。
label有自己默认的Font的,如果那个Font不支持中文. 你改JB的字体有什么用?
1.首先
private static ResourceBundle resources; static {
try {
resources = ResourceBundle.getBundle("resources.Notepad",
Locale.getDefault());
} catch (MissingResourceException mre) {
System.err.println("resources/Notepad.properties not found");
System.exit(1);
}
}
2.如下用,
String vpFlag = resources.getString("ViewportBackingStore");
3,然后,
add(new Label(vpFlag));
说明:../resources/Notepad.properties文件
文件有这样一行
ViewportBackingStore="中国队加油"
*<Applet code=Hello width=300 height=150>
*</Applet>
*/
import javax.swing.*;
import java.awt.event.*;public class Hello extends JApplet {
public void init() {
getContentPane().add(new JLabel("Hello!Swing World",new ImageIcon("fox.gif"),JLabel.CENTER));
}
public static void main(String[] args) {
JFrame f=new JFrame("Hello");
Hello helloApplet=new Hello();
helloApplet.init();
f.getContentPane().add(helloApplet);
f.addWindowListener(new WindowEventHandler());
f.setSize(300,150);
f.show();
}
}class WindowEventHandler extends WindowAdapter {
public void windowClosing(WindowEvent e){
System.exit(0);
}
} test.htm<html>
<head><title>Java Applet Example</title></head>
<body>
<center>
<applet code="Hello.class" width=300 height=200></applet>
</center>
</body>
</html>
如String English="english";
换为String English="英文";
注意在KAVA环境中要用copy才能将“英文”二字拷到里面去
而不能直接输入。