javax.swing.JSlider类的使用及代码示例

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

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

JSlider介绍

暂无

代码示例

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

@Override
   public void stateChanged(ChangeEvent e) {
     lblMinZoom.setText("MinZoom: (" + sliMinZoom.getValue() + ")");
   }
});

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

protected JPanel createControls() {
  JPanel controls = new JPanel();
  controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));
  JCheckBox checkLPC = new JCheckBox("Show LPC");
  checkLPC.setAlignmentX(CENTER_ALIGNMENT);
  controls.add(checkLPC);
  JLabel lpcLabel = new JLabel("LPC order:");
  lpcLabel.setAlignmentX(CENTER_ALIGNMENT);
  controls.add(lpcLabel);
  int min = 1;
  int max = 100;
  JSlider lpcSlider = new JSlider(JSlider.HORIZONTAL, min, max, lpcOrder);
  lpcSlider.setAlignmentX(CENTER_ALIGNMENT);
  lpcSlider.addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent ce) {
      JSlider source = (JSlider) ce.getSource();

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

pnlButtons = new javax.swing.JPanel();
sldVolume = new javax.swing.JSlider();
btnRewind = new javax.swing.JButton();
btnStop = new javax.swing.JButton();
btnFF = new javax.swing.JButton();
btnOpen = new javax.swing.JButton();
pnlBar = new javax.swing.JPanel();
lblTime = new javax.swing.JLabel();
sldBar = new javax.swing.JSlider();
pnlButtons.setLayout(new javax.swing.BoxLayout(pnlButtons, javax.swing.BoxLayout.LINE_AXIS));
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);
pnlButtons.add(btnOpen);
sldBar.setValue(0);
sldBar.addChangeListener(new javax.swing.event.ChangeListener() {
  public void stateChanged(javax.swing.event.ChangeEvent evt) {
    sldBarStateChanged(evt);

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

protected void setPositionSliderWithoutNotification(int value) {
  if (value == positionSlider.getValue()) return;
  ChangeListener[] listeners = positionSlider.getChangeListeners();
  for (ChangeListener listener : listeners) {
    positionSlider.removeChangeListener(listener);
  }
  positionSlider.setValue(value);
  for (ChangeListener listener : listeners) {
    positionSlider.addChangeListener(listener);
  }
}

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

private void updateTime(){
  int max = (int) (musicLength * 100);
  int pos = (int) (curTime * 100);
  sldBar.setMaximum(max);
  sldBar.setValue(pos);
  int minutesTotal = (int) (musicLength / 60);
  int secondsTotal = (int) (musicLength % 60);
  int minutesNow = (int) (curTime / 60);
  int secondsNow = (int) (curTime % 60);
  String txt = String.format("%01d:%02d-%01d:%02d", minutesNow, secondsNow,
                         minutesTotal, secondsTotal);
  lblTime.setText(txt);
}

代码示例来源:origin: bonnyfone/vectalign

@Override
  public void stateChanged(ChangeEvent e) {
    if(sliderMorphing.isEnabled()){
      svgMorphing.renderStep(((float)sliderMorphing.getValue())/1000.f);
    }
  }
});

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

protected JPanel getControls() {
  JPanel controls = new JPanel();
  controls.setLayout(new BoxLayout(controls, BoxLayout.Y_AXIS));
  JLabel fftLabel = new JLabel("FFT size:");
  fftLabel.setAlignmentX(CENTER_ALIGNMENT);
  controls.add(fftLabel);
  int min = 5;
  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>();
  for (int i = min; i <= max; i++) {
    int twoPowI = 1 << i; // 2^i, e.g. i==8 => twoPowI==256
    labelTable.put(new Integer(i), new JLabel(String.valueOf(twoPowI)));
  fftSizeSlider.setLabelTable(labelTable);
  fftSizeSlider.setPaintLabels(true);
  fftSizeSlider.addChangeListener(new ChangeListener() {
    public void stateChanged(ChangeEvent ce) {
      JSlider source = (JSlider) ce.getSource();

代码示例来源:origin: magefree/mage

tabMain = new javax.swing.JPanel();
main_gamelog = new javax.swing.JPanel();
cbGameLogAutoSave = new javax.swing.JCheckBox();
cbDraftLogAutoSave = new javax.swing.JCheckBox();
cbGameJsonLogAutoSave = new javax.swing.JCheckBox();
main_card = new javax.swing.JPanel();
showCardName = new javax.swing.JCheckBox();
tooltipDelayLabel = new javax.swing.JLabel();
tooltipDelay = new javax.swing.JSlider();
sliderFontSize = new javax.swing.JSlider();
fontSizeLabel = new javax.swing.JLabel();
sliderChatFontSize = new javax.swing.JSlider();
chatFontSizeLabel = new javax.swing.JLabel();
sliderDialogFont = new javax.swing.JSlider();
labelDialogFont = new javax.swing.JLabel();
sliderEditorCardSize = new javax.swing.JSlider();
labelEditorCardSize = new javax.swing.JLabel();
sliderEditorCardOffset = new javax.swing.JSlider();
labelEditorCardOffset = new javax.swing.JLabel();
sliderEnlargedImageSize = new javax.swing.JSlider();
sliderCardSizeHand = new javax.swing.JSlider();
labelCardSizeHand = new javax.swing.JLabel();
sliderCardSizeOtherZones = new javax.swing.JSlider();
labelCardSizeOtherZones = new javax.swing.JLabel();
sliderCardSizeMinBattlefield = new javax.swing.JSlider();
labelCardSizeMinBattlefield = new javax.swing.JLabel();
sliderCardSizeMaxBattlefield = new javax.swing.JSlider();

代码示例来源:origin: fossasia/neurolab-desktop

int[] y1 = new int[numChannels];
frame = new JFrame() {
frame.setLayout(new BorderLayout());
frameGraphics = frame.getGraphics();
parameterPanel.setBackground(Color.GREEN);
JSlider freqZoomSlider = new JSlider(JSlider.HORIZONTAL, 1, 800, 200);
JLabel freqZoomLabel = new JLabel("freq zoom: 0.5x");
freqZoomSlider.addChangeListener(new ChangeListener() {
parameterPanel.add(freqZoomLabel);
JSlider avgSlider = new JSlider(JSlider.HORIZONTAL, 100, 100000, 100);
avg = Integer.valueOf(config.getPref(Config.server_settings, String.valueOf(Config.server_settings_params.avg) ));
JLabel avgLabel = new JLabel("avg: " + avg);
avgSlider.addChangeListener(new ChangeListener() {
JSlider peakSlider = new JSlider(JSlider.HORIZONTAL, 1, 5000, 200);
JLabel peakLabel = new JLabel("p2p: "+pp+" uV");
peakSlider.addChangeListener(new ChangeListener() {
JSlider trainSlider = new JSlider(JSlider.HORIZONTAL, 1, 100, 10);
JLabel trainLabel = new JLabel("training factor: "+tf+"%");
trainSlider.addChangeListener(new ChangeListener() {

代码示例来源:origin: bonnyfone/vectalign

panelInput = new JPanel(new GridLayout(1, 2, 10, 0));
JPanel panelFrom = new JPanel(new BorderLayout());
JPanel panelTo = new JPanel(new BorderLayout());
svgFrom = new SVGDrawingPanel();
svgFrom.setPreferredSize(new Dimension(190, 200));
JPanel panelStrokeSize = new JPanel(new BorderLayout());
panelStrokeSize.add(new JLabel("Stroke size: "), BorderLayout.WEST);
SpinnerModel spinnerModel =
    new SpinnerNumberModel(2, //initial value
svgMorphing.setListener(this);
svgMorphing.setPreferredSize(new Dimension(400, 400));
sliderMorphing = new JSlider(JSlider.HORIZONTAL, 0, 1000, 0);
sliderMorphing.setPreferredSize(new Dimension(350, 25));
btnMorphAnimation = new JButton(icnPlay);
btnMorphAnimation.setPreferredSize(new Dimension(35, 35));
getContentPane().add(panelConfig, BorderLayout.WEST);
getContentPane().add(panelMorphing, BorderLayout.EAST);
getContentPane().add(panelOutput, BorderLayout.SOUTH);
setPreferredSize(new Dimension(900, 650));
setBackground(Color.white);

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

int fPW = Integer.parseInt(fpw);
    JSlider slider = bp.getFramesPerWavelengthSlider();
    slider.setValue( fPW );
  } catch(NumberFormatException useDefault) {
framesPerWavelength = new JSlider(JSlider.HORIZONTAL,10,200,25);
framesPerWavelength.setPaintTicks(true);
framesPerWavelength.setMajorTickSpacing(10);
framesPerWavelength.setMinorTickSpacing(5);
framesPerWavelength.setToolTipText("Frames per Wavelength");
framesPerWavelength.addChangeListener( new ChangeListener(){
  public void stateChanged(ChangeEvent ce) {
    setUpSound();
  final JSlider volume = new JSlider(
    JSlider.VERTICAL,
    (int)control.getMinimum(),
  volume.addChangeListener( new ChangeListener(){
    public void stateChanged(ChangeEvent ce) {
      control.setValue( volume.getValue() );
Integer sR = (Integer)sampleRate.getSelectedItem();
int intST = sR.intValue();
int intFPW = framesPerWavelength.getValue();
int intFPW = framesPerWavelength.getValue();

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

private JSlider slider = new JSlider(0, 100, 50);
private JLabel label = new JLabel("   ", SwingConstants.CENTER);
  slider.addChangeListener(new ChangeListener() {
    @Override
    public void stateChanged(ChangeEvent e) {
      label.setText(String.valueOf(slider.getValue()));
  slider.setMajorTickSpacing(20);
  slider.setMinorTickSpacing(5);
  slider.setPaintTicks(true);
  slider.setPaintLabels(true);
  JPanel topPanel = new JPanel();
  topPanel.add(new JLabel("Slider Value:"));
  topPanel.add(label);
  setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
  setLayout(new BorderLayout(5, 5));
  add(topPanel, BorderLayout.PAGE_START);
  add(slider);
  SliderFoo mainPanel = new SliderFoo();

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

import java.awt.*;
import javax.swing.*;

public class Broken2 {
 JLabel value = new JLabel();
 JSlider slider = new JSlider(0, 255, 0);

 public Broken2() {
  JPanel panel = new JPanel();
  value.setText("Some Value");
  panel.add(value);
  JFrame frame = new JFrame("Frame Name2");
  frame.setLayout(new GridLayout(2, 1));
  frame.add(panel);
  frame.add(slider);
  frame.pack();
  frame.setVisible(true);
 }

 public static void main(String[] args) {

  // Generally the proper way. Create Whole app on EDT
  SwingUtilities.invokeLater(new Runnable() {
   public void run() {
    new Broken2();
   }
  });
 }
}

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

public static void main(String[] args) {
  JFrame frame = new JFrame();
  DynamicJPanel dynamic = new DynamicJPanel();
  frame.add(dynamic.createTipTailoringPanel(3));
  frame.pack();
  frame.setVisible(true);
}

JPanel createTipTailoringPanel(int size) {
  JPanel content = new JPanel();
  content.setLayout(new GridLayout(0, 4));

  for (int i = 0; i < size; i++) {
    content.add(new JTextField());
    content.add(new JSlider());
    content.add(new JLabel("$"));
    content.add(new JLabel());
  }

  return content;
}

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeBrowseButtonBox() {
 JPanel buttonBox = new JPanel();
 buttonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
 buttonBox.setLayout(new GridBagLayout());
 browseButton = new JButton("Browse Trees");
 browseButton.addActionListener(this);
 JLabel sizeLabel = new JLabel("Tree size:");
 JSlider fontSlider = new JSlider(2, 64, 12);
 fontSlider.addChangeListener(this);
 GridBagConstraints buttonConstraints = new GridBagConstraints();
 buttonConstraints.fill = GridBagConstraints.HORIZONTAL;
 buttonConstraints.weightx = 0.2;
 buttonConstraints.weighty = 0.2;
 buttonBox.add(browseButton,buttonConstraints);
 buttonConstraints.weightx = 0.6;
 buttonBox.add(fontSlider, buttonConstraints);
 buttonConstraints.weightx = 0.2;
 buttonBox.add(sizeLabel, buttonConstraints);
 return buttonBox;
}

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

gbc.insets = new Insets(2, 2, 2, 2);
JPanel inputPanel = new JPanel(new GridBagLayout());
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);
gbc.weightx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
inputPanel.add(slider, gbc);
JLabel tintLabel = new JLabel("Tint Value:");
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
inputPanel.add(tintLabel, gbc);

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

if (!slider.getValueIsAdjusting())
    System.out.println(slider.getValue());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationByPlatform(true);
JPanel contentPane = new JPanel();
contentPane.setOpaque(true);
slider = new JSlider(0, 10, 5);
slider.setMajorTickSpacing(2);
slider.setMinorTickSpacing(1);
slider.addChangeListener(changeListener);
contentPane.add(slider);
getContentPane().add(contentPane);
pack();
setVisible(true);

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

JPanel panel = new JPanel(layout);
controls = new HashMap<Component, ControlCategory>();
JButton btn = null;
label = new JLabel("Feature type");
label.setForeground(Color.BLUE);
panel.add(label, "wrap");
typeLabel = new JLabel();
panel.add(typeLabel, "gapbefore indent, span, wrap");
panel.add(label, "split 2");
fillOpacitySlider = new JSlider(0, 100, 100);
fillOpacitySlider.setPaintLabels(true);
fillOpacitySlider.setMajorTickSpacing(20);
fillOpacitySlider.addChangeListener(
    new ChangeListener() {
panel.add(btn);
getContentPane().add(panel);
pack();

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

private JPanel panel = new JPanel();
private JTextField xAccelTextField = new JTextField(10);
private JSlider xAccelSlider = new JSlider();
      try {
        FrameExample2 frame = new FrameExample2();
        frame.setVisible(true);
      } catch (Exception e) {
        e.printStackTrace(System.out);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  panel.setLayout(new GridLayout(0, 1));
  panel.setBorder(BorderFactory.createLineBorder(Color.gray, 8));
  panel.add(new JLabel("Linear Acceleration along X", JLabel.CENTER));
  panel.add(xAccelSlider);
  xAccelTextField.setEditable(false);
  xAccelTextField.setText("0");
  xAccelTextField.setColumns(10);
  this.add(panel);
  this.pack();
  this.setLocationRelativeTo(null);
  xAccelSlider.addChangeListener(new ChangeListener() {
        String.valueOf(xAccelSlider.getValue()));

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

int height = 100;
gui = new JPanel(new BorderLayout(3,4));
quality = new JSlider(JSlider.VERTICAL, 0, 100, 75);
quality.setSnapToTicks(true);
quality.setPaintTicks(true);
quality.setPaintLabels(true);
quality.setMajorTickSpacing(10);
quality.setMinorTickSpacing(5);
quality.addChangeListener( new ChangeListener(){
  public void stateChanged(ChangeEvent ce) {
    updateImages();
gui.add(quality, BorderLayout.WEST);
dithering = new JCheckBox("Dithering", false);
controls.add(antialiasing);
controls.add(fractionalMetrics);
float qualityFloat = (float)quality.getValue()/100f;
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
builder.append(jpgSize);
builder.append(" bytes \tquality: ");
builder.append(quality.getValue());

相关文章

JSlider类方法