public class DrawFrame {
public static void main(String[] args) {
final JFrame frame = new JFrame();
frame.setContentPane(new JPanel() {
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
RadialGradientPaint paint = new RadialGradientPaint(65, 65, 50, new float[]{0f, 1f}, new Color[]{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);
Ellipse2D e = new Ellipse2D.Float(10, 10, 100, 100);
g2d.fill(e);
}
});
frame.setVisible(true);
}
}
黑白棋。
Graphics2D g2d = (Graphics2D) g;
RadialGradientPaint paint = new RadialGradientPaint(65, 60, 50, new float[]{0f, 0.5f, 1f}, new Color[]{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);
Ellipse2D e = new Ellipse2D.Float(10, 10, 100, 100);
g2d.fill(e);
这个是斯诺克球。
制作图片,然后加载即可。