我draw(Graphics g)在使用Java中的方法绘制三角形时遇到问题.我可以像这样绘制一个矩形:
public void draw(Graphics g) {
g.setColor(colorFill);
g.fillRect(p.x, p.y, width, height);
g.setColor(colorBorder);
g.drawRect(p.x, p.y, width, height);
drawHandles(g);
Run Code Online (Sandbox Code Playgroud)
其中p代表"形状的左上角".我如何以相同的方式绘制三角形?
有人能给我一个标准三角形的例子吗?
我的Java有问题 据我所知,Java中绘制几何图形不是来的,代码和下面的你能帮我吗?
这是代码:
public class Gioco {
public static void main (String args [])
{
PaintRect();
}
public static void PaintRect() {
g.drawRect(100,100,300,300);
g.drawLine(100,100,100,100);
g.setBackground(Color.BLACK);
System.out.println("Trasut");
credits.setText("Kitebbiv");
credits.setBackground(null);
credits.setEditable(false);
credits.setFocusable(false);
credits.setBounds(0,0,100,100);
credits.setForeground(Color.BLACK);
panel.add(credits);
g.getPaint();
}
Run Code Online (Sandbox Code Playgroud)
如何创建JFrame三角形、正方形和矩形?更正我的代码谢谢