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

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

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

JSlider.getWidth介绍

暂无

代码示例

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

protected void calculateFocusRect() {
  focusRect.x = insetCache.left;
  focusRect.y = insetCache.top;
  focusRect.width = slider.getWidth()
      - (insetCache.left + insetCache.right);
  focusRect.height = slider.getHeight()
      - (insetCache.top + insetCache.bottom);
}

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

protected void calculateFocusRect() {
  focusRect.x = insetCache.left;
  focusRect.y = insetCache.top;
  focusRect.width = slider.getWidth()
      - (insetCache.left + insetCache.right);
  focusRect.height = slider.getHeight()
      - (insetCache.top + insetCache.bottom);
}

代码示例来源:origin: joel-costigliola/assertj-swing

@Override
@RunsInCurrentThread
int max(@Nonnull JSlider slider, @Nonnull Insets insets) {
 return slider.getWidth() - insets.left - insets.right - 1;
}

代码示例来源:origin: khuxtable/seaglass

/**
 * Calculates the pad for the label at the specified index.
 * 
 * @param index
 *            index of the label to calculate pad for.
 * @return padding required to keep label visible.
 */
private int getPadForLabel(int i) {
  Dictionary dictionary = slider.getLabelTable();
  int pad = 0;
  Object o = dictionary.get(i);
  if (o != null) {
    Component c = (Component) o;
    int centerX = xPositionForValue(i);
    int cHalfWidth = c.getPreferredSize().width / 2;
    if (centerX - cHalfWidth < insetCache.left) {
      pad = Math.max(pad, insetCache.left - (centerX - cHalfWidth));
    }
    if (centerX + cHalfWidth > slider.getWidth() - insetCache.right) {
      pad = Math.max(pad, (centerX + cHalfWidth) - (slider.getWidth() - insetCache.right));
    }
  }
  return pad;
}

代码示例来源:origin: sc.fiji/bigdataviewer-core

private void updateNumberFormat()
{
  if ( userDefinedNumberFormat )
    return;
  final int sw = slider.getWidth();
  if ( sw > 0 )
  {
    final double range = dmax - dmin;
    final int digits = ( int ) Math.ceil( Math.log10( sw / range ) );
    final NumberEditor numberEditor = ( ( JSpinner.NumberEditor ) spinner.getEditor() );
    numberEditor.getFormat().setMaximumFractionDigits( digits );
    numberEditor.stateChanged( new ChangeEvent( spinner ) );
  }
}

代码示例来源:origin: pvto/konte-art

public void mouseClicked(MouseEvent e)
  {
    if (e.getButton() == MouseEvent.BUTTON1)
    {
      int val = jSlider1.getValue();
      int add =
          (e.getX() > jSlider1.getWidth() * (val - jSlider1.getMinimum()) / (jSlider1.getMaximum() - jSlider1.getMinimum()) ? 1 : -1);
      addToSlider(add);
    }
  }
});

代码示例来源:origin: joel-costigliola/assertj-swing

@RunsInCurrentThread
final @Nonnull Point locationForValue(JSlider slider, int value) {
 Point center = new Point(slider.getWidth() / 2, slider.getHeight() / 2);
 int max = max(slider, checkNotNull(slider.getInsets()));
 int coordinate = (int) (percent(slider, value) * max);
 if (!slider.getInverted()) {
  coordinate = max - coordinate;
 }
 return update(center, coordinate);
}

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

private ComponentLocation valueToLocation(JSlider s, int value) {
  int range = s.getMaximum() - s.getMinimum();
  int x = s.getWidth()/2;
  int y = s.getHeight()/2;
  Insets insets = s.getInsets();
  float percent = (float)(value - s.getMinimum()) / range;
  if (s.getOrientation() == JSlider.VERTICAL) {
    int max = s.getHeight() - insets.top - insets.bottom - 1;
    y = (int)(percent * max);
    if (!s.getInverted()) {
      y = max - y;
    }
  }
  else {
    int max = s.getWidth() - insets.left - insets.right - 1;
    x = (int)(percent * max);
    if (s.getInverted()) {
      x = max - x;
    }
  }
  return new ComponentLocation(new Point(x, y));
}

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

trackLeft = (this.insetCache.left + this.focusInsets.left + this.slider.getWidth() - this.insetCache.right - this.focusInsets.right) / 2 - trackWidth / 2;
  trackRight = trackLeft + trackWidth - 1;
} else {
  trackRight = (this.insetCache.left + this.focusInsets.left + this.slider.getWidth() - this.insetCache.right - this.focusInsets.right) / 2 + trackWidth / 2;
  trackLeft = trackRight - trackWidth - 1;

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

+ this.slider.getWidth() - this.insetCache.right - this.focusInsets.right)
      / 2 - trackWidth / 2;
  trackRight = trackLeft + trackWidth - 1;
} else {
  trackRight = (this.insetCache.left + this.focusInsets.left
      + this.slider.getWidth() - this.insetCache.right - this.focusInsets.right)
      / 2 + trackWidth / 2;
  trackLeft = trackRight - trackWidth - 1;

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

private void showToolTip(MouseEvent e) {
  Track s = player.getTrack();
  if (s != null) {
    toolTip.setTipText(Util.samplesToTime(progressSlider.getValue() - progressSlider.getMinimum(), s.getTrackData().getSampleRate(), 1));
    int x = e.getXOnScreen();
    x = Math.max(x, progressSlider.getLocationOnScreen().x);
    x = Math.min(x, progressSlider.getLocationOnScreen().x + progressSlider.getWidth() - toolTip.getWidth());
    popup = popupFactory.getPopup(progressSlider, toolTip, x, progressSlider.getLocationOnScreen().y + 25);
    popup.show();
  }
}

代码示例来源:origin: khuxtable/seaglass

contentDim.width = slider.getWidth() - insetCache.left - insetCache.right;
trackRect.height = tickRect.height = labelRect.height = contentDim.height - valueRect.height;
int startX = slider.getWidth() / 2 - contentDim.width / 2;
if (SeaGlassLookAndFeel.isLeftToRight(slider)) {
  if (l > w1) {

相关文章

JSlider类方法