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


Java JSlider类代码示例

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


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

示例1: buidSlider

import javax.swing.JSlider; //导入依赖的package包/类
/**
 * Creates the image slider component
 * 
 * @return JComponent
 */
private JComponent buidSlider() {
    slider = new JSlider(0, 0);
    slider.setPreferredSize(new Dimension(120, 25));
    slider.setEnabled(false);
    slider.setOpaque(false);
    slider.setFocusable(false);
    slider.addChangeListener((ChangeEvent e) -> {
        if (input != null) {
            if (input instanceof MultiFileInput) {
                MultiFileInput multi = (MultiFileInput) input;
                input = new MultiFileInput(multi.getFiles(), slider.getValue());
                fireValueChanged();
            }
        }
    });
    return slider;
}
 
开发者ID:VISNode,项目名称:VISNode,代码行数:23,代码来源:InputEditor.java

示例2: getBindingDescriptors

import javax.swing.JSlider; //导入依赖的package包/类
@Override
public List<BindingDescriptor>[] getBindingDescriptors(RADComponent component) {
    BeanDescriptor beanDescriptor = component.getBeanInfo().getBeanDescriptor();
    List<BindingDescriptor>[] descs = getBindingDescriptors(null, beanDescriptor, false);
    Class<?> beanClass = component.getBeanClass();
    if (JTextComponent.class.isAssignableFrom(beanClass)) {
        // get rid of text_... descriptors
        descs[0] = filterDescriptors(descs[0], "text_"); // NOI18N
    } else if (JTable.class.isAssignableFrom(beanClass)
            || JList.class.isAssignableFrom(beanClass)
            || JComboBox.class.isAssignableFrom(beanClass)) {
        // get rid of selectedElement(s)_... descriptors
        descs[0] = filterDescriptors(descs[0], "selectedElement_"); // NOI18N
        descs[0] = filterDescriptors(descs[0], "selectedElements_"); // NOI18N
        // add elements descriptor
        BindingDescriptor desc = new BindingDescriptor("elements", List.class); // NOI18N
        descs[0].add(0, desc);
    } else if (JSlider.class.isAssignableFrom(beanClass)) {
        // get rid of value_... descriptor
        descs[0] = filterDescriptors(descs[0], "value_"); // NOI18N
    }
    return descs;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BindingDesignSupportImpl.java

示例3: enableSliderToolTips

import javax.swing.JSlider; //导入依赖的package包/类
public static void enableSliderToolTips(final JSlider slider) {
	slider.addChangeListener(new ChangeListener() {

		private boolean adjusting = false;
		private String oldTooltip;

		@Override
		public void stateChanged(ChangeEvent e) {
			if (slider.getModel().getValueIsAdjusting()) {
				if (!adjusting) {
					oldTooltip = slider.getToolTipText();
					adjusting = true;
				}
				slider.setToolTipText(String.valueOf(slider.getValue()));
				hideToolTip(slider);
				postToolTip(slider);
			} else {
				hideToolTip(slider);
				slider.setToolTipText(oldTooltip);
				adjusting = false;
				oldTooltip = null;
			}
		}
	});
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:26,代码来源:ExtendedJSliderToolTips.java

示例4: RangeOptionUI

import javax.swing.JSlider; //导入依赖的package包/类
/**
 * Creates a new {@code RangeOptionUI} for the given
 * {@code RangeOption}.
 *
 * @param option The {@code RangeOption} to make a user interface for
 * @param editable boolean whether user can modify the setting
 */
public RangeOptionUI(final RangeOption option, boolean editable) {
    super(option, editable);

    JSlider slider = getComponent();

    slider.setModel(new DefaultBoundedRangeModel(option.getValueRank(), 0,
            0, option.getItemValues().size()-1));

    Hashtable<Integer, JComponent> labels
        = new Hashtable<>();
    int index = 0;
    for (String string : option.getItemValues().values()) {
        if (option.localizeLabels()) {
            labels.put(index, Utility.localizedLabel(string));
        } else {
            labels.put(index, new JLabel(string));
        }
        index++;
    }

    slider.setLabelTable(labels);
    slider.setValue(option.getValueRank());
    slider.setMajorTickSpacing(1);
    slider.setSnapToTicks(true);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:33,代码来源:RangeOptionUI.java

示例5: addSliderListener

import javax.swing.JSlider; //导入依赖的package包/类
private void addSliderListener()
{
    m_slideProbability.addChangeListener(new ChangeListener()
    {

        @Override
        public void stateChanged(ChangeEvent e)
        {
            int value = ((JSlider) e.getSource()).getValue();

            String curProc = m_lstProcNames.getSelectedValue().toString();
            try
            {
                ProcEnv.setProbability(curProc, value);
                m_txtProbability.setText(Integer.toString(value));
            }
            catch (TotalProbabilityExceeds100Exception e1)
            {
                Integer nOldVal = ProcEnv.getProbability(curProc);
                m_slideProbability.setValue((nOldVal == null) ? 0 : nOldVal);
                m_notifier.showMsg(e1.getMessage(), false);
            }
        }
    });
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:26,代码来源:ProcGui.java

示例6: addBorderSetter

import javax.swing.JSlider; //导入依赖的package包/类
private void addBorderSetter(final JComponent s) {
        if (s instanceof JTextField || s instanceof JSlider || s instanceof JComboBox || s instanceof AbstractButton) {
            s.setFocusable(true);// sliders and combo boxes not normally focusable
            s.addFocusListener(this);
//            log.info("added border setter for "+s.getClass().getSimpleName());
        } else if (s instanceof Container) {
            Component[] components = s.getComponents();
            for (Component c : components) {
//                log.info("possibly adding border setter for "+c.getClass().getSimpleName());
                if (c instanceof JComponent) {
                    addBorderSetter((JComponent) c);
                }
            }
        }
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:16,代码来源:PotPanel.java

示例7: accept

import javax.swing.JSlider; //导入依赖的package包/类
protected boolean accept(Component jc) {
    if (extListener != null && extListener.accept(jc)) {
        return true;
    }
    if (!(jc instanceof JComponent)) {
        return false;
    }
    return isProbablyAContainer (jc) || 
            jc instanceof JList ||
            jc instanceof JComboBox ||
            jc instanceof JTree ||
            jc instanceof JToggleButton || //covers toggle, radio, checkbox
            jc instanceof JTextComponent ||
            jc instanceof JColorChooser ||
            jc instanceof JSpinner ||
            jc instanceof JSlider;
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:18,代码来源:GenericListener.java

示例8: 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

示例9: DrivestrengthMainWindow

import javax.swing.JSlider; //导入依赖的package包/类
public DrivestrengthMainWindow() {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
    setLayout(new GridBagLayout());
    setTitle("ASGDrivestrength");
    setSize(500, 300);

    JSlider percentageEnergySlider = new JSlider(JSlider.HORIZONTAL,
            0, 100, 0);

    JButton runButton = new JButton("Run");
    add(percentageEnergySlider);
    add(runButton);

    setVisible(true);
}
 
开发者ID:hpiasg,项目名称:asgdrivestrength,代码行数:19,代码来源:DrivestrengthMainWindow.java

示例10: 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

示例11: sliderStateChanged

import javax.swing.JSlider; //导入依赖的package包/类
/**
 * when slider is moved, event is sent here. The slider is the 'master' of the value in the text field.
 * Slider is linear scale, from pot min to pot max
 *
 * @param e
 *            the ChangeEvent
 */
private void sliderStateChanged(javax.swing.event.ChangeEvent evt) {// GEN-FIRST:event_sliderStateChanged
	if (sliderDontProcess) {
		return;
	}
	// we can get a double send here if user presses uparrow key, resulting in new pot value,
	// which updates the slider position, which ends up with a different bitvalue that makes a new
	// pot value.
	// See http://java.sun.com/docs/books/tutorial/uiswing/components/slider.html
	// System.out.println("slider state changed");
	// slider is only source of ChangeEvents
	JSlider s = (JSlider) evt.getSource();
	// System.out.println("slider state changed for "+pot);

	int v = s.getValue(); // slider value
	if (v == 0) {
		pot.setBitValue(0); // these pot chanages will come back to us as Observer events
		// a problem because they will updateAappearance, which will change slider state
		// and generate possibly a new slider changeevent
	}
	else {
		v = sliderValueFromBitValue(s);
		pot.setBitValue(v);
	}
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:32,代码来源:SimpleVPotSliderTextControl.java

示例12: main

import javax.swing.JSlider; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    JSlider slider = new JSlider();
    test(slider);

    ThreadGroup group = new ThreadGroup("$$$");
    Thread thread = new Thread(group, new Test6657026());
    thread.start();
    thread.join();

    test(slider);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:Test6657026.java

示例13: setupInstance

import javax.swing.JSlider; //导入依赖的package包/类
protected void setupInstance(JSlider instance) {
    super.setupInstance(instance);
    
    instance.setPaintTicks(paintTicks);
    instance.setPaintTrack(paintTrack);
    instance.setPaintLabels(paintLabels);
    instance.setInverted(isInverted);
    if (sliderModel != null) instance.setModel(sliderModel.createInstance());
    instance.setMajorTickSpacing(majorTickSpacing);
    instance.setMinorTickSpacing(minorTickSpacing);
    instance.setSnapToTicks(snapToTicks);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:JComponentBuilders.java

示例14: bitVal2SliderVal

import javax.swing.JSlider; //导入依赖的package包/类
/** Maps from bit value to linear/log slider value.
     * 
     * @param v bit value.
     * @param vmax max bit value.
     * @param slider the slider for the value.
     * @return the correct slider value.
     */
    private int bitVal2SliderVal(int v, int vmax, JSlider slider) {
        int s = 0;
        if (v < knee) {
            s = v;
        } else {
            double sm = slider.getMaximum();
            double vm = vmax;
            s = (int) (knee + Math.round((sm - knee) * log2((double) v - (knee - 1)) / log2(vm - (knee - 1))));
        }
//        log.info("bitValue=" + v + " -> sliderValue=" + s);
        return s;
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:20,代码来源:ConfigurableIPotGUIControl.java

示例15: setMinorTickSpacing

import javax.swing.JSlider; //导入依赖的package包/类
/**
 * Maps {@code JSlider.setMinorTickSpacing(int)} through queue
 */
public void setMinorTickSpacing(final int i) {
    runMapping(new MapVoidAction("setMinorTickSpacing") {
        @Override
        public void map() {
            ((JSlider) getSource()).setMinorTickSpacing(i);
        }
    });
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:JSliderOperator.java


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