Volume value is now padded to maintain ui element size.

This commit is contained in:
neviyn 2016-04-02 19:06:49 +01:00
parent cedd6bac8b
commit 3fb9dd1fa6

View File

@ -153,16 +153,21 @@ public class PlayerGUI extends JPanel implements PlayerCallbackInterface {
volumeSlider.setValue(player.getVolume());
panel.add(volumeSlider);
JLabel volumeValue = new JLabel();
volumeValue.setText(String.format("%d%%", player.getVolume()));
volumeValue.setText(volumeFormat(player.getVolume()));
volumeSlider.addChangeListener(e -> {
player.setVolume(((JSlider) e.getSource()).getValue());
volumeValue.setText(String.format("%d%%", player.getVolume()));
volumeValue.setText(volumeFormat(player.getVolume()));
ConfigManager.setLastVolume(player.getVolume());
});
panel.add(volumeValue);
return panel;
}
private String volumeFormat(int volume){
return String.format("%03d%%", volume);
}
/**
* Populate the top menu bar with items.
*/