Package javax.swing.plaf.basic

Examples of javax.swing.plaf.basic.BasicSliderUI


      {
        final MouseListener[] listeners = getMouseListeners();
        for (final MouseListener l : listeners) {
          removeMouseListener(l); // remove UI-installed TrackListener
        }
        final BasicSliderUI ui = (BasicSliderUI) getUI();
        final BasicSliderUI.TrackListener tl = ui.new TrackListener() {
          // this is where we jump to absolute value of click
          @Override
          public void mouseClicked(final MouseEvent e) {
            final Point p = e.getPoint();
            final int value = ui.valueForXPosition(p.x);

            setValue(value);

          }
View Full Code Here


   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    JSlider slider1 = new JSlider(JSlider.HORIZONTAL);
    BasicSliderUI ui1 = new BasicSliderUI(slider1);
    slider1.setUI(ui1);
    Dimension d1 = ui1.getMaximumSize(slider1);
    harness.check(d1, new Dimension(32767, 20));
       
    slider1.setPaintTicks(true);
    slider1.setMajorTickSpacing(10);
    d1 = ui1.getMaximumSize(slider1);
    harness.check(d1, new Dimension(32767, 28));

    JSlider slider2 = new JSlider(JSlider.VERTICAL);
    BasicSliderUI ui2 = new BasicSliderUI(slider2);
    slider2.setUI(ui2);
    Dimension d2 = ui2.getMaximumSize(slider2);
    harness.check(d2, new Dimension(20, 32767));

    slider2.setPaintTicks(true);
    slider2.setMajorTickSpacing(10);
    d2 = ui2.getMaximumSize(slider2);
    harness.check(d2, new Dimension(28, 32767));

    // try null argument - the argument is ignored, probably the implementation
    // uses the internal slider reference
    d2 = ui2.getMaximumSize(null);
    harness.check(d2, new Dimension(28, 32767));
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    JSlider slider1 = new JSlider(JSlider.HORIZONTAL);
    BasicSliderUI ui1 = new BasicSliderUI(slider1);
    slider1.setUI(ui1);
    Dimension d1 = ui1.getMinimumSize(slider1);
    harness.check(d1, new Dimension(36, 20));
       
    slider1.setPaintTicks(true);
    slider1.setMajorTickSpacing(10);
    d1 = ui1.getMinimumSize(slider1);
    harness.check(d1, new Dimension(36, 28));

    JSlider slider2 = new JSlider(JSlider.VERTICAL);
    BasicSliderUI ui2 = new BasicSliderUI(slider2);
    slider2.setUI(ui2);
    Dimension d2 = ui2.getMinimumSize(slider2);
    harness.check(d2, new Dimension(20, 36));

    slider2.setPaintTicks(true);
    slider2.setMajorTickSpacing(10);
    d2 = ui2.getMinimumSize(slider2);
    harness.check(d2, new Dimension(28, 36));

    // try null argument - the argument is ignored, probably the implementation
    // uses the internal slider reference
    d2 = ui2.getMinimumSize(null);
    harness.check(d2, new Dimension(28, 36));
 
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JSlider slider1 = new JSlider(JSlider.HORIZONTAL);
    slider1.setBounds(10, 20, 400, 40);
    BasicSliderUI ui1 = new BasicSliderUI(slider1);
    slider1.setUI(ui1);
    harness.check(ui1.valueForXPosition(0), 0);
    harness.check(ui1.valueForXPosition(200), 50);
    harness.check(ui1.valueForXPosition(400), 100);
    harness.check(ui1.valueForXPosition(-50), 0);
    harness.check(ui1.valueForXPosition(450), 100);
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)     
  {
    JSlider slider1 = new JSlider(JSlider.HORIZONTAL);
    BasicSliderUI ui1 = new BasicSliderUI(slider1);
    slider1.setUI(ui1);
    Dimension d1 = ui1.getPreferredSize(slider1);
    harness.check(d1, new Dimension(200, 20));
   
    slider1.setPaintTicks(true);
    slider1.setMajorTickSpacing(10);
    d1 = ui1.getPreferredSize(slider1);
    harness.check(d1, new Dimension(200, 28));
   
    JSlider slider2 = new JSlider(JSlider.VERTICAL);
    BasicSliderUI ui2 = new BasicSliderUI(slider2);
    slider2.setUI(ui2);
    Dimension d2 = ui2.getPreferredSize(slider2);
    harness.check(d2, new Dimension(20, 200));
   
    slider2.setPaintTicks(true);
    slider2.setMajorTickSpacing(10);
    d2 = ui2.getPreferredSize(slider2);
    harness.check(d2, new Dimension(28, 200));
   
    // try null argument - the argument is ignored, probably the implementation
    // uses the internal slider reference
    d2 = ui2.getPreferredSize(null);
    harness.check(d2, new Dimension(28, 200));
  }
View Full Code Here

   */
  public void test(TestHarness harness)     
  {
    JSlider slider1 = new JSlider(JSlider.VERTICAL);
    slider1.setBounds(10, 20, 40, 400);
    BasicSliderUI ui1 = new BasicSliderUI(slider1);
    slider1.setUI(ui1);
    harness.check(ui1.valueForYPosition(0), 100);
    harness.check(ui1.valueForYPosition(200), 50);
    harness.check(ui1.valueForYPosition(400), 0);
    harness.check(ui1.valueForYPosition(-50), 100);
    harness.check(ui1.valueForYPosition(450), 0);
  }
View Full Code Here

    // http://stackoverflow.com/questions/518471/jslider-question-position-after-leftclick
    // http://stackoverflow.com/a/936725/1250278
    for (MouseListener li: getMouseListeners()) {
      removeMouseListener(li);
    }
    final BasicSliderUI ui = (BasicSliderUI) getUI();
    MouseListener li = ui.new TrackListener() {
      @Override
      public void mousePressed(MouseEvent e) {
        followCursor(e);
      }
      @Override
      public boolean shouldScroll(int direction) {
        return false;
      }

      private void followCursor(MouseEvent e) {
        Point p = e.getPoint();
        setValue(ui.valueForXPosition(p.x));
      }
    };
    addMouseListener(li);

  }
View Full Code Here

TOP

Related Classes of javax.swing.plaf.basic.BasicSliderUI

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.