展开全部
圆锥就32313133353236313431303231363533e4b893e5b19e31333337616564是一个三角形+一个椭圆.只要算好三角形和椭圆 的坐标就可以了import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TestDemo extends JFrame {
public TestDemo() {
MyJPanel jp = new MyJPanel();
this.add(jp);
this.setTitle("圆锥");
this.setBounds(0, 0, 380, 300);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args) {
new TestDemo();
}
class MyJPanel extends JPanel {
@Override
public void paint(Graphics g) {
super.paint(g);
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.BLUE);
int x = 120;//定义椭圆左顶点的x坐标
int y = 180;//定义椭圆左顶点的y坐标
int w = 120;//椭圆长
int h = 40;//椭圆高
int hh = 130;//圆锥体的高
g2d.fillOval(x, y, w, h);//画椭圆
//三角形 三个顶点的 坐标
int[] xPoints = { x, x + w, x + w / 2 };//3个x坐标
int[] yPoints = { y + h / 2, y + h / 2, y + h / 2 - hh };//3个y坐标
g2d.setColor(Color.RED);
g2d.fillPolygon(xPoints, yPoints, 3);
}
}
}