I'm starting to develop a window that i'll be using in future games that i'll create. This is a customized JFrame which i made undecorated, and created my own borders, and i'm currently adding an exit button.

The problem is this: Currently, the jbutton appears, but if you look down the code to see the bold/underlined statement, it basically adds a PNG image to the jbutton.

This works perfectly, but when I un-comment those lines (or just even the ImageIcon line), the button only appears when the mouse hovers over the JButton. Is this a glitch with swing? because I don't even add the image to the jbutton, and the button still doesn't appear...

if you need some more code, i'll send the code for the frame; thank you.


//adds an exit button in top right corner
public void addExitButton()
{
int panelSize = 30; //size of panel and button
JPanel exitPanel = new JPanel();
exitPanel.setSize(panelSize, panelSize); //panel is a square
exitPanel.setLocation(WIDTH-panelSize-2, 2); //Top Right corner
exitPanel.setBackground(new Color(0,0,0,0)); //makes panel transparent

JButton exitButton = new JButton();
exitButton.setSize(panelSize, panelSize); //button size = panel size
//ImageIcon i = new ImageIcon("images\\ExitButton1.png");
//exitButton.setIcon(i); //get exit image


//exitButton.setBorderPainted(false); //remove button border
exitButton.setBackground(new Color(0,0,0,0)); //makes button transparent

exitButton.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//if button pressed
Graphics g = getGraphics();
g.setFont(new Font("Times New Roman", Font.ITALIC, 75));
g.setColor(Color.RED);
g.drawString("Exiting...", 175, 175);

try
{
Thread.sleep(250);
}
catch(Exception ex) {}

System.exit(0); //terminates JVM
}
});

exitPanel.add(exitButton);
this.add(exitPanel);
}