Example usage for javax.swing JProgressBar getSize

List of usage examples for javax.swing JProgressBar getSize

Introduction

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

Prototype

public Dimension getSize() 

Source Link

Document

Returns the size of this component in the form of a Dimension object.

Usage

From source file:Main.java

@Override
public void paint(Graphics g, JComponent c) {
    JLayer jlayer = (JLayer) c;
    JProgressBar progress = (JProgressBar) jlayer.getView();
    int w = progress.getSize().width;
    int h = progress.getSize().height;

    if (bi == null || w != prevw || h != prevh) {
        bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    }/*  w  ww.  j a  v a  2  s.c  o m*/
    prevw = w;
    prevh = h;

    Graphics2D g2 = bi.createGraphics();
    super.paint(g2, c);
    g2.dispose();

    Image image = c.createImage(new FilteredImageSource(bi.getSource(), new RedGreenChannelSwapFilter()));
    g.drawImage(image, 0, 0, c);
}

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 w w  . j  a  va 2s .c o m*/
        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;
}