首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Java Graphics.fillPolygon:如何同时渲染右边缘和下边缘?

在Java中,Graphics.fillPolygon方法可以用来填充一个多边形。要同时渲染右边缘和下边缘,您需要首先确定多边形的顶点坐标,然后使用fillPolygon方法进行填充。以下是一个简单的示例:

代码语言:java
复制

import javax.swing.*;

import java.awt.*;

public class PolygonExample extends JPanel {

代码语言:txt
复制
@Override
代码语言:txt
复制
protected void paintComponent(Graphics g) {
代码语言:txt
复制
    super.paintComponent(g);
代码语言:txt
复制
    setBackground(Color.WHITE);
代码语言:txt
复制
    int[] xPoints = {100, 150, 150, 200, 200, 250, 250, 300, 300, 350, 350, 400, 400, 450, 450, 500, 500, 550, 550, 600, 600, 650, 650, 700, 700, 750, 750, 800, 800, 850, 850, 900, 900, 950, 950, 1000, 1000, 1050, 1050, 1100, 1100, 1150, 1150, 1200, 1200, 1250, 1250, 1300, 1300, 1350, 1350, 1400, 1400, 1450, 1450, 1500, 1500, 1550, 1550, 1600, 1600, 1650, 1650, 1700, 1700, 1750, 1750, 1800, 1800, 1850, 1850, 1900, 1900, 1950, 1950, 2000, 2000, 2050, 2050, 2100, 2100, 2150, 2150, 2200, 2200, 2250, 2250, 2300, 2300, 2350, 2350, 2400, 2400, 2450, 2450, 2500, 2500, 2550, 2550, 2600, 2600, 2650, 2650, 2700, 2700, 2750, 2750, 2800, 2800, 2850, 2850, 2900, 2900, 2950, 2950, 3000, 3000, 3050, 3050, 3100, 3100, 3150, 3150, 3200, 3200, 3250, 3250, 3300, 3300, 3350, 3350, 3400, 3400, 3450, 3450, 3500, 3500, 3550, 3550, 3600, 3600, 3650, 3650, 3700, 3700, 3750, 3750, 3800, 3800, 3850, 3850, 3900, 3900, 3950, 3950, 4000, 4000, 4050, 4050, 4100, 4100, 4150, 4150, 4200, 4200, 4250, 4250, 4300, 4300, 4350, 4350, 4400, 4400, 4450, 4450, 4500, 4500, 4550, 4550, 4600, 4600, 4650, 4650, 4700, 4700, 4750, 4750, 4800, 4800, 4850, 4850, 4900, 4900, 4950, 4950, 5000, 5000, 5050, 5050, 5100, 5100, 5150, 5150, 5200, 5200, 5250, 5250, 5300, 5300, 5350, 5350, 5400, 5400, 5450, 5450, 5500, 5500, 5550, 5550, 5600, 5600, 5650, 5650, 5700, 5700, 5750, 5750, 5800, 5800, 5850, 5850, 5900, 5900, 5950, 5950, 6000, 6000, 6050, 6050, 6100, 6100, 6150, 6150, 6200, 6200, 6250, 6250, 6300, 6300, 6350, 6350, 6400, 6400, 6450, 6450, 6500, 6500, 6550, 6550, 6600, 6600, 6650, 6650, 6700, 6700, 6750, 6750, 6800, 6800, 6850, 6850, 6900, 6900, 6950, 6950, 7000, 7000, 7050, 7050, 7100, 7100, 7150, 7150, 7200, 7200, 7250, 7250, 7300, 7300, 7350, 7350, 7400, 7400, 7450, 7450, 7500, 7500, 7550, 7550, 7600, 7600, 7650, 7650, 7700, 7700, 7750, 7750, 7800, 7800, 7850, 7850, 7900, 7900, 7950, 7950, 8000, 8000, 8050, 8050, 8100, 8100, 8150, 8150, 8200, 8200, 8250, 8250, 8300, 8300, 8350, 8350, 8400, 8400, 8450, 8450, 8500, 8500, 8550, 8550, 8600, 8600, 8650, 8650, 8700, 8700, 8750, 8750, 8800, 8800, 8850, 8850, 8900, 8900, 8950, 8950, 9000, 9000, 9050, 9050, 9100, 9100, 9150, 9150, 9200, 9200, 9250, 9250, 9300, 9300, 9350, 9350, 9400, 9400, 9450, 9450, 9500, 9500, 9550, 9550, 9600, 9600, 9650, 9650, 9700, 9700, 9750, 9750, 9800, 9800, 9850, 9850, 9900, 9900, 9950, 9950, 10000, 10000, 10050, 10050, 10100, 10100, 10150, 10150, 10200, 10200, 10250, 10250, 10300, 10300, 10350, 10350, 10400, 10400, 10450, 10450, 10500, 10500, 10550, 10550, 10600, 10600, 10650, 10650, 10700, 10700, 10750, 10750, 10800, 10800, 10850, 10850, 10900, 10900, 10950, 10950, 11000, 11000, 11050, 11050, 11100, 11100, 11150, 11150, 11200, 11200, 11250, 11250, 11300, 11300, 11350, 11350, 11400, 11400, 11450, 11450, 11500, 11500, 11550, 11550, 11600, 11600, 11650, 11650, 11700, 11700, 11750, 11750, 11800, 11800, 11850, 11850, 11900, 11900, 11950, 11950, 12000, 12000, 12050, 12050, 12100, 12100, 12150, 12150, 12200, 12200, 12250, 12250, 12300, 12300, 12350, 12350, 12400, 12400, 12450, 12450, 12500, 12500, 12550, 12550, 12600, 12600, 12650, 12650, 12700, 12700, 12750, 12750, 12800, 12800, 12850, 12850, 12900, 12900, 12950, 12950, 13000, 13000, 13050, 13050, 13100, 13100, 13150, 13150, 13200, 13200, 13250, 13250, 13300, 13300, 13350, 13350, 13400, 13400, 13450, 13450, 13500, 13500, 13550, 13550, 13600, 13600, 13650, 13650, 13700, 13700, 13750, 13750, 13800, 13800, 13850, 13850, 13900, 13900, 13950, 13950, 14000, 14000, 14050, 14050, 14100, 14100, 14150, 14150, 14200, 14200, 14250, 14250, 14300, 14300, 14350, 14350, 14400, 14400, 14450, 14450, 14500, 14500, 14550, 14550, 14600, 14600, 14650, 14650, 14700, 14700, 14750, 14750, 14800, 14800, 14850, 14850, 14900, 14900, 14950
页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

4分43秒

SuperEdge易学易用系列-使用ServiceGroup实现多地域应用管理

领券