小编MKB*_*MKB的帖子

如何在java中为设计着色?

嗨!我有这个问题:我必须在java中创建一个程序设计一个人的图形,我必须绘制它.我已经编写了设计人类的代码,但我不知道如何用颜色填充形状.我知道我必须使用"java.awt.Color",但我不知道如何.

颜色必须是:图像背景(黄色),头部(蓝色),手臂和腿部(绿色),身体(红色).

到目前为止,这是我的代码:

import javax.swing.*;
import java.awt.*;

public class DrawPanelTest {
    //creates a window to display the drawing
    public static void main(String[] args) {
        // create a new frame to hold the panel
        JFrame application = new JFrame();
        Container pane=application.getContentPane();
        // create a panel that contains our drawing
        DrawPanel panel = new DrawPanel();
        // set the frame to exit when it is closed
        application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        // add the panel to the frame
        pane.add(panel);
        application.setContentPane(pane);
        // set the size of …
Run Code Online (Sandbox Code Playgroud)

java colors draw background-color

1
推荐指数
1
解决办法
160
查看次数

标签 统计

background-color ×1

colors ×1

draw ×1

java ×1