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

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

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

JSlider.setMajorTickSpacing介绍

暂无

代码示例

代码示例来源:origin: MovingBlocks/Terasology

public PropertySlider() {
  titledBorder = new TitledBorder("");
  setBorder(titledBorder);
  borderLayout = new BorderLayout();
  setLayout(borderLayout);
  label = new JLabel("");
  slider = new JSlider();
  slider.setMinimum(0);
  slider.setMaximum(100);
  slider.setMinorTickSpacing(1);
  slider.setMajorTickSpacing(10);
  slider.addChangeListener(this);
  add(slider, BorderLayout.CENTER);
  add(label, BorderLayout.EAST);
}

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

mainPanel.add(lblMaxZoom);
sliMinZoom.addChangeListener(new ChangeListener() {
   @Override
   public void stateChanged(ChangeEvent e) {
sliMinZoom.setMinimum(0);
sliMinZoom.setMaximum(22);
sliMinZoom.setMajorTickSpacing(1);
sliMinZoom.setMinorTickSpacing(1);
sliMinZoom.setValue(0);
gbcpanel0.gridx = 1;
mainPanel.add(sliMinZoom);
sliMaxZoom.addChangeListener(new ChangeListener() {
   @Override
   public void stateChanged(ChangeEvent e) {
sliMaxZoom.setMinimum(0);
sliMaxZoom.setValue(10);
sliMaxZoom.setMajorTickSpacing(1);
sliMaxZoom.setMinorTickSpacing(1);
gbcpanel0.gridx = 1;
gbcpanel0.gridy = 4;

代码示例来源:origin: stackoverflow.com

// orientation, min, max, initial value
final JSlider slider = new JSlider(SwingConstants.HORIZONTAL, 0, 2, 1);
slider.setSnapToTicks(true); // only allow 0, 1, 2 and not in between
slider.setPaintTicks(true); // paint ticks at tick spacing interval
slider.setMajorTickSpacing(1); // set interval to 1
slider.setPaintLabels(true); // show labels on ticks

代码示例来源:origin: robotframework/SwingLibrary

private JSlider testSlider() {
  JSlider slider = new JSlider(0, 5);
  slider.setName("testSlider");
  slider.setMajorTickSpacing(1);
  slider.setPaintTicks(true);
  return slider;
}

代码示例来源:origin: stackoverflow.com

public class SliderPane extends JPanel {

  private JSlider diameterJSlider;
  private Circle1 myPanel;

  public SliderPane() {

    setLayout(new BorderLayout());

    myPanel = new Circle1();

    diameterJSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 300, 10);
    diameterJSlider.setMajorTickSpacing(10);
    diameterJSlider.setPaintTicks(true);
    diameterJSlider.addChangeListener(new ChangeListener() {
      public void stateChanged(ChangeEvent e) {
        myPanel.setDiameter(diameterJSlider.getValue());
      }
    }
    );
    add(diameterJSlider, BorderLayout.NORTH);
    add(myPanel, BorderLayout.CENTER);
  }
}

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

public JSlider getSlider(int min, int max, int value) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, min, max, value);
    slider.setMajorTickSpacing(10);
    slider.setMinorTickSpacing(1);
//        slider.setPaintLabels(true);
//        slider.setUI(new WindowsSliderUI(slider));
    slider.setForeground(AppThemeColor.TEXT_DEFAULT);
    slider.setFont(REGULAR_FONT.deriveFont(15f));
    slider.setRequestFocusEnabled(false);
    slider.addMouseMotionListener(new MouseMotionAdapter() {
      @Override
      public void mouseDragged(MouseEvent e) {
        slider.getParent().repaint();
      }
    });
    slider.setBackground(AppThemeColor.FRAME);
    return slider;
  }

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

sldVolume = new javax.swing.JSlider();
btnRewind = new javax.swing.JButton();
btnStop = new javax.swing.JButton();
pnlBar = new javax.swing.JPanel();
lblTime = new javax.swing.JLabel();
sldBar = new javax.swing.JSlider();
sldVolume.setMajorTickSpacing(20);
sldVolume.setOrientation(javax.swing.JSlider.VERTICAL);
sldVolume.setPaintTicks(true);
sldVolume.setValue(100);
sldVolume.addChangeListener(new javax.swing.event.ChangeListener() {
  public void stateChanged(javax.swing.event.ChangeEvent evt) {
    sldVolumeStateChanged(evt);
sldBar.addChangeListener(new javax.swing.event.ChangeListener() {
  public void stateChanged(javax.swing.event.ChangeEvent evt) {
    sldBarStateChanged(evt);

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
  brightnessSlider = new javax.swing.JSlider();
  setLayout(new java.awt.BorderLayout());
  brightnessSlider.setMajorTickSpacing(50);
  brightnessSlider.setOrientation(javax.swing.JSlider.VERTICAL);
  brightnessSlider.setPaintTicks(true);
  add(brightnessSlider, java.awt.BorderLayout.EAST);
}//GEN-END:initComponents

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

public JETABean createBean(String compName, boolean instantiateBean, boolean setDefaults) throws FormException {
    JETABean jbean = super.createBean(compName, instantiateBean, setDefaults);
    Component comp = jbean.getDelegate();
    if (comp instanceof JSlider && setDefaults) {
      JSlider slider = (JSlider) comp;
      slider.setMajorTickSpacing(20);
      slider.setMaximum(100);
      slider.setPaintTicks(true);
      slider.setPaintLabels(true);
    }
    return jbean;
  }
}

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

int max = 13;
int deflt = (int) (Math.log(this.fftSize) / Math.log(2));
JSlider fftSizeSlider = new JSlider(JSlider.VERTICAL, min, max, deflt);
fftSizeSlider.setAlignmentX(CENTER_ALIGNMENT);
fftSizeSlider.setMajorTickSpacing(1);
fftSizeSlider.setPaintTicks(true);
fftSizeSlider.setSnapToTicks(true);
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
fftSizeSlider.setPaintLabels(true);
fftSizeSlider.addChangeListener(new ChangeListener() {
  public void stateChanged(ChangeEvent ce) {
    JSlider source = (JSlider) ce.getSource();

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

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
  brightnessSlider = new javax.swing.JSlider();
  setLayout(new java.awt.BorderLayout());
  brightnessSlider.setMajorTickSpacing(50);
  brightnessSlider.setOrientation(javax.swing.JSlider.VERTICAL);
  brightnessSlider.setPaintTicks(true);
  add(brightnessSlider, java.awt.BorderLayout.EAST);
}//GEN-END:initComponents

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

int max = 13;
int deflt = (int) (Math.log(this.fftSize) / Math.log(2));
JSlider fftSizeSlider = new JSlider(JSlider.VERTICAL, min, max, deflt);
fftSizeSlider.setAlignmentX(CENTER_ALIGNMENT);
fftSizeSlider.setMajorTickSpacing(1);
fftSizeSlider.setPaintTicks(true);
fftSizeSlider.setSnapToTicks(true);
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
fftSizeSlider.setPaintLabels(true);
fftSizeSlider.addChangeListener(new ChangeListener() {
  public void stateChanged(ChangeEvent ce) {
    JSlider source = (JSlider) ce.getSource();

代码示例来源:origin: robo-code/robocode

private JSlider createBattlefieldSizeSlider() {
  JSlider slider = new JSlider();
  slider.setMinimum(MIN_BATTLEFIELD_SIZE);
  slider.setMaximum(MAX_BATTLEFIELD_SIZE);
  slider.setMajorTickSpacing(BATTLEFIELD_STEP_SIZE);
  slider.setSnapToTicks(true);
  slider.setPaintTicks(true);
  return slider;
}

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

int max = 13;
int deflt = (int) (Math.log(this.fftSize) / Math.log(2));
JSlider fftSizeSlider = new JSlider(JSlider.VERTICAL, min, max, deflt);
fftSizeSlider.setAlignmentX(CENTER_ALIGNMENT);
fftSizeSlider.setMajorTickSpacing(1);
fftSizeSlider.setPaintTicks(true);
fftSizeSlider.setSnapToTicks(true);
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
fftSizeSlider.setPaintLabels(true);
fftSizeSlider.addChangeListener(new ChangeListener() {
  public void stateChanged(ChangeEvent ce) {
    JSlider source = (JSlider) ce.getSource();

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

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
private void initComponents() {//GEN-BEGIN:initComponents
  brightnessSlider = new javax.swing.JSlider();
  setLayout(new java.awt.BorderLayout());
  brightnessSlider.setMajorTickSpacing(50);
  brightnessSlider.setOrientation(javax.swing.JSlider.VERTICAL);
  brightnessSlider.setPaintTicks(true);
  add(brightnessSlider, java.awt.BorderLayout.EAST);
}//GEN-END:initComponents

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

int max = 13;
int deflt = (int) (Math.log(this.fftSize) / Math.log(2));
JSlider fftSizeSlider = new JSlider(JSlider.VERTICAL, min, max, deflt);
fftSizeSlider.setAlignmentX(CENTER_ALIGNMENT);
fftSizeSlider.setMajorTickSpacing(1);
fftSizeSlider.setPaintTicks(true);
fftSizeSlider.setSnapToTicks(true);
Hashtable<Integer, JLabel> labelTable = new Hashtable<Integer, JLabel>();
fftSizeSlider.setPaintLabels(true);
fftSizeSlider.addChangeListener(new ChangeListener() {
  public void stateChanged(ChangeEvent ce) {
    JSlider source = (JSlider) ce.getSource();

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
  brightnessSlider = new javax.swing.JSlider();
  setBorder(javax.swing.BorderFactory.createEmptyBorder(4, 6, 6, 6));
  setLayout(new java.awt.BorderLayout());
  brightnessSlider.setMajorTickSpacing(50);
  brightnessSlider.setOrientation(javax.swing.JSlider.VERTICAL);
  brightnessSlider.setPaintTicks(true);
  add(brightnessSlider, java.awt.BorderLayout.EAST);
}// </editor-fold>//GEN-END:initComponents

代码示例来源:origin: 4thline/cling

volumeSlider = new JSlider(JSlider.HORIZONTAL, minVolume, maxVolume, maxVolume / 2);
volumeSlider.setBorder(BorderFactory.createTitledBorder("Volume"));
volumeSlider.setMajorTickSpacing(maxVolume / 5);
volumeSlider.setMinorTickSpacing(5);
volumeSlider.setPaintTicks(true);
volumeSlider.setPaintLabels(true);
volumeSlider.addChangeListener(new ChangeListener() {

代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw

private JPanel createSliderChooser(ColorSpace sys, boolean vertical) {
  JPanel p = new JPanel(new GridLayout(vertical ? 1 : 0, vertical ? 0 : 1));
  DefaultColorSliderModel m = new DefaultColorSliderModel(sys);
  models.add(m);
  if (!vertical) {
    p.add(new JLabel(
        "<html>" + ColorUtil.getName(sys)), BorderLayout.NORTH);
  }
  m.addChangeListener(handler);
  for (int i = 0;
      i < m.getComponentCount();
      i++) {
    JSlider s = new JSlider(JSlider.HORIZONTAL);
    s.setMajorTickSpacing(50);
    s.setPaintTicks(true);
    s.setOrientation(vertical ? JSlider.VERTICAL : JSlider.HORIZONTAL);
    m.configureSlider(i, s);
    p.add(s);
  }
  return p;
}

代码示例来源:origin: apache/pdfbox

slider = new JSlider(0, 100, 50);
slider.setMajorTickSpacing(50);
slider.setPaintTicks(true);
labelTable.put(100, darkest);
slider.setPaintLabels(true);
slider.setLabelTable(labelTable);
slider.addChangeListener(this);

相关文章

JSlider类方法