小编jan*_*n b的帖子

Swing Ui倍增面板重影

我最近和我的挥杆问题有关.一切正常,直到我从JButton触发工具提示.之后将鼠标移动到ui的其余部分会导致奇怪的伪像和故障.

窃听:

在此输入图像描述

我无法显示整个代码,因为它太多但在这里我初始化按钮:

    GridBagConstraints bottompane_gbc = new GridBagConstraints();
    toggleTorConnectionButton = new JButton();      
    toggleTorConnectionButton.setToolTipText("Toggles Tor Connection.");
    toggleTorConnectionButton.setIcon(new ImageIcon(ResourceHandler.Menueicon3_1));
    toggleTorConnectionButton.setMinimumSize(new Dimension(removeFinishedDownloads.getMinimumSize().width, toggleTorConnectionButton.getIcon().getIconHeight()+5));

    toggleTorConnectionButton.addActionListener(); // unimportant
    bottompane_gbc.gridy = 1;
    bottompane_gbc.fill = GridBagConstraints.BOTH;
    bottompane_gbc.insets = new Insets(0,15,10,5);
    bottompane.add(ToggleTorConnectionButton,bottompane_gbc);


    this.add(bottompane,BorderLayout.PAGE_END);
Run Code Online (Sandbox Code Playgroud)

如果有人需要更多的信息来帮助我请随意问.我有点绝望.XD

编辑:经过一些修补我猜测问题与swing和我的使用有关.目前我使用很多Eventlisteners(这是不是很糟糕?),这可能会减慢awt线程?以下是HPROF的简要摘录:http: //www.pastebucket.com/96444

编辑2:我能够在一个方便而简单的例子中重新创建错误.当你移动按钮时,等待工具提示,然后在ui上.你会看到鬼影:(.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

public class Main_frame {

    public static void main(String[] args) {
        new Main_frame();
    }

    public Main_frame() {
        JFrame frame = new JFrame("LOL"); …
Run Code Online (Sandbox Code Playgroud)

java debugging user-interface swing

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

标签 统计

debugging ×1

java ×1

swing ×1

user-interface ×1