import java.awt.*;
import javax.swing.*;public class Test {
public static void main(String args[]) {
JFrame f = new JFrame("My Test");
Container ct = new Container();
JButton bn = new JButton("BN");
JButton bs = new JButton("BS");
JButton bw = new JButton("BW");
JButton be = new JButton("BE");
JButton bc = new JButton("BC");
ct.add(bn, "North");
ct.add(bs, "South");
ct.add(bw, "West");
ct.add(be, "East");
ct.add(bc, "Center"); f.setBackground(Color.BLACK);
f.setLocation(400,200);
f.setSize(400,400);
f.setVisible(true);
}
}为什么加不上按钮呢?
还有背景颜色为什么不是黑色的?
谢谢
import javax.swing.*;public class Test {
public static void main(String args[]) {
JFrame f = new JFrame("My Test");
Container ct = new Container();
JButton bn = new JButton("BN");
JButton bs = new JButton("BS");
JButton bw = new JButton("BW");
JButton be = new JButton("BE");
JButton bc = new JButton("BC");
ct.add(bn, "North");
ct.add(bs, "South");
ct.add(bw, "West");
ct.add(be, "East");
ct.add(bc, "Center"); f.setBackground(Color.BLACK);
f.setLocation(400,200);
f.setSize(400,400);
f.setVisible(true);
}
}为什么加不上按钮呢?
还有背景颜色为什么不是黑色的?
谢谢
解决方案 »
- java聊天程序的客户端代码问题求解
- 新手字符串问题
- ======JAVA是按unicode编码处理字符的,那它占用的内存和别的语言比也应该比较大的吧?======
- Fatal Error: Unable to locate package java.lang in classpath or bootclasspath at line 0 (0:0)
- 关于JDK最愚昧的问题????????、
- lookup (java:comp/env )的问题:? 和上下文和property三者的关系? 请大家指教,困惑已久!
- 怎么把文件从一个目录拷贝到另一个文件?快,着急!在线等!
- 使用JCreator2.5的问题。
- 如何防止一个Java应用程序同时运行两个实例?
- 容器内对象排序问题
- thinking in java的疑问???
- 如何删除CNNIC?
ct.setBackground(Color.BLACK);