本题是设计一个窗体,窗口的背景色为系统桌面的颜色,在窗口中分别画了空心和实心的黑色矩形、深灰色圆角矩形和浅灰色椭圆形,并且画了白色粗体的“Java二级考试!”字符串。
Import java.awt.*;
Import javax.swing.*;
Public class java2
Public static void main(string[]args)
Fillframe frame=new fillframe();
Frame.setdefaultcloseoperation(jframe.exit_on_close);
Frame.show();
Class fillframe extends jframe
Public fillframe()
Settitle("simple");
Setsize(width,height);
Fillpanel panel=new fillpanel();
Panel.setbackground(systemcolor.desktop);
Container contentpane=getcontentpane();
Contentpane.add(panel);
Public static final int width=400;
Public static final int width=250;
Class fillpanel extends jpanel
Public void paintcomponent(graphics g)
______;
g.setcolor(new color(10,10,10));
g.drawrect(10,10,100,30);
g.setcolor(new color(100,100,100));
g.drawroundrect(150,10,100,30,15,15);
g.setcolor(new color(150,150,150));
g.drawoval(280,10,80,30);
g.setcolor(new color(10,10,10));
g.fillrect(10,110,100,30);
g.setcolor(new color(100,100,100));
g.drawroundrect(150,110,100,30,15,15);
g.setcolor(new color(150,150,150));
g.filloval(280,110,80,30);
g.setcolor(color.white),
font f=new font("宋体",__,20);
g.setfont(f);
g.drawstring("java二级考试!",150,200);