本文整理了Java中javax.swing.JSlider.setValue()
方法的一些代码示例,展示了JSlider.setValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.setValue()
方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:setValue
暂无
代码示例来源: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
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.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) {
pnlBar.add(lblTime);
sldBar.setValue(0);
sldBar.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
代码示例来源:origin: stackoverflow.com
final JFrame frame = new JFrame();
final JTextField text = new JTextField(20);
final JSlider slider = new JSlider(0, 100, 0);
slider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
text.setText(String.valueOf(slider.getValue()));
public void keyReleased(KeyEvent ke) {
String typed = text.getText();
slider.setValue(0);
if(!typed.matches("\\d+") || typed.length() > 3) {
return;
slider.setValue(value);
代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
JSlider slider = (JSlider) e.getComponent();
// compute new value
int nb = e.getWheelRotation();
int value = slider.getValue() - nb;
// set the value
slider.setValueIsAdjusting(true);
slider.setValue(value);
slider.setValueIsAdjusting(false);
e.consume();
}
代码示例来源:origin: 4thline/cling
protected void setVolumeSliderWithoutNotification(int value) {
if (value == volumeSlider.getValue()) return;
ChangeListener[] listeners = volumeSlider.getChangeListeners();
for (ChangeListener listener : listeners) {
volumeSlider.removeChangeListener(listener);
}
volumeSlider.setValue(value);
for (ChangeListener listener : listeners) {
volumeSlider.addChangeListener(listener);
}
// Mute button state depends on volume state
muteButton.setSelected(value == 0);
}
}
代码示例来源:origin: stackoverflow.com
slider = new JSlider(0, 100);
setLayout(new BorderLayout());
add(slider, BorderLayout.SOUTH);
@Override
public void stateChanged(ChangeEvent e) {
progress = ((float)slider.getValue() / 100f);
repaint();
slider.setValue(100);
代码示例来源:origin: magefree/mage
showCardName = new javax.swing.JCheckBox();
tooltipDelayLabel = new javax.swing.JLabel();
tooltipDelay = new javax.swing.JSlider();
showFullImagePath = new javax.swing.JCheckBox();
main_game = new javax.swing.JPanel();
tooltipDelay.setSnapToTicks(true);
tooltipDelay.setToolTipText("<HTML>The time the appearance of the tooltip window for a card is delayed.<br>\nIf set to zero, the tooltip window won't be shown at all.");
tooltipDelay.setValue(300);
sliderCardSizeHand.setSnapToTicks(true);
sliderCardSizeHand.setToolTipText("<HTML>The size of the card images in hand and on the stack");
sliderCardSizeHand.setValue(14);
sliderCardSizeHand.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderCardSizeHand.setMinimumSize(new java.awt.Dimension(150, 40));
sliderStackWidth.setSnapToTicks(true);
sliderStackWidth.setToolTipText("<HTML>The % size of the stack object area in relation to the hand card area size.");
sliderStackWidth.setValue(30);
sliderStackWidth.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderStackWidth.setMinimumSize(new java.awt.Dimension(150, 40));
sliderTooltipSize.setSnapToTicks(true);
sliderTooltipSize.setToolTipText("<HTML>The size of the tooltip window for cards or permanents");
sliderTooltipSize.setValue(14);
sliderTooltipSize.setBorder(javax.swing.BorderFactory.createEtchedBorder());
sliderTooltipSize.setMinimumSize(new java.awt.Dimension(150, 40));
代码示例来源:origin: stackoverflow.com
JSlider slider = new JSlider(JSlider.HORIZONTAL);
slider.setUI(new MetalSliderUI() {
protected void scrollDueToClickInTrack(int direction) {
// this is the default behaviour, let's comment that out
//scrollByBlock(direction);
int value = slider.getValue();
if (slider.getOrientation() == JSlider.HORIZONTAL) {
value = this.valueForXPosition(slider.getMousePosition().x);
} else if (slider.getOrientation() == JSlider.VERTICAL) {
value = this.valueForYPosition(slider.getMousePosition().y);
}
slider.setValue(value);
}
});
代码示例来源:origin: stackoverflow.com
int fPW = Integer.parseInt(fpw);
JSlider slider = bp.getFramesPerWavelengthSlider();
slider.setValue( fPW );
} catch(NumberFormatException useDefault) {
options.add( pSampleRate );
framesPerWavelength = new JSlider(JSlider.HORIZONTAL,10,200,25);
framesPerWavelength.setPaintTicks(true);
framesPerWavelength.setMajorTickSpacing(10);
clip.getControl( FloatControl.Type.MASTER_GAIN );
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: senbox-org/snap-desktop
public JPanel getControlPanel(final WorldWindowGLCanvas wwd) {
final JSlider opacitySlider = new JSlider();
opacitySlider.setMaximum(100);
opacitySlider.setValue((int) (getOpacity() * 100));
opacitySlider.setEnabled(true);
opacitySlider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
int value = opacitySlider.getValue();
setOpacity(value / 100d);
wwd.repaint();
}
});
//theSelectedObjectLabel = new JLabel("Selected: ");
final JPanel opacityPanel = new JPanel(new BorderLayout(5, 5));
opacityPanel.add(new JLabel("Opacity"), BorderLayout.WEST);
opacityPanel.add(opacitySlider, BorderLayout.CENTER);
return opacityPanel;
}
}
代码示例来源:origin: com.synaptix/SynaptixSwing
public void scrollByUnit(int direction) {
synchronized (slider) {
int oldValue = slider.getValue();
int delta = 1 * ((direction > 0) ? POSITIVE_SCROLL
: NEGATIVE_SCROLL);
slider.setValue(oldValue + delta);
}
}
代码示例来源:origin: stackoverflow.com
final JSlider horse1 = new JSlider(0, 100, 0);
final JSlider horse2 = new JSlider(0, 100, 0);
final JSlider horse3 = new JSlider(0, 100, 0);
Random random = new Random();
int horse1Value = horse1.getValue();
horse1Value += random.nextInt(101 - horse1Value);
horse1.setValue(horse1Value);
int horse2Value = horse2.getValue();
horse2Value += random.nextInt(101 - horse2Value);
horse2.setValue(horse2Value);
int horse3Value = horse3.getValue();
horse3Value += random.nextInt(101 - horse3Value);
horse3.setValue(horse3Value);
代码示例来源:origin: antlr/antlrworks
protected JSlider createZoomSlider() {
JSlider slider = new JSlider();
slider.setFocusable(false);
slider.setMinimum(1);
slider.setMaximum(800);
slider.setValue(100);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
JSlider slider = (JSlider)event.getSource();
view.setZoom((float)slider.getValue()/100);
view.repaint();
}
});
return slider;
}
代码示例来源:origin: com.synaptix/SynaptixSwing
public void scrollByUnit(int direction) {
synchronized (slider) {
int oldValue = slider.getValue();
int delta = 1 * ((direction > 0) ? POSITIVE_SCROLL
: NEGATIVE_SCROLL);
slider.setValue(oldValue + delta);
}
}
代码示例来源:origin: com.io7m.jcamera/com.io7m.jcamera.examples.jogl
CameraFloatSlider(
final String in_label,
final double in_minimum,
final double in_maximum)
{
this.label = new JLabel(NullCheck.notNull(in_label, "ForwardLabel"));
this.group = new RowGroup();
this.maximum = in_maximum;
this.minimum = in_minimum;
this.field = new JTextField(Double.toString(in_minimum));
this.slider = new JSlider(SwingConstants.HORIZONTAL);
this.slider.setMinimum(0);
this.slider.setMaximum(100);
this.slider.setValue(0);
this.slider.addChangeListener(ev -> {
final int slider_current = CameraFloatSlider.this.slider.getValue();
this.current = convertFromSlider(slider_current, in_minimum, in_maximum);
this.refreshText();
this.callListener();
});
this.field.setEditable(false);
}
代码示例来源:origin: antlr/antlrworks
public JSlider createZoomSlider() {
JSlider slider = new JSlider();
slider.setFocusable(false);
slider.setMinimum(1);
slider.setMaximum(200);
slider.setValue(100);
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) {
JSlider slider = (JSlider)event.getSource();
treeGraphView.setZoom((float)slider.getValue()/100);
treeGraphView.repaint();
treeGraphView.revalidate();
}
});
return slider;
}
代码示例来源:origin: stackoverflow.com
public void stateChanged(ChangeEvent e) {
JSlider source = (JSlider)e.getSource();
int val = (int)source.getValue();
for (JSlider slider : otherSliders) {
slider.setValue(val);
}
}
代码示例来源:origin: nroduit/Weasis
JSlider createSlider(final FloatControl c) {
if (c == null) {
return null;
}
final JSlider s = new JSlider(0, 1000);
final float min = c.getMinimum();
final float max = c.getMaximum();
final float width = max - min;
float fval = c.getValue();
s.setValue((int) ((fval - min) / width * 1000));
java.util.Hashtable<Integer, JLabel> labels = new java.util.Hashtable<>(3);
labels.put(0, new JLabel(c.getMinLabel()));
labels.put(500, new JLabel(c.getMidLabel()));
labels.put(1000, new JLabel(c.getMaxLabel()));
s.setLabelTable(labels);
s.setPaintLabels(true);
s.setBorder(new TitledBorder(c.getType().toString() + " " + c.getUnits())); //$NON-NLS-1$
s.addChangeListener(e -> {
int i = s.getValue();
float f = min + (i * width / 1000.0f);
c.setValue(f);
});
return s;
}
代码示例来源:origin: stackoverflow.com
public class test1 extends javax.swing.JFrame {
public test1() {
initComponents();
jSlider1.setMaximum(255);
jSlider1.setValue(-255);
}
@SuppressWarnings("unchecked")
private void initComponents() {
jSlider1 = new javax.swing.JSlider();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new test().setVisible(true);
}
});
}
private javax.swing.JSlider jSlider1;
}
代码示例来源:origin: tulskiy/musique
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int value = volumeSlider.getValue();
if (e.getWheelRotation() > 0)
value -= 5;
else
value += 5;
volumeSlider.setValue(value);
}
});
内容来源于网络,如有侵权,请联系作者删除!