java - 如何修复 Eclipse 中模糊的 Swing 元素

标签 java eclipse swing

我创建了一个 GUI,其中包含一个 JButton,但它只显示一个模糊的按钮。

看到这里你就明白我的意思了。

enter image description here

这是我的主类的代码:

    Gui gui = new Gui();
    gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    gui.setSize(300,  300);
    gui.setVisible(true);

gui类代码:

import javax.swing.JFrame;
import javax.swing.JOptionPane;

import java.awt.FlowLayout;

import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Gui extends JFrame {
    public Gui() {
        super("testing buttons");
        getContentPane().setLayout(new FlowLayout());

        JButton btnClickMe = new JButton("Click me");
        getContentPane().add(btnClickMe);
    }

}

有人知道如何解决这个问题吗?

最佳答案

没有理由打电话

super("testing buttons");

要设置标题,只需使用:

gui.setTitle("testing buttons");

您运行的是什么操作系统?

关于java - 如何修复 Eclipse 中模糊的 Swing 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27412096/

相关文章:

java - 在构造函数中处理 JDialog

java - 将 JLabel 添加到 JFrame

Java:反射(在运行时)与镜像(在注释处理时)

java - 使用分词器提取句子

java - Junit 参数化测试失败,并出现 java.lang.IllegalArgumentException : argument type mismatch

java - 为什么我的简单 Struts2 示例不起作用?

java - shell 提示使用 jsch 触发多个命令

java - 两个文本字段之间的乘法 - Android Java

java - Spring MVC Http 状态 404

java - 使用 JTable 显示 Arraylist 的值