allenlee
发贴: 24
积分: 0
|
于 2004-08-26 14:49
{ 请尽量用准确的文字描述作为标题 }
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class WelcomeText{ public static void main(String args[]) {WelcomeFrame frame=new WelcomeFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.show(); } } class WelcomeFrame extends JFrame {public WelcomeFrame() {setTitle("LOGIN"); setSize(DEFAULT_WIDTH,DEFAULT_HEIGTH); WelcomePanel panel=new WelcomePanel(); Container contentPane=getContentPane(); contentPane.add(panel); } public static final int DEFAULT_WIDTH=300; public static final int DEFAULT_HEIGTH=200; } class WelcomePanel extends JPanel {public WelcomePanel() {JLabel prompt=new JLabel("请输入你的名字:"); final JTextField input=new JTextField(10); final JTextField output=new JTextField(25); JButton btnn=new JButton("login"); add(prompt); add(input); add(output); add(btnn); btnn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) {String s=input.getText(); output.setText("hello! "+s+" 欢迎加入我们的行列"); } }); } } 为什么程序执行后中文变成乱码?? 需要什么转换吗??请指教.
why edited on 2004-08-26 19:06
|