小编Cha*_*One的帖子

调用paintComponent,但不显示任何内容

我是AWT的新手,这只是一个示例程序,可以看看它是如何工作的.

我的问题是在调整大小/最小化等事件时,窗口被清除.

我已经paintComponent在许多SO问题中指定了覆盖,并且实际调用了代码(因为如果我放入一个println,我看到输出),但是没有显示任何内容.

我在Windows和Linux上试过这个,结果是一样的,所以我想我错过了什么.

这是代码:

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JPanel;

class Site {
    private Integer x;
    private Integer y;
    private Integer width;
    private Integer height;
    private Graphics2D g2d;
    private boolean isOpen = false;

    private Integer id = null;
    private Integer root = null;

    public Site(Integer id, Integer x, Integer y, Integer width, Integer height, Graphics2D g2d) {
        this.id = id;
        this.root = id;
        this.x = …
Run Code Online (Sandbox Code Playgroud)

java swing

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

标签 统计

java ×1

swing ×1