简体   繁体   English

JFrame部分透明

[英]JFrame partly transparent

Im working on analyse differences between shortest and simpliest way in a graph. 我正在研究图形中最短和最简单方式之间的差异。 To make it easier, I created a very simple JFrame for visualizing the graph and the way. 为了简化操作,我创建了一个非常简单的JFrame来可视化图形和方式。 As you can see on the pictue, the background seems to be partly transparent. 正如您在图片上看到的那样,背景似乎是部分透明的。 I dont know the reason. 我不知道原因。

http://postimg.org/image/p1axfhj9h/ (Sory but i am not allowed to upload pictues, yet) http://postimg.org/image/p1axfhj9h/ (很抱歉,但是我还不能上传照片)

Is there a problem with the painting method? 上漆方法有问题吗? This problem occurs only on my private laptop. 仅在我的私人笔记本电脑上会出现此问题。 Im using java 1.7.0_45 我正在使用Java 1.7.0_45

I have noch changes made on background color or transparency. 我对背景颜色或透明度进行了更改。 The paint method is only painting strings, ovals and lines. 绘制方法仅绘制字符串,椭圆形和线条。

public Drucker(Graph graph) {
    super();
    this.graph = graph;
    setDefaultCloseOperation(EXIT_ON_CLOSE);
}


@Override
public void paint(Graphics g) {

    for (int i = 0; i < this.graph.getKanten().size(); i++) {
        xxx
    }

    for (int i = 0; i < this.graph.getKnoten().size(); i++) {
        xxx
    }       

    this.paintDistance(g);
}

Is there a problem with my java vesion? 我的Java vesion是否有问题? I home somebody can help me. 我回家有人可以帮助我。

Thanks and regards 谢谢并恭祝安康

I think you need to super construct your paint() method. 我认为您需要超级构造 paint()方法。

This simply means writing this: 这仅意味着编写以下代码:

@Override
public void paint(Graphics g) {
    super.paint(g);

    // your code goes here
}

When you super construct the method, that basically means you will paint the parent object then paint the String. 当您超级构造该方法时,基本上意味着您将绘制父对象,然后绘制String。

This is just a hunch. 这只是预感。 Let me know if this does, in fact, fix your problem. 让我知道这是否确实可以解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM