javax.swing.JSlider#setEnabled ( )源码实例Demo

下面列出了javax.swing.JSlider#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: snap-desktop   文件: DefaultProductLayer.java
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;
}
 
源代码2 项目: jFuzzyLogic   文件: BlockDemo.java
@Override
 
    protected void addFuzzyControls(JPanel cntrl) {
        JPanel sp = new JPanel();
        sp.add(new JLabel("Position:"));
//        final double  maxAng=50;
        final double  steps=200;
//        final double fact=maxAng/steps/steps;
//        
        posSlider = new JSlider((int)-steps, (int)steps);
        //     final SpinnerNumberModel smA = new SpinnerNumberModel((int) angle, -180, 180, 1);
        posSlider.addChangeListener(new ChangeListener() {

            
            public void stateChanged(ChangeEvent e) {
                double x = 3.0*posSlider.getValue()/(double)steps;
                ((BlockFuzzyController) fuzzyController).setTargetPosition(x);
            }
        });
        posSlider.setEnabled(fuzzyControlActive);
        sp.add(posSlider);

        cntrl.add(sp);

    }
 
源代码3 项目: jFuzzyLogic   文件: IPDemo.java
@Override
protected void addFuzzyControls(JPanel cntrl) {
    JPanel sp = new JPanel();
    sp.add(new JLabel("Angle:"));
    final double  maxAng=50;
    final double  steps=200;
    final double fact=maxAng/steps/steps;
    
    angleSlider = new JSlider((int)-steps, (int)steps);
    //     final SpinnerNumberModel smA = new SpinnerNumberModel((int) angle, -180, 180, 1);
    angleSlider.addChangeListener(new ChangeListener() {

        
        public void stateChanged(ChangeEvent e) {
            angle = angleSlider.getValue();
            angle= Math.abs(angle)*angle*fact;
            ((IPFuzzyController2) fuzzyController).setTargetAngle(angle);
        }
    });
    angleSlider.setEnabled(fuzzyControlActive);
    sp.add(angleSlider);

    cntrl.add(sp);

}
 
源代码4 项目: jpexs-decompiler   文件: ColorEditor.java
private static Color noTransparencyColorChooser(Component component, String title, Color initialColor) throws Exception {
    final JColorChooser pane = new JColorChooser(initialColor != null
            ? initialColor : Color.white);

    AbstractColorChooserPanel[] colorPanels = pane.getChooserPanels();
    for (int i = 1; i < colorPanels.length; i++) {
        AbstractColorChooserPanel cp = colorPanels[i];

        Field f = cp.getClass().getDeclaredField("panel");
        f.setAccessible(true);

        Object colorPanel = f.get(cp);
        Field f2 = colorPanel.getClass().getDeclaredField("spinners");
        f2.setAccessible(true);
        Object spinners = f2.get(colorPanel);

        Object transpSlispinner = Array.get(spinners, 3);
        if (i == colorPanels.length - 1) {
            transpSlispinner = Array.get(spinners, 4);
        }
        Field f3 = transpSlispinner.getClass().getDeclaredField("slider");
        f3.setAccessible(true);
        JSlider slider = (JSlider) f3.get(transpSlispinner);
        slider.setEnabled(false);
        Field f4 = transpSlispinner.getClass().getDeclaredField("spinner");
        f4.setAccessible(true);
        JSpinner spinner = (JSpinner) f4.get(transpSlispinner);
        spinner.setEnabled(false);
    }
    final Color[] col = new Color[]{initialColor};

    JDialog dialog = JColorChooser.createDialog(component, title, true, pane, new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            col[0] = pane.getColor();
        }
    }, null);

    dialog.setVisible(true);
    return col[0];

}
 
源代码5 项目: scifio   文件: ImageViewer.java
/** Constructs an image viewer. */
	public ImageViewer(final Context context) {
		super(TITLE);
		context.inject(this);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		addWindowListener(this);

		// content pane
		pane = new JPanel();
		pane.setLayout(new BorderLayout());
		setContentPane(pane);
		setSize(350, 350); // default size

		// navigation sliders
		sliderPanel = new JPanel();
		sliderPanel.setVisible(false);
		sliderPanel.setBorder(new EmptyBorder(5, 3, 5, 3));
		sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.Y_AXIS));
		pane.add(BorderLayout.SOUTH, sliderPanel);

		final JPanel nPanel = new JPanel();
		nPanel.setLayout(new BoxLayout(nPanel, BoxLayout.X_AXIS));
		sliderPanel.add(nPanel);
		sliderPanel.add(Box.createVerticalStrut(2));

		nSlider = new JSlider(1, 1);
		nSlider.setEnabled(false);
		nSlider.addChangeListener(this);
		nPanel.add(new JLabel("N"));
		nPanel.add(Box.createHorizontalStrut(3));
		nPanel.add(nSlider);

		final JPanel ztcPanel = new JPanel();
		ztcPanel.setLayout(new BoxLayout(ztcPanel, BoxLayout.X_AXIS));
		sliderPanel.add(ztcPanel);

		// image icon
		final BufferedImage dummy = AWTImageTools.makeImage(new byte[1][1], 1, 1,
			false);
		icon = new ImageIcon(dummy);
		iconLabel = new JLabel(icon, SwingConstants.LEFT);
		iconLabel.setVerticalAlignment(SwingConstants.TOP);
		pane.add(new JScrollPane(iconLabel));

		// cursor probe
		probeLabel = new JLabel(" ");
		probeLabel.setHorizontalAlignment(SwingConstants.CENTER);
		probeLabel.setBorder(new BevelBorder(BevelBorder.RAISED));
		pane.add(BorderLayout.NORTH, probeLabel);
		iconLabel.addMouseMotionListener(this);

		// menu bar
		final JMenuBar menubar = new JMenuBar();
		// FIXME: currently the menu bar is disabled to restrict the use of
		// ImageViewer to the Show command. We could attempt to get this
		// implementation working nicely, or just convert to an IJ2
		// implementation.
//		setJMenuBar(menubar);

		final JMenu file = new JMenu("File");
		file.setMnemonic('f');
		menubar.add(file);
		final JMenuItem fileOpen = new JMenuItem("Open...");
		fileOpen.setMnemonic('o');
		fileOpen.setActionCommand("open");
		fileOpen.addActionListener(this);
		file.add(fileOpen);
		fileSave = new JMenuItem("Save...");
		fileSave.setMnemonic('s');
		fileSave.setEnabled(false);
		fileSave.setActionCommand("save");
		fileSave.addActionListener(this);
		file.add(fileSave);
		fileView = new JMenuItem("View Metadata...");
		final JMenuItem fileExit = new JMenuItem("Exit");
		fileExit.setMnemonic('x');
		fileExit.setActionCommand("exit");
		fileExit.addActionListener(this);
		file.add(fileExit);

		final JMenu options = new JMenu("Options");
		options.setMnemonic('p');
		menubar.add(options);
		final JMenuItem optionsFPS = new JMenuItem("Frames per Second...");
		optionsFPS.setMnemonic('f');
		optionsFPS.setActionCommand("fps");
		optionsFPS.addActionListener(this);
		options.add(optionsFPS);

		final JMenu help = new JMenu("Help");
		help.setMnemonic('h');
		menubar.add(help);
		final JMenuItem helpAbout = new JMenuItem("About...");
		helpAbout.setMnemonic('a');
		helpAbout.setActionCommand("about");
		helpAbout.addActionListener(this);
		help.add(helpAbout);

		// add key listener to focusable components
		nSlider.addKeyListener(this);
	}