I've made a gui for my program and used
UIManager.put("Button.background", new Color(0,0,0));
UIManager.put("JButton.background", new Color(0,0,0));
to make the buttons appear black. Unfortunately, this doesn't work sometimes. Without modifying the code, it will work when I run it one time and wont work another time.
The following image is the same button in the same program after several times I ran it. This happens about 1 in 4 times I run the program.
(left button is correct and the right one is what sometimes happens while running)
Also, other things like
UIManager.put("control", new Color(15,0,0));
are loading properly. Never had a problem with it and it's loaded at the same time and same format.
EDIT: Here's a sample code where the button colors aren't loading at all while the background and other things are. They are loaded the same exact way and there are no compilation or run errors.
import java.awt.*;
import javax.swing.*;
import javax.swing.UIManager.*;
public class gtst
{
public static void main(String[] args) throws Exception
{
UIManager.put("Button.background", new Color(1,1,1));
UIManager.put("JButton.background", new Color(1,1,1));
UIManager.put("control", new Color(0,0,0));
UIManager.put("text", new Color(255,220,0));
Frame batFrame = new JFrame("nananananna Batman!");
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels())
{
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
String username = JOptionPane.showInputDialog(batFrame, "Enter something...:");
}
}