各位,定义类名不是必须要用合法的标识符来定吗?为什么定义中文名称一样可以编译运行?
例如:
class 你好
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}请教AWT问题。此程序默认label是不显示的,是通过点击button来显示。
为何通过点击button也显示不出来呢?
刚接触AWT,还望各位详解。先谢过了。
import java.awt.*;
import java.awt.event.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;public class Hide extends Frame {
XYLayout xYLayout1 = new XYLayout();
Button button1 = new Button();
Label label1 = new Label();
public Hide() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
Hide hide = new Hide();
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
this.setSize(350, 350);
this.setLocation(300, 220);
button1.setLabel("Display Edition");
button1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
label1.setBackground(SystemColor.desktop);
label1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
label1.setForeground(Color.white);
label1.setText("Edition:1.0");
label1.setVisible(false);
this.add(button1, new XYConstraints(66, 52, 138, 42));
this.add(button1, new XYConstraints(59, 47, 137, 41));
this.add(label1, new XYConstraints(66, 175, 103, 38));
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void button1_actionPerformed(ActionEvent e) {
label1.setVisible(true);
}
}
例如:
class 你好
{
public static void main(String[] args)
{
System.out.println("Hello World!");
}
}请教AWT问题。此程序默认label是不显示的,是通过点击button来显示。
为何通过点击button也显示不出来呢?
刚接触AWT,还望各位详解。先谢过了。
import java.awt.*;
import java.awt.event.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;public class Hide extends Frame {
XYLayout xYLayout1 = new XYLayout();
Button button1 = new Button();
Label label1 = new Label();
public Hide() {
try {
jbInit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) {
Hide hide = new Hide();
}
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
this.setSize(350, 350);
this.setLocation(300, 220);
button1.setLabel("Display Edition");
button1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
button1_actionPerformed(e);
}
});
label1.setBackground(SystemColor.desktop);
label1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 14));
label1.setForeground(Color.white);
label1.setText("Edition:1.0");
label1.setVisible(false);
this.add(button1, new XYConstraints(66, 52, 138, 42));
this.add(button1, new XYConstraints(59, 47, 137, 41));
this.add(label1, new XYConstraints(66, 175, 103, 38));
this.setVisible(true);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void button1_actionPerformed(ActionEvent e) {
label1.setVisible(true);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货