javax.swing.JSlider.addMouseListener()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中javax.swing.JSlider.addMouseListener()方法的一些代码示例,展示了JSlider.addMouseListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.addMouseListener()方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:addMouseListener

JSlider.addMouseListener介绍

暂无

代码示例

代码示例来源:origin: com.hazelcast.simulator/visualizer

public static void addHorizontalMouseListener(final JPanel panel, final JSlider slider) {
  slider.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      Point p = e.getPoint();
      double percent = p.x / ((double) panel.getWidth());
      int range = slider.getMaximum() - slider.getMinimum();
      double newVal = range * percent;
      int result = (int) (slider.getMinimum() + newVal);
      slider.setValue(result);
    }
  });
}

代码示例来源:origin: com.hazelcast.simulator/visualiser

public static void addHorizontalMouseListener(final JPanel panel, final JSlider slider) {
  slider.addMouseListener(new MouseAdapter() {
    @Override
    public void mousePressed(MouseEvent e) {
      Point p = e.getPoint();
      double percent = p.x / ((double) panel.getWidth());
      int range = slider.getMaximum() - slider.getMinimum();
      double newVal = range * percent;
      int result = (int) (slider.getMinimum() + newVal);
      slider.setValue(result);
    }
  });
}

代码示例来源:origin: com.hazelcast.simulator/visualizer

public static void addVerticalMouseListener(final JPanel panel, final JSlider slider) {
    slider.addMouseListener(new MouseAdapter() {
      @Override
      public void mousePressed(MouseEvent e) {
        Point p = e.getPoint();
        double percent = p.y / ((double) panel.getHeight());
        int range = slider.getMaximum() - slider.getMinimum();
        double newVal = range * percent;
        int result = (int) (slider.getMaximum() - newVal);
        slider.setValue(result);
      }
    });
  }
}

代码示例来源:origin: com.hazelcast.simulator/visualiser

public static void addVerticalMouseListener(final JPanel panel, final JSlider slider) {
    slider.addMouseListener(new MouseAdapter() {
      @Override
      public void mousePressed(MouseEvent e) {
        Point p = e.getPoint();
        double percent = p.y / ((double) panel.getHeight());
        int range = slider.getMaximum() - slider.getMinimum();
        double newVal = range * percent;
        int result = (int) (slider.getMaximum() - newVal);
        slider.setValue(result);
      }
    });
  }
}

代码示例来源:origin: tulskiy/musique

@Override
  public void run() {
    for (MouseListener ml : progressSlider.getMouseListeners()) {
      progressSlider.removeMouseListener(ml);
    }
    progressSlider.addMouseListener(progressMouseListener);
  }
});

代码示例来源:origin: Exslims/MercuryTrade

public JSlider getVolumeSlider(AdrDurationComponentDescriptor descriptor) {
  JSlider notificationSlider = this.componentsFactory.getSlider(-40, 6, descriptor.getSoundDescriptor().getDb().intValue(), AppThemeColor.ADR_BG);
  notificationSlider.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseReleased(MouseEvent e) {
      if (!descriptor.getSoundDescriptor().getWavPath().equals("...")) {
        descriptor.getSoundDescriptor().setDb(notificationSlider.getValue() == -40 ? -80f : (float) notificationSlider.getValue());
        MercuryStoreCore.soundDescriptorSubject.onNext(descriptor.getSoundDescriptor());
        MercuryStoreUI.adrReloadSubject.onNext(descriptor);
      }
    }
  });
  return notificationSlider;
}

代码示例来源:origin: sc.fiji/Color_Inspector_3D

private JSlider makeTitledVerticalSilder(String string, Color color, int minVal, int maxVal, int val) {
  //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() );
  JSlider slider = new JSlider(JSlider.VERTICAL, minVal, maxVal, val );
  TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), //empty,
      "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM,
      new Font("Sans", Font.PLAIN, 11));
  tb.setTitle(string);
  //tb.setTitleJustification(TitledBorder.LEFT);
  tb.setTitleColor(color);
  slider.setBorder(tb);
  slider.setMajorTickSpacing((maxVal - minVal)/6 );
  slider.setPaintTicks(true);
  slider.addChangeListener( this );
  slider.addChangeListener( this );
  slider.addMouseListener(this);
  return slider;
}

