本文整理了Java中javax.swing.JSlider.addChangeListener()
方法的一些代码示例,展示了JSlider.addChangeListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSlider.addChangeListener()
方法的具体详情如下:
包路径:javax.swing.JSlider
类名称:JSlider
方法名:addChangeListener
暂无
代码示例来源: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: 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.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);
getContentPane().add(pnlButtons, java.awt.BorderLayout.CENTER);
sldBar.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
sldBarStateChanged(evt);
pnlBar.add(sldBar);
getContentPane().add(pnlBar, java.awt.BorderLayout.PAGE_START);
代码示例来源: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()));
frame.add(text, BorderLayout.NORTH);
frame.add(slider, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.pack();
代码示例来源:origin: fossasia/neurolab-desktop
int[] y1 = new int[numChannels];
frame = new JFrame() {
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() {
frame.setSize(width - samplesPerSecond-(drawBins?0:600), height);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
final DecimalFormat df = new DecimalFormat("0.####");
final JFrame frame = new JFrame();
final JTextField text = new JTextField(20);
final DoubleJSlider slider = new DoubleJSlider(0, 100, 0, 1000);
slider.addChangeListener(new ChangeListener(){
@Override
public void stateChanged(ChangeEvent e) {
frame.add(text, BorderLayout.NORTH);
frame.add(slider, BorderLayout.CENTER);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.pack();
代码示例来源:origin: fossasia/neurolab-desktop
frame = new JFrame();
frame.setSize(70, 600);
frame.setLayout(new BorderLayout());
JSlider slider = new JSlider(1,1000,50);
slider.setOrientation(JSlider.VERTICAL);
slider.addChangeListener(new ChangeListener() {
代码示例来源: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: magefree/mage
JPanel sliderPanel = new JPanel(new GridBagLayout());
sliderPanel.setOpaque(false);
cardSizeSlider = new JSlider(SwingConstants.HORIZONTAL, 0, 100, 50);
cardSizeSlider.setOpaque(false);
cardSizeSlider.setPreferredSize(new Dimension(100, (int) cardSizeSlider.getPreferredSize().getHeight()));
cardSizeSlider.addChangeListener(e -> {
if (!cardSizeSlider.getValueIsAdjusting()) {
float sliderFrac = ((float) (cardSizeSlider.getValue() - 50)) / 50;
代码示例来源:origin: stackoverflow.com
JFrame frame = new JFrame("Testing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new BorderLayout());
frame.add(new FadePane());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
slider = new JSlider(0, 100);
setLayout(new BorderLayout());
add(slider, BorderLayout.SOUTH);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
progress = ((float)slider.getValue() / 100f);
repaint();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
JFrame frame = new JFrame("Test");
JSlider slider = new JSlider();
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent ce) {
System.out.println(((JSlider) ce.getSource()).getValue());
}
});
frame.add(slider);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}
代码示例来源:origin: libgdx/libgdx
public ColorSlider (Color[] paletteColors) {
this.paletteColors = paletteColors;
setLayout(new GridBagLayout());
{
slider = new JSlider(0, 1000, 0);
slider.setPaintTrack(false);
add(slider, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 6, 0, 6), 0, 0));
}
{
colorPicker = new ColorPicker();
add(colorPicker, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 6), 0, 0));
}
slider.addChangeListener(new ChangeListener() {
public void stateChanged (ChangeEvent event) {
colorPicked();
}
});
}
代码示例来源:origin: fossasia/neurolab-desktop
Font bigFont = new Font(Font.SANS_SERIF, Font.PLAIN, 16);
window = new JFrame()
JFrame controlPanel = new JFrame();
controlPanel.setSize(80, windowHeight);
controlPanel.setLocationRelativeTo(window);
controlPanel.setLayout(new BoxLayout(controlPanel.getContentPane(), BoxLayout.X_AXIS));
JSlider sliderMin = new JSlider(SwingConstants.VERTICAL, -1000, 1000, 0);
JSlider sliderMax = new JSlider(SwingConstants.VERTICAL, -1000, 5000, 30);
sliderMin.addChangeListener(new ChangeListener()
sliderMax.addChangeListener(new ChangeListener()
代码示例来源:origin: geotools/geotools
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: 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
quality = new JSlider(JSlider.VERTICAL, 0, 100, 75);
quality.setSnapToTicks(true);
quality.setPaintTicks(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());
代码示例来源:origin: ru.sbtqa/monte-media
@Override
public void run() {
JFrame fr = new JFrame(f.getName());
fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final JLabel label = new JLabel(new ImageIcon(frames.get(0)));
final JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, frames.size() - 1, 0);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
label.setIcon(new ImageIcon(frames.get(slider.getValue())));
}
});
fr.add(BorderLayout.CENTER, label);
fr.add(BorderLayout.SOUTH, slider);
fr.pack();
fr.setVisible(true);
}
});
代码示例来源:origin: libgdx/libgdx
public ColorSlider (Color[] paletteColors) {
this.paletteColors = paletteColors;
setLayout(new GridBagLayout());
{
slider = new JSlider(0, 1000, 0);
slider.setPaintTrack(false);
add(slider, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
new Insets(0, 6, 0, 6), 0, 0));
}
{
colorPicker = new ColorPicker();
add(colorPicker, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
GridBagConstraints.HORIZONTAL, new Insets(0, 6, 0, 6), 0, 0));
}
slider.addChangeListener(new ChangeListener() {
public void stateChanged (ChangeEvent event) {
colorPicked();
}
});
}
代码示例来源:origin: openimaj/openimaj
/**
* @param title
* @param min
* @param max
* @param change
* @return the frame containing the slider
*/
public static JFrame displaySlider(String title, int min, int max, final Operation<JSlider> change){
JFrame sliderFrame = new JFrame();
sliderFrame.setTitle(title);
sliderFrame.setSize(200,100);
final JSlider slider = new JSlider(min, max);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
change.perform(slider);
}
});
sliderFrame.add(slider);
sliderFrame.setVisible(true);
return sliderFrame;
}
}
代码示例来源:origin: stackoverflow.com
getContentPane().add(bp);
validate();
f.setMinimumSize( f.getSize() );
f.setLocationByPlatform(true);
f.setVisible(true);
options.add( pSampleRate );
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();
clip.getControl( FloatControl.Type.MASTER_GAIN );
);
volume.setToolTipText("Volume of beep");
volume.addChangeListener( new ChangeListener(){
public void stateChanged(ChangeEvent ce) {
control.setValue( volume.getValue() );
int intFPW = framesPerWavelength.getValue();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
final URL lenna =
new URL("http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png");
final JSlider slider = new JSlider(0, 1000, 500);
final ImageComponent image = new ImageComponent(lenna);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
image.setZoom(2. * slider.getValue() / slider.getMaximum());
}
});
JFrame frame = new JFrame("Test");
frame.add(slider, BorderLayout.NORTH);
frame.add(new JScrollPane(image));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 300);
frame.setVisible(true);
}
内容来源于网络,如有侵权,请联系作者删除!