下面java程序能编译运行,但是没有窗口出来,怎么回事?
importjava.awt.*;publicclassLayoutj{publicstaticvoidmain(Stringargs[])throwsException...
import java.awt.*;
public class Layoutj{
public static void main(String args[]) throws Exception{
Frame f=new Frame("little window");
f.setSize(200,200);
f.add(new Button("north"),"North");
f.add(new Button("west"),"West");
f.add(new Button("center"),"Center");
Panel p1=new Panel();
Panel p2=new Panel();
p1.add(new Button("fuck"));
p1.add(new Button("you"));
p2.add(new Button("asshole"));
f.add(p1,"East");
f.add(p2,"South");
for(int i=0;i<=200;i++)
for(int j=0;j<=200;j++){
p1.setBackground(new Color(i,j,99));
Thread.sleep(100);
}
for(int a=0;a<=255;a++)
for(int b=0;b<=255;b++){
p2.setBackground(new Color(33,a,b));
Thread .sleep(10);
}
f.pack();
f.setBackground(new Color(199,199,33));
f.setVisible(true);
}
} 展开
public class Layoutj{
public static void main(String args[]) throws Exception{
Frame f=new Frame("little window");
f.setSize(200,200);
f.add(new Button("north"),"North");
f.add(new Button("west"),"West");
f.add(new Button("center"),"Center");
Panel p1=new Panel();
Panel p2=new Panel();
p1.add(new Button("fuck"));
p1.add(new Button("you"));
p2.add(new Button("asshole"));
f.add(p1,"East");
f.add(p2,"South");
for(int i=0;i<=200;i++)
for(int j=0;j<=200;j++){
p1.setBackground(new Color(i,j,99));
Thread.sleep(100);
}
for(int a=0;a<=255;a++)
for(int b=0;b<=255;b++){
p2.setBackground(new Color(33,a,b));
Thread .sleep(10);
}
f.pack();
f.setBackground(new Color(199,199,33));
f.setVisible(true);
}
} 展开
3个回答
展开全部
你为什么要在每一次循环里都sleep一下啊,把sleep去掉就出来了,不然你就一直等个几小时也能出来。。。
import java.awt.*;
public class Layoutj {
public static void main(String args[]) throws Exception {
Frame f = new Frame("little window");
f.setSize(200, 200);
f.add(new Button("north"), "North");
f.add(new Button("west"), "West");
f.add(new Button("center"), "Center");
Panel p1 = new Panel();
Panel p2 = new Panel();
p1.add(new Button("fuck"));
p1.add(new Button("you"));
p2.add(new Button("asshole"));
f.add(p1, "East");
f.add(p2, "South");
for (int i = 0; i <= 200; i++)
for (int j = 0; j <= 200; j++) {
p1.setBackground(new Color(i, j, 99));
}
for (int a = 0; a <= 255; a++)
for (int b = 0; b <= 255; b++) {
p2.setBackground(new Color(33, a, b));
}
f.pack();
f.setBackground(new Color(199, 199, 33));
f.setVisible(true);
}
}
展开全部
for (int i = 0; i <= 200; i++)
for (int j = 0; j <= 200; j++) {
p1.setBackground(new Color(i, j, 99));
//Thread.sleep(100);
}
for (int a = 0; a <= 255; a++)
for (int b = 0; b <= 255; b++) {
p2.setBackground(new Color(33, a, b));
//Thread.sleep(10);
}
for (int j = 0; j <= 200; j++) {
p1.setBackground(new Color(i, j, 99));
//Thread.sleep(100);
}
for (int a = 0; a <= 255; a++)
for (int b = 0; b <= 255; b++) {
p2.setBackground(new Color(33, a, b));
//Thread.sleep(10);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-29
展开全部
循环太多了。~~~~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询