代码示例来源:origin: sc.fiji/Color_Inspector_3D

private JSlider makeTitledSilder(String string, Color color, int minVal, int maxVal, int val) {
  //Border empty = BorderFactory.createTitledBorder( BorderFactory.createEmptyBorder() );
  JSlider slider = new JSlider(JSlider.HORIZONTAL, minVal, maxVal, val );
  TitledBorder tb = new TitledBorder(BorderFactory.createEtchedBorder(), 
      //empty,
      "", TitledBorder.CENTER, TitledBorder.ABOVE_BOTTOM,
      new Font("Sans", Font.PLAIN, 11));
  tb.setTitle(string);
  tb.setTitleJustification(TitledBorder.LEFT);
  tb.setTitleColor(color);
  slider.setBorder(tb);
  slider.setMajorTickSpacing((maxVal - minVal)/6 );
  //slider.setMajorTickSpacing((maxVal - minVal)/10 );
  slider.setPaintTicks(true);
  slider.addChangeListener( this );
  slider.addChangeListener( this );
  slider.addMouseListener(this);
  return slider;
}

代码示例来源:origin: Exslims/MercuryTrade

public JPanel getFpsSliderPanel(AdrCaptureDescriptor descriptor) {
  JPanel fpsPanel = this.componentsFactory.getJPanel(new BorderLayout(), AppThemeColor.ADR_BG);
  JLabel fpsCountLabel = this.componentsFactory.getTextLabel(String.valueOf(descriptor.getFps()));
  fpsCountLabel.setPreferredSize(new Dimension(30, 26));
  JSlider fpsSlider = this.componentsFactory.getSlider(1, 60, descriptor.getFps());
  fpsSlider.setBackground(AppThemeColor.SLIDE_BG);
  fpsSlider.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseReleased(MouseEvent e) {
      descriptor.setFps(fpsSlider.getValue());
      fpsCountLabel.setText(String.valueOf(fpsSlider.getValue()));
      MercuryStoreUI.adrReloadSubject.onNext(descriptor);
    }
  });
  fpsPanel.add(fpsCountLabel, BorderLayout.LINE_START);
  fpsPanel.add(fpsSlider, BorderLayout.CENTER);
  return fpsPanel;
}

代码示例来源:origin: Exslims/MercuryTrade

public JSlider getOpacitySlider(AdrComponentDescriptor descriptor) {
  JSlider opacitySlider = this.componentsFactory.getSlider(20, 100, (int) (descriptor.getOpacity() * 100));
  opacitySlider.setBackground(AppThemeColor.SLIDE_BG);
  opacitySlider.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseReleased(MouseEvent e) {
      descriptor.setOpacity(opacitySlider.getValue() / 100f);
      MercuryStoreUI.adrReloadSubject.onNext(descriptor);
    }
  });
  return opacitySlider;
}

代码示例来源:origin: sdedit/sdedit

scalePanel = new ScalePanel(true);
scalePanel.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
scalePanel.getSlider().addMouseListener(ml);
scalePanel.setScalable(zoomPane);

代码示例来源:origin: Exslims/MercuryTrade

