Skip to content

Instantly share code, notes, and snippets.

@kleinlennart
Last active May 24, 2018 11:17
Show Gist options
  • Save kleinlennart/4a41f7466f7a7de9727182363c032168 to your computer and use it in GitHub Desktop.
Save kleinlennart/4a41f7466f7a7de9727182363c032168 to your computer and use it in GitHub Desktop.
Default Generater for JProgressBar (Colour setter not working on MacOS)
UIManager.put("ProgressBar.selectionBackground", Color.red);
UIManager.put("ProgressBar.selectionForeground", Color.red);
UIManager.put("ProgressBar.foreground", Color.red);
UIManager.put("ProgressBar.background", Color.red);
JProgressBar bar = new JProgressBar();
bar.setMaximum(50);
bar.setMinimum(0);
bar.setBounds(30, 118, 235, 41);
bar.setValue(n);
bar.setString(bar.getValue() + "/" + bar.getMaximum() + " HP");
bar.setStringPainted(true);
frame.getContentPane().add(bar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment