Example usage for javax.swing JButton getX

List of usage examples for javax.swing JButton getX

Introduction

In this page you can find the example usage for javax.swing JButton getX.

Prototype

@BeanProperty(bound = false)
public int getX() 

Source Link

Document

Returns the current x coordinate of the component's origin.

Usage

From source file:org.rdv.ui.TimeSlider.java

/**
 * Called when the mouse is dragged. This deals dragging the time value and
 * range controls.// w  ww . ja v a2  s  . c om
 * 
 * @param me  the mosue event that triggered this 
 */
public void mouseDragged(MouseEvent me) {
    if (!isEnabled()) {
        return;
    }

    JButton button = (JButton) me.getSource();
    int x = me.getX();
    if (button == startButton) {
        x += endButton.getWidth() - clickStart;
    } else if (button == valueButton) {
        x += Math.round(valueButton.getWidth() / 2d) - clickStart;
    } else if (button == endButton) {
        x -= clickStart;
    }
    double time = getTimeFromX(button.getX() + x);

    if (button == startButton) {
        if (time < minimum) {
            time = minimum;
        } else if (time >= end) {
            time = end;
        }

        setStart(time);
    } else if (button == valueButton) {
        if (rangeChangeable) {
            if (time < start) {
                time = start;
            } else if (time > end) {
                time = end;
            }
        } else {
            if (time < minimum) {
                time = minimum;
            } else if (time > maximum) {
                time = maximum;
            }
        }

        setValue(time);
    } else if (button == endButton) {
        if (time < start) {
            time = start;
        } else if (time > maximum) {
            time = maximum;
        }

        setEnd(time);
    }
}