Example usage for javax.swing JSlider setName

List of usage examples for javax.swing JSlider setName

Introduction

In this page you can find the example usage for javax.swing JSlider setName.

Prototype

public void setName(String name) 

Source Link

Document

Sets the name of the component to the specified string.

Usage

From source file:Main.java

public static JSlider getSlider(int w, int h, String name, int minValue, int maxValue, int initValue) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, initValue);
    slider.setFont(getFont());//from   www.j a va  2 s . c  o m
    slider.setPreferredSize(getSliderDimension(w, h));
    slider.setMinimumSize(getSliderDimension(w, h));
    slider.setName(name);
    return slider;
}

From source file:Main.java

public static JSlider getSlider(int w, int h, String name, int minValue, int maxValue) {
    JSlider slider = new JSlider(JSlider.HORIZONTAL, minValue, maxValue, ((maxValue + minValue) / 2));
    slider.setFont(getFont());// w ww .  j av a2  s  . c  o m
    slider.setPreferredSize(getSliderDimension(w, h));
    slider.setMinimumSize(getSliderDimension(w, h));
    slider.setName(name);
    return slider;
}

From source file:AtomPanel.java

private void commonInit() {
    //initial time series plots
    initJFreeChart();//from  w  w w . ja v a  2 s. c  o  m
    startFlag = false;

    //create control panel
    //        JPanel panel=new JPanel(new GridLayout(1,2));
    //add control buttons to control panel
    /*
    startButton=new JButton("Start");
    startButton.addActionListener(this);
    pauseButton=new JButton("Pause");
    pauseButton.addActionListener(this);
    stopButton=new JButton("Stop");
    stopButton.addActionListener(this);
    panel.add(startButton);
    panel.add(pauseButton);
    panel.add(stopButton);
    */
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    //Create the slider
    JSlider faRateSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT);
    faRateSlider.setName("faRate");
    faRateSlider.addChangeListener(this);
    faRateSlider.setMajorTickSpacing(30);
    faRateSlider.setPaintTicks(true);

    //Create the label table
    Hashtable labelTable = new Hashtable();
    labelTable.put(new Integer(L_MIN), new JLabel("0.1%"));
    labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel("   False Alarm Rate"));
    labelTable.put(new Integer(L_MAX), new JLabel("1%"));
    faRateSlider.setLabelTable(labelTable);

    faRateSlider.setPaintLabels(true);
    panel.add(faRateSlider);
    // window size slider
    JSlider wdSzSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, WDL_INIT);
    wdSzSlider.setName("wdSz");
    wdSzSlider.addChangeListener(this);
    wdSzSlider.setMajorTickSpacing(30);
    wdSzSlider.setPaintTicks(true);

    //Create the label table
    Hashtable wdTable = new Hashtable();
    wdTable.put(new Integer(L_MIN), new JLabel("20"));
    wdTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel("   Window Size"));
    wdTable.put(new Integer(L_MAX), new JLabel("200"));
    wdSzSlider.setLabelTable(wdTable);

    wdSzSlider.setPaintLabels(true);
    panel.add(wdSzSlider);
    if (AtomUtils.PCAType.pcaTrack == this.pcaType) { // new: tracking delta bar
        JSlider deltaSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT);
        deltaSlider.setName("delta");
        deltaSlider.addChangeListener(this);
        deltaSlider.setMajorTickSpacing(30);
        deltaSlider.setPaintTicks(true);

        //Create the label table
        labelTable = new Hashtable();
        labelTable.put(new Integer(L_MIN), new JLabel("0%"));
        labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel("   Tracking Threshold"));
        labelTable.put(new Integer(L_MAX), new JLabel("20%"));
        deltaSlider.setLabelTable(labelTable);

        deltaSlider.setPaintLabels(true);
        panel.add(deltaSlider);

        // tracking saving label
        trackSaveLabel = new JLabel();
        trackSaveLabel.setText("Saved/Total:0/0");
        panel.add(trackSaveLabel);
    }
    if (AtomUtils.PCAType.pcaTrackAdjust == this.pcaType) {
        JSlider devSlider = new JSlider(JSlider.HORIZONTAL, L_MIN, L_MAX, L_INIT);
        devSlider.setName("devbnd");
        devSlider.addChangeListener(this);
        devSlider.setMajorTickSpacing(30);
        devSlider.setPaintTicks(true);

        //Create the label table
        labelTable = new Hashtable();
        labelTable.put(new Integer(L_MIN), new JLabel("0%"));
        labelTable.put(new Integer((L_MIN + L_MAX) / 2), new JLabel("   Deviation Bound"));
        labelTable.put(new Integer(L_MAX), new JLabel("1%"));
        devSlider.setLabelTable(labelTable);

        devSlider.setPaintLabels(true);
        panel.add(devSlider);

        // tracking saving label
        trackSaveLabel = new JLabel();
        trackSaveLabel.setText("Saved/Total:0/0");
        panel.add(trackSaveLabel);
    }
    add(panel, BorderLayout.SOUTH);

}