notificationSlider.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseReleased(MouseEvent e) {
chatScannerSlider.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseReleased(MouseEvent e) {
clicksSlider.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseReleased(MouseEvent e) {
updateSlider.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseReleased(MouseEvent e) {

代码示例来源:origin: lbalazscs/Pixelitor

@Override
protected void installListeners(JSlider slider) {
  super.installListeners(slider);
  slider.removeMouseListener(trackListener);
  slider.removeMouseMotionListener(trackListener);
  slider.addMouseListener(myMouseListener);
  slider.addMouseMotionListener(myMouseListener);
  slider.setOpaque(false);
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void installListeners(JSlider slider) {
  slider.addMouseListener(trackListener);
  slider.addMouseMotionListener(trackListener);
  slider.addFocusListener(focusListener);
  slider.addComponentListener(componentListener);
  slider.addPropertyChangeListener(propertyChangeListener);
  slider.getModel().addChangeListener(changeListener);
}

代码示例来源:origin: com.synaptix/SynaptixSwing

protected void installListeners(JSlider slider) {
  slider.addMouseListener(trackListener);
  slider.addMouseMotionListener(trackListener);
  slider.addFocusListener(focusListener);
  slider.addComponentListener(componentListener);
  slider.addPropertyChangeListener(propertyChangeListener);
  slider.getModel().addChangeListener(changeListener);
}

代码示例来源:origin: RPTools/maptool

ZoomChangeListener zoomListener = new ZoomChangeListener();
zoomSlider.addChangeListener(zoomListener);
zoomSlider.addMouseListener(zoomListener);

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void installListeners(final JSlider slider) {
  super.installListeners(slider);
  this.substanceRolloverListener = new RolloverControlListener(this,
      this.thumbModel);
  slider.addMouseListener(this.substanceRolloverListener);
  slider.addMouseMotionListener(this.substanceRolloverListener);
  this.substancePropertyChangeListener = new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      if ("enabled".equals(evt.getPropertyName())) {
        thumbModel.setEnabled(slider.isEnabled());
      }
      if ("font".equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            slider.updateUI();
          }
        });
      }
    }
  };
  this.slider
      .addPropertyChangeListener(this.substancePropertyChangeListener);
  this.stateTransitionTracker.registerModelListeners();
  this.stateTransitionTracker.registerFocusListeners();
}

代码示例来源:origin: org.java.net.substance/substance

@Override
protected void installListeners(final JSlider slider) {
  super.installListeners(slider);
  // fix for defect 109 - memory leak on changing skin
  this.substanceRolloverListener = new RolloverControlListener(this,
      this.thumbModel);
  slider.addMouseListener(this.substanceRolloverListener);
  slider.addMouseMotionListener(this.substanceRolloverListener);
  this.substancePropertyChangeListener = new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      if ("enabled".equals(evt.getPropertyName())) {
        SubstanceSliderUI.this.thumbModel.setEnabled(slider
            .isEnabled());
      }
      if ("font".equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            slider.updateUI();
          }
        });
      }
    }
  };
  this.slider
      .addPropertyChangeListener(this.substancePropertyChangeListener);
  this.stateTransitionTracker.registerModelListeners();
  this.stateTransitionTracker.registerFocusListeners();
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void installListeners(final JSlider slider) {
  super.installListeners(slider);
  // fix for defect 109 - memory leak on changing skin
  this.substanceRolloverListener = new RolloverControlListener(this,
      this.thumbModel);
  slider.addMouseListener(this.substanceRolloverListener);
  slider.addMouseMotionListener(this.substanceRolloverListener);
  this.substancePropertyChangeListener = new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if ("enabled".equals(evt.getPropertyName())) {
        SubstanceSliderUI.this.thumbModel.setEnabled(slider
            .isEnabled());
      }
      if ("font".equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            slider.updateUI();
          }
        });
      }
    }
  };
  this.slider
      .addPropertyChangeListener(this.substancePropertyChangeListener);
  this.stateTransitionTracker.registerModelListeners();
  this.stateTransitionTracker.registerFocusListeners();
}

代码示例来源:origin: com.github.insubstantial/substance

@Override
protected void installListeners(final JSlider slider) {
  super.installListeners(slider);
  this.substanceRolloverListener = new RolloverControlListener(this,
      this.thumbModel);
  slider.addMouseListener(this.substanceRolloverListener);
  slider.addMouseMotionListener(this.substanceRolloverListener);
  this.substancePropertyChangeListener = new PropertyChangeListener() {
    @Override
    public void propertyChange(PropertyChangeEvent evt) {
      if ("enabled".equals(evt.getPropertyName())) {
        thumbModel.setEnabled(slider.isEnabled());
      }
      if ("font".equals(evt.getPropertyName())) {
        SwingUtilities.invokeLater(new Runnable() {
          @Override
          public void run() {
            slider.updateUI();
          }
        });
      }
    }
  };
  this.slider
      .addPropertyChangeListener(this.substancePropertyChangeListener);
  this.stateTransitionTracker.registerModelListeners();
  this.stateTransitionTracker.registerFocusListeners();
}

相关文章

JSlider类方法