import java.awt.*;
import javax.swing.JLabel;
public class rcr {
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame("标题-java图形用户界面");
Panel p1=new Panel();
JLabel lab=new JLabel("Hello World");
f.setSize(300,150);
f.setVisible(true);
f.setBackground(Color.pink);
f.add(p1);
p1.add(lab);
}
}
import javax.swing.JLabel;
public class rcr {
public static void main(String[] args) {
// TODO Auto-generated method stub
Frame f=new Frame("标题-java图形用户界面");
Panel p1=new Panel();
JLabel lab=new JLabel("Hello World");
f.setSize(300,150);
f.setVisible(true);
f.setBackground(Color.pink);
f.add(p1);
p1.add(lab);
}
}
JavaGUI程序示例
本文介绍了一个简单的Java图形用户界面(GUI)程序示例。该程序使用了`Frame`、`Panel`和`JLabel`组件来创建一个窗口,并显示了Hello World文字。通过设置窗口大小、背景颜色等属性,演示了基本的GUI布局。
1185

被折叠的 条评论
为什么被折叠?



