package java01;
import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
public class java4{
private static final int Width = 0;
public void paintComponent(Graphics g){
paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
float width = getSize().width-10;
float Height= getSize().height/3-10;
g2.setPaint(Color.red);
g2.draw(new Line2D.Float(5,5,5+Width,5+Height));
g2.draw(new Line2D.Float(5,5+Height,5+Width,5));
g2.setPaint(new Color(192,128,64));
g2.fill(new Rectangle2D.Float(5,10+Height,Width,Height));
g2.fill(new Shape(5,5,Color.blue,5+Width,5,Color.yellow));
g2.fill(new Ellipse2D.Float(5,20+2*Height,Width,Height));
}
private Object getSize() {
// TODO Auto-generated method stub
return null;
}
public static void main(String [] argv, Object color){
JFrame f=new JFrame("色彩应用");
Component p=new Color(0);
p.setBackground(color.white);
f.getContentPane().add(p);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(640,480);
f.setVisible(true);
}
}显示有错误,不知如何修改,朋友们看下,不胜感激!
添加回答
举报
0/150
提交
取消