当前位置: 首页>>代码示例>>Java>>正文


Java JSlider.addChangeListener方法代码示例

本文整理汇总了Java中javax.swing.JSlider.addChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java JSlider.addChangeListener方法的具体用法?Java JSlider.addChangeListener怎么用?Java JSlider.addChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JSlider的用法示例。


在下文中一共展示了JSlider.addChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initializeComponents

import javax.swing.JSlider; //导入方法依赖的package包/类
private void initializeComponents() {
	qualitySlider = new JSlider(10, 100, 50) {
		private static final long serialVersionUID = -3633632766184431178L;

		@Override
		public Dimension getPreferredSize() {
			return new Dimension(super.getPreferredSize().width/2, new JLabel(" ").getPreferredSize().height);
		}
	};
	qualitySlider.addChangeListener(ce -> r.refresh());
	
	qualitySlider.setOpaque(false);
	statusLabel = new JLabel();
	skipFrames = new JCheckBox("Skip frames", false);
	skipFrames.setOpaque(false);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:17,代码来源:PreviewStatusPanel.java

示例2: enableSliderToolTips

import javax.swing.JSlider; //导入方法依赖的package包/类
public static void enableSliderToolTips(final JSlider slider){ 
    slider.addChangeListener(new ChangeListener(){ 
        private boolean adjusting = false; 
        private String oldTooltip; 
        public void stateChanged(ChangeEvent e){ 
            if(slider.getModel().getValueIsAdjusting()){ 
                if(!adjusting){ 
                    oldTooltip = slider.getToolTipText(); 
                    adjusting = true; 
                } 
                slider.setToolTipText(String.valueOf(slider.getValue())); 
                hideToolTip(slider); // to avoid flickering :) 
                postToolTip(slider); 
            }else{ 
                hideToolTip(slider); 
                slider.setToolTipText(oldTooltip); 
                adjusting = false; 
                oldTooltip = null; 
            } 
        } 
    }); 
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:23,代码来源:SliderToolTips.java

示例3: Slider

import javax.swing.JSlider; //导入方法依赖的package包/类
/**
 * @param prefix the text of the Label
 * @param sufix  thge text of the Label
 * @param minvalue start vlaue
 * @param maxvalue last value
 * @param startvalue inital value
 * @param komma 10^x offset for komma digits
 */
public Slider(String prefix, String sufix, int minvalue, int maxvalue, int startvalue, int komma, @Nullable ChangeListener cl,@Nullable Updater upd, boolean enabled) {//ChangeListener or Updater could be Null!
	slider = new JSlider(minvalue, maxvalue, startvalue);
	slider.addChangeListener(this);
	if(prefix != null)
		this.prefix = prefix;
	if(sufix != null) {
		this.sufix = sufix;
	}
	offset = komma;
	label = new JLabel(getLabelText());
	add(slider);
	add(label);
	listener = cl;
	updater = upd;
	slider.setEnabled(enabled);
	defaultvalue = startvalue;
}
 
开发者ID:mrbesen,项目名称:ClashRoyale-Bot,代码行数:26,代码来源:UI.java

示例4: getControls

import javax.swing.JSlider; //导入方法依赖的package包/类
public Component getControls() {

      final JSlider slider = new JSlider(JSlider.HORIZONTAL,0,100,opacity);

      final HashMap<Integer,JLabel> labelTable = new HashMap<Integer,JLabel>();
      labelTable.put(0, new JLabel("Transparent"));
      labelTable.put(100, new JLabel("Opaque"));

      slider.setMajorTickSpacing(10);
      slider.setPaintTicks(true);
      // Note: JSlider uses the outdated Hashtable. Eventually Hashtable
      // will be deprecated and we'll be able to use the HashMap directly.
      slider.setLabelTable(new Hashtable<Integer,JLabel>(labelTable));
      slider.setPaintLabels(true);
      slider.setBorder(javax.swing.BorderFactory.createTitledBorder(name));
      slider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
          final JSlider source = (JSlider) e.getSource();
          if (!source.getValueIsAdjusting()) {
            opacity = source.getValue();
          }
        }});

      return slider;
    }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:26,代码来源:ZoneHighlight.java

