publicclassDrawFrame{
publicstaticvoidmain(String[]args){
finalJFrameframe=newJFrame();
frame.setContentPane(newJPanel(){
@Override
publicvoidpaint(Graphicsg){
super.paint(g);
Graphics2Dg2d=(Graphics2D)g;
RadialGradientPaintpaint=newRadialGradientPaint(65,65,50,newfloat[]{0f,1f},newColor[]{Color.WHITE,Color.BLACK});
g2d.setPaint(paint);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
Ellipse2De=newEllipse2D.Float(10,10,100,100);
g2d.fill(e);
}
});
frame.setVisible(true);
}
}
黑白棋。
Graphics2Dg2d=(Graphics2D)g;
RadialGradientPaintpaint=newRadialGradientPaint(65,60,50,newfloat[]{0f,0.5f,1f},newColor[]{Color.WHITE,Color.BLUE,Color.BLACK});
g2d.setPaint(paint);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,RenderingHints.VALUE_ALPHA_INTERPOLATION_DEFAULT);
Ellipse2De=newEllipse2D.Float(10,10,100,100);
g2d.fill(e);
这个是斯诺克球。