Example usage for javax.swing JProgressBar updateUI

List of usage examples for javax.swing JProgressBar updateUI

Introduction

In this page you can find the example usage for javax.swing JProgressBar updateUI.

Prototype

public void updateUI() 

Source Link

Document

Resets the UI property to a value from the current look and feel.

Usage

From source file:io.gameover.utilities.pixeleditor.Pixelizer.java

public JProgressBar getToleranceBar() {
    if (toleranceBar == null) {
        toleranceBar = new JProgressBar();
        toleranceBar.setPreferredSize(new Dimension(200, 25));
        toleranceBar.setValue(10);/*w  ww. jav a2 s .  com*/
        toleranceBar.setMaximum(100);
        toleranceBar.setStringPainted(true);
        toleranceBar.addMouseListener(new MouseAdapter() {
            public boolean mouseEntered = false;

            @Override
            public void mouseReleased(MouseEvent e) {
                if (mouseEntered) {
                    JProgressBar pb = (JProgressBar) e.getComponent();
                    pb.setValue((int) ((((double) e.getX()) / pb.getSize().getWidth()) * 100d));
                    pb.updateUI();
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
                this.mouseEntered = true;
            }

            @Override
            public void mouseExited(MouseEvent e) {
                this.mouseEntered = false;
            }
        });
    }
    return toleranceBar;
}