示例5: setParseTreeViewer

import javax.swing.JSlider; //导入方法依赖的package包/类
public void setParseTreeViewer(TreeViewer aParseTree) {
	parseTreeViewer = aParseTree;
	JSlider scaleSlider = new JSlider();
	scaleSlider.setMinimum(PARSE_TREE_MIN_VAL);
	scaleSlider.setMaximum(PARSE_TREE_MAX_VAL);
	
	// JSlider only has integer values
	scaleSlider.setValue((int) (PARSE_TREE_DEFAULT_SCALE / PARSE_TREE_SLIDER_FACTOR)); 
	aParseTree.setScale(PARSE_TREE_DEFAULT_SCALE);
	
	JScrollPane parseTreeSP = new JScrollPane(aParseTree);
	parseTreeSP.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	parseTreeSP.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
	
	getParseTreePanel().removeAll();
	getParseTreePanel().add(parseTreeSP, BorderLayout.CENTER);
	getParseTreePanel().add(scaleSlider, BorderLayout.SOUTH);
	
	scaleSlider.addChangeListener(new ChangeListener() {
		public void stateChanged(ChangeEvent e) {
			double scaleValue = 
					((double) scaleSlider.getValue()) * PARSE_TREE_SLIDER_FACTOR;
			aParseTree.setScale(scaleValue);
		}
	});
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:27,代码来源:Workspace.java

示例6: subscribeActual

import javax.swing.JSlider; //导入方法依赖的package包/类
@Override
protected void subscribeActual(Observer<? super ChangeEvent> observer) {
    JSlider w = widget;

    ChangeEventConsumer aec = new ChangeEventConsumer(observer, w);
    observer.onSubscribe(aec);

    w.addChangeListener(aec);
    if (aec.get() == null) {
        aec.onDispose(w);
    }
}
 
开发者ID:akarnokd,项目名称:RxJava2Swing,代码行数:13,代码来源:ChangeEventSliderObservable.java

示例7: getOptionsComponent

import javax.swing.JSlider; //导入方法依赖的package包/类
@Override
public JComponent getOptionsComponent(int index) {
	JComponent comp = super.getOptionsComponent(index);
	if (comp != null) {
		lastPlotterComponentIndex = index;
		return comp;
	} else {
		if (index == lastPlotterComponentIndex + 1) {
			JLabel label = new JLabel("Transparency");
			label.setToolTipText("Select level of transparency");
			return label;
		} else if (index == lastPlotterComponentIndex + 2) {
			String toolTip = "Select level of transparency";
			final JSlider alphaSlider = new JSlider(0, 100, 50);
			alphaSlider.setToolTipText(toolTip);
			alphaSlider.addChangeListener(new ChangeListener() {

				@Override
				public void stateChanged(ChangeEvent e) {
					setAlphaLevel(((double) alphaSlider.getValue()) / 100);
				}
			});
			return alphaSlider;
		}
	}
	return null;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:SOMModelPlotter.java

示例8: createSlider

import javax.swing.JSlider; //导入方法依赖的package包/类
void createSlider(Method methodToCall, int min, int max, int init, String label) {
    JSlider slider = new MyJSlider(methodToCall, min, max, init, this.layout, this.item);
    slider.addChangeListener(this);
    JLabel sliderLabel = new JLabel(label, SwingConstants.LEFT);
    this.add(sliderLabel);
    this.add(slider);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:8,代码来源:LayoutKind.java

示例9: addNotificationListeners

import javax.swing.JSlider; //导入方法依赖的package包/类
public void addNotificationListeners(Component c) {
    if (c instanceof Accessible) {
        AccessibleContext ac = ((Accessible)c).getAccessibleContext();
        ac.addPropertyChangeListener(new AXChangeNotifier());
    }
    if (c instanceof JProgressBar) {
        JProgressBar pb = (JProgressBar) c;
        pb.addChangeListener(new AXProgressChangeNotifier());
    } else if (c instanceof JSlider) {
        JSlider slider = (JSlider) c;
        slider.addChangeListener(new AXProgressChangeNotifier());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:14,代码来源:CAccessible.java

示例10: IntSliderControl

import javax.swing.JSlider; //导入方法依赖的package包/类
public IntSliderControl(final Object f, PropertyDescriptor p, SliderParams params) {
            super();
            final String name = p.getName();
            final Method r = p.getReadMethod(), w = p.getWriteMethod();
            setterMap.put(name, this);
            clazz = f;
            write = w;
            read = r;
            setLayout(new GridLayout(1, 0));
//           setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
            setAlignmentX(ALIGNMENT);

            final IntControl ic = new IntControl(f, p);
            add(ic);
            slider = new JSlider(params.minIntValue, params.maxIntValue);
            slider.setMaximumSize(new Dimension(200, 25));

            refresh();
            add(slider);

            slider.addChangeListener(new ChangeListener() {

                @Override
                public void stateChanged(ChangeEvent e) {
                    try {
                        w.invoke(clazz, new Integer(slider.getValue())); // write int value
                        ic.set(slider.getValue());
//                        tf.setText(Integer.toString(slider.getValue()));
                    } catch (InvocationTargetException ite) {
                        ite.printStackTrace();
                    } catch (Exception iae) {
                        iae.printStackTrace();
                    }
                }
            });

        }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:38,代码来源:ParameterControlPanel.java

示例11: OptionsPanel

import javax.swing.JSlider; //导入方法依赖的package包/类
OptionsPanel(JList<?> list) {
	// set up components
	formatPng = new JRadioButton("PNG");
	formatGif = new JRadioButton("GIF");
	formatJpg = new JRadioButton("JPEG");
	ButtonGroup bgroup = new ButtonGroup();
	bgroup.add(formatPng);
	bgroup.add(formatGif);
	bgroup.add(formatJpg);
	formatPng.setSelected(true);

	slider = new JSlider(SwingConstants.HORIZONTAL, -3 * SLIDER_DIVISIONS, 3 * SLIDER_DIVISIONS, 0);
	slider.setMajorTickSpacing(10);
	slider.addChangeListener(this);
	curScale = new JLabel("222%");
	curScale.setHorizontalAlignment(SwingConstants.RIGHT);
	curScale.setVerticalAlignment(SwingConstants.CENTER);
	curScaleDim = new Dimension(curScale.getPreferredSize());
	curScaleDim.height = Math.max(curScaleDim.height, slider.getPreferredSize().height);
	stateChanged(null);

	printerView = new JCheckBox();
	printerView.setSelected(true);

	// set up panel
	gridbag = new GridBagLayout();
	gbc = new GridBagConstraints();
	setLayout(gridbag);

	// now add components into panel
	gbc.gridy = 0;
	gbc.gridx = GridBagConstraints.RELATIVE;
	gbc.anchor = GridBagConstraints.NORTHWEST;
	gbc.insets = new Insets(5, 0, 5, 0);
	gbc.fill = GridBagConstraints.NONE;
	addGb(new JLabel(Strings.get("labelCircuits") + " "));
	gbc.fill = GridBagConstraints.HORIZONTAL;
	addGb(new JScrollPane(list));
	gbc.fill = GridBagConstraints.NONE;

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelImageFormat") + " "));
	Box formatsPanel = new Box(BoxLayout.Y_AXIS);
	formatsPanel.add(formatPng);
	formatsPanel.add(formatGif);
	formatsPanel.add(formatJpg);
	addGb(formatsPanel);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelScale") + " "));
	addGb(slider);
	addGb(curScale);

	gbc.gridy++;
	addGb(new JLabel(Strings.get("labelPrinterView") + " "));
	addGb(printerView);
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:58,代码来源:ExportImage.java

示例12: WeibullDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public WeibullDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> shapeLabelTable = new Hashtable<>();
    for (int i = 0; i <= 10; i+=2) {
        shapeLabelTable.put(new Integer(i), new JLabel(String.valueOf(i)));
    }

    shapeSlider = new JSlider(0, 10, (int) Math.round(shape));
    shapeSlider.addChangeListener(this);
    shapeSlider.setLabelTable(shapeLabelTable);
    shapeSlider.setMajorTickSpacing(2);
    shapeSlider.setMinorTickSpacing(1);
    shapeSlider.setPaintTicks(true);
    shapeSlider.setPaintLabels(true);

    Hashtable<Integer, JLabel> scaleLabelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        scaleLabelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    scaleSlider = new JSlider(0, 50, (int) Math.round(scale*10));
    scaleSlider.addChangeListener(this);
    scaleSlider.setLabelTable(scaleLabelTable);
    scaleSlider.setMajorTickSpacing(10);
    scaleSlider.setMinorTickSpacing(2);
    scaleSlider.setPaintTicks(true);
    scaleSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("Shape:"));
    optionPane.add(shapeSlider);
    optionPane.add(new JLabel("Scale:"));
    optionPane.add(scaleSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    WeibullDistribution dist = new WeibullDistribution(shape, scale);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = i / 20.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = i / 20.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:74,代码来源:WeibullDistributionDemo.java

示例13: ExponentialDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public ExponentialDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 50; i+=10) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10)));
    }

    lambdaSlider = new JSlider(0, 50, (int) Math.round(lambda * 10));
    lambdaSlider.addChangeListener(this);
    lambdaSlider.setLabelTable(labelTable);
    lambdaSlider.setMajorTickSpacing(10);
    lambdaSlider.setMinorTickSpacing(2);
    lambdaSlider.setPaintTicks(true);
    lambdaSlider.setPaintLabels(true);

    optionPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("\u03BB:"));
    optionPane.add(lambdaSlider);

    add(optionPane, BorderLayout.NORTH);

    canvas = new JPanel(new GridLayout(2, 2));
    add(canvas, BorderLayout.CENTER);

    ExponentialDistribution dist = new ExponentialDistribution(lambda);

    double[][] p = new double[100][2];
    double[][] q = new double[100][2];
    for (int i = 0; i < p.length; i++) {
        p[i][0] = i / 20.0;
        p[i][1] = dist.p(p[i][0]);
        q[i][0] = i / 20.0;
        q[i][1] = dist.cdf(p[i][0]);
    }

    pdf = LinePlot.plot(p, Line.Style.SOLID, Color.BLUE);
    pdf.setTitle("PDF");
    canvas.add(pdf);

    cdf = LinePlot.plot(q, Line.Style.SOLID, Color.BLUE);
    cdf.setTitle("CDF");
    canvas.add(cdf);

    double[] data = new double[500];
    for (int i = 0; i < data.length; i++) {
        data[i] = dist.rand();
    }

    histogram = Histogram.plot(data, 20);
    histogram.setTitle("Histogram");
    canvas.add(histogram);

    qqplot = QQPlot.plot(data, dist);
    qqplot.setTitle("Q-Q Plot");
    canvas.add(qqplot);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:59,代码来源:ExponentialDistributionDemo.java

示例14: SSBuilder

import javax.swing.JSlider; //导入方法依赖的package包/类
public SSBuilder( ProfileGen profileGen, FeatureCache features ) {
	
	this.profileGen = profileGen;
	this.features = features;
	
	megaArea     = new JSlider (0, 1000, 500);
	gisInterior  = new JSlider (0, 1000, 400);
	heightCutoff = new JSlider (0, 1000, 400);
	mfSoft       = new JSlider (0, 1000, 400);
	pMerge       = new JSlider (0, 1000, 800);
	exposed      = new JSlider (0, 1000, 800);
	
	megaArea.addChangeListener( cl -> updateVars() );
	gisInterior.addChangeListener( cl -> updateVars() );
	heightCutoff.addChangeListener( cl -> updateVars() );
	mfSoft.addChangeListener( cl -> updateVars() );
	pMerge.addChangeListener( cl -> updateVars() );
	exposed.addChangeListener( cl -> updateVars() );
	
	JButton preview = new JButton ("preview");
	preview.addActionListener( e -> preview(false) );
	
	JButton save = new JButton ("save");
	save.addActionListener( e -> save( preview( true ) ) );
	
	JButton opt = new JButton ("optimise");
	opt.addActionListener( e -> opt( preview( true ) ) );
	
	quick = new JCheckBox( "quick", true );
	
	PaintThing.debug.clear();
	
	plot = new Plot(preview, save, opt, 
			new JLabel ("mega area"), megaArea, 
			new JLabel("GIS"), gisInterior,
			new JLabel("Height"), heightCutoff,
			new JLabel("MFPoint"), mfSoft,
			new JLabel("ProfMerge"), pMerge,
			new JLabel("Exposed"), exposed,
			quick
			);
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:43,代码来源:SSBuilder.java

示例15: MultivariateGaussianDistributionDemo

import javax.swing.JSlider; //导入方法依赖的package包/类
public MultivariateGaussianDistributionDemo() {
    super(new BorderLayout());

    Hashtable<Integer, JLabel> labelTable = new Hashtable<>();
    for (int i = 0; i <= 30; i+=10) {
        labelTable.put(new Integer(i), new JLabel(String.valueOf(i/10.0)));
    }

    sigma1Slider = new JSlider(0, 30, (int) (sigma[0]*10));
    sigma1Slider.addChangeListener(this);
    sigma1Slider.setLabelTable(labelTable);
    sigma1Slider.setMajorTickSpacing(10);
    sigma1Slider.setMinorTickSpacing(2);
    sigma1Slider.setPaintTicks(true);
    sigma1Slider.setPaintLabels(true);

    sigma2Slider = new JSlider(0, 30, (int) (sigma[1]*10));
    sigma2Slider.addChangeListener(this);
    sigma2Slider.setLabelTable(labelTable);
    sigma2Slider.setMajorTickSpacing(10);
    sigma2Slider.setMinorTickSpacing(2);
    sigma2Slider.setPaintTicks(true);
    sigma2Slider.setPaintLabels(true);

    optionPane = new JPanel();
    optionPane.setBorder(BorderFactory.createRaisedBevelBorder());
    optionPane.add(new JLabel("<html>\u03C3<sub>1</sub>:</html>"));
    optionPane.add(sigma1Slider);
    optionPane.add(new JLabel("<html>\u03C3<sub>2</sub>:</html>"));
    optionPane.add(sigma2Slider);

    add(optionPane, BorderLayout.NORTH);

    MultivariateGaussianDistribution g = new MultivariateGaussianDistribution(mu, sigma);

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            z[i][j][0] = 6.0 * (i - m/2) / m;
            z[i][j][1] = 6.0 * (j - n/2) / n;
            double[] point = {z[i][j][0], z[i][j][1]};
            z[i][j][2] = g.p(point);
        }
    }

    pdf = Surface.plot(z);
    pdf.setTitle("Multivariate Gaussian");
    add(pdf, BorderLayout.CENTER);
}
 
开发者ID:takun2s,项目名称:smile_1.5.0_java7,代码行数:49,代码来源:MultivariateGaussianDistributionDemo.java


注:本文中的javax.swing.JSlider.addChangeListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。