1

I created a GUI with one JButton in it but it just shows a blurry button.

Here you see what I mean.

enter image description here

This is the code of my main class:

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

Code of gui class:

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);
    }

}

Does anyone know how to fix this?

1 Answers1

0

There is no reason to call

super("testing buttons");

To set the title, just use:

gui.setTitle("testing buttons");

What operating system are you running?

MitchAman
  • 116
  • 5