Example usage for javax.swing JSlider setMinimum

List of usage examples for javax.swing JSlider setMinimum

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The sliders minimum value.")
public void setMinimum(int minimum) 

Source Link

Document

Sets the slider's minimum value to minimum .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    int newMin = 0;
    slider.setMinimum(newMin);

}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    JSlider slider = new JSlider();

    int newMin = 0;
    slider.setMinimum(newMin);

    int newMax = 256;
    slider.setMaximum(newMax);/*  ww w . jav a  2 s .c  o  m*/
}

From source file:MainClass.java

public MainClass() {
    Container cp = new Box(BoxLayout.X_AXIS);
    setContentPane(cp);// ww w  .j a  v  a 2  s. com
    JPanel firstPanel = new JPanel();
    propertyComboBox = new JComboBox();
    propertyComboBox.addItem("text");
    propertyComboBox.addItem("font");
    propertyComboBox.addItem("background");
    propertyComboBox.addItem("foreground");
    firstPanel.add(propertyComboBox);
    cp.add(firstPanel);
    cp.add(Box.createGlue());

    tf = new JTextField("Hello");
    tf.setForeground(Color.RED);
    tf.setDragEnabled(true);
    cp.add(tf);

    cp.add(Box.createGlue());

    l = new JLabel("Hello");
    l.setBackground(Color.YELLOW);
    cp.add(l);

    cp.add(Box.createGlue());

    JSlider stryder = new JSlider(SwingConstants.VERTICAL);
    stryder.setMinimum(10);
    stryder.setValue(14);
    stryder.setMaximum(72);
    stryder.setMajorTickSpacing(10);
    stryder.setPaintTicks(true);

    cp.add(stryder);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 300);

    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    MouseListener myDragListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);
        }
    };
    l.addMouseListener(myDragListener);

    propertyComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ce) {
            JComboBox bx = (JComboBox) ce.getSource();
            String prop = (String) bx.getSelectedItem();
            setMyTransferHandlers(prop);
        }
    });

    tf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JTextField jtf = (JTextField) evt.getSource();
            String fontName = jtf.getText();
            Font font = new Font(fontName, Font.BOLD, 18);
            tf.setFont(font);
        }
    });

    stryder.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider sl = (JSlider) evt.getSource();
            Font oldf = tf.getFont();
            Font newf = oldf.deriveFont((float) sl.getValue());
            tf.setFont(newf);
        }
    });
}

From source file:biomine.bmvis2.pipeline.EdgeGoodnessHider.java

public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) {
    double maxEdge = 0;
    for (VisualEdge e : graph.getAllEdges()) {
        maxEdge = Math.max(maxEdge, e.getGoodness());
    }/*from   w  w  w.  jav  a 2s .  c om*/

    final int scale = 100;
    final JSlider limitSlider = new JSlider();
    limitSlider.setMinimum(0);
    limitSlider.setMaximum(scale);
    limitSlider.setValue((int) (limit * scale));
    final JTextField limitText = new JTextField();
    limitText.setEditable(false);
    limitText.setText("" + limit);

    limitSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            limit = limitSlider.getValue() / (double) scale;
            limitText.setText("" + limit);
            v.settingsChanged(false);
        }
    });

    JPanel ret = new JPanel();
    GridBagLayout bag = new GridBagLayout();
    ret.setLayout(bag);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = c.HORIZONTAL;
    ret.add(limitSlider, c);
    c.gridy++;
    ret.add(limitText, c);
    return ret;
}

From source file:Transfer.java

public Transfer() {

    // Establish the GUI
    Container cp = new Box(BoxLayout.X_AXIS);
    setContentPane(cp);//from  w  ww  .j  av a  2 s .com
    JPanel firstPanel = new JPanel();
    propertyComboBox = new JComboBox();
    propertyComboBox.addItem("text");
    propertyComboBox.addItem("font");
    propertyComboBox.addItem("background");
    propertyComboBox.addItem("foreground");
    firstPanel.add(propertyComboBox);
    cp.add(firstPanel);
    cp.add(Box.createGlue());

    tf = new JTextField("Hello");
    tf.setForeground(Color.RED);
    tf.setDragEnabled(true);
    cp.add(tf);

    cp.add(Box.createGlue());

    l = new JLabel("Hello");
    l.setBackground(Color.YELLOW);
    cp.add(l);

    cp.add(Box.createGlue());

    JSlider stryder = new JSlider(SwingConstants.VERTICAL);
    stryder.setMinimum(10);
    stryder.setValue(14);
    stryder.setMaximum(72);
    stryder.setMajorTickSpacing(10);
    stryder.setPaintTicks(true);

    cp.add(stryder);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 300);

    // Add Listeners and Converters
    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    // Mousing in the Label starts a Drag.
    MouseListener myDragListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);
        }
    };
    l.addMouseListener(myDragListener);

    // Selecting in the ComboBox makes that the property that is xfered.
    propertyComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ce) {
            JComboBox bx = (JComboBox) ce.getSource();
            String prop = (String) bx.getSelectedItem();
            setMyTransferHandlers(prop);
        }
    });

    // Typing a word and pressing enter in the TextField tries
    // to set that as the font name.
    tf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JTextField jtf = (JTextField) evt.getSource();
            String fontName = jtf.getText();
            Font font = new Font(fontName, Font.BOLD, 18);
            tf.setFont(font);
        }
    });

    // Setting the Slider sets that font into the textfield.
    stryder.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider sl = (JSlider) evt.getSource();
            Font oldf = tf.getFont();
            Font newf = oldf.deriveFont((float) sl.getValue());
            tf.setFont(newf);
        }
    });

}

From source file:au.edu.uwa.csse.plot.Clustering.java

private void setUpView(Graph graph) throws IOException {

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Integer, Number> layout = new AggregateLayout<Integer, Number>(
            new FRLayout<Integer, Number>(graph));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    vv.setVertexToolTipTransformer(Plot.vertexLabelTransformer);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()/*  w  w w .  j av a 2s. c om*/
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:fr.free.hd.servers.gui.FaceView.java

private JPanel createMouth() {
    JPanel panel = new JPanel(new GridLayout(3, 0));
    final JSlider slider = new JSlider();
    final JSlider sliderX = new JSlider();
    final JSlider sliderY = new JSlider();
    slider.setMinimum(0);
    slider.setMaximum(1000);//  w  w w  .j a  v  a2 s . co  m
    slider.setMajorTickSpacing(100);
    slider.setPaintLabels(true);
    slider.setPaintTicks(true);
    slider.setPaintTrack(true);
    sliderX.setMinimum(-1000);
    sliderX.setMaximum(1000);
    sliderX.setMajorTickSpacing(100);
    sliderX.setPaintLabels(true);
    sliderX.setPaintTicks(true);
    sliderX.setPaintTrack(true);
    sliderY.setMinimum(-1000);
    sliderY.setMaximum(1000);
    sliderY.setMajorTickSpacing(100);
    sliderY.setPaintLabels(true);
    sliderY.setPaintTicks(true);
    sliderY.setPaintTrack(true);

    sliderX.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            face.setMouthXPercent(sliderX.getValue());
            updateLabel();
        }
    });
    sliderY.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            face.setMouthYPercent(sliderY.getValue());
            updateLabel();
        }
    });
    slider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            face.setMouthRatio(slider.getValue());
            updateLabel();
        }
    });

    panel.add(slider);
    panel.add(sliderX);
    panel.add(sliderY);

    return panel;
}

From source file:cimat.tesis.sna.visualization.ClusteringDemo.java

private void setUpView(BufferedReader br) throws IOException {

    Factory<Number> vertexFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }//  ww  w  . j  av  a  2 s . c o m
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }
    };

    PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>(
            vertexFactory, edgeFactory);

    final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>();

    pnr.load(br, graph);

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>(
            new FRLayout<Number, Number>(graph));

    vv = new VisualizationViewer<Number, Number>(layout);
    vv.setBackground(Color.white);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() {
        public Paint transform(Number v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:geovista.network.gui.ClusteringDemo.java

private void setUpView() throws IOException {

    /*// w  w  w  .  ja va  2s . c o  m
     * Factory<Integer> vertexFactory = new Factory<Integer>() { int n = 0;
     * public Integer create() { return n++; } }; Factory<Number>
     * edgeFactory = new Factory<Number>() { int n = 0; public Number
     * create() { return n++; } };
     */

    /*
     * PajekNetReader<Graph<Integer, Number>, Integer,Number> pnr = new
     * PajekNetReader<Graph<Integer, Number>, Integer,Number>(vertexFactory,
     * edgeFactory);
     * 
     * final Graph<Integer,Number> graph = new SparseMultigraph<Integer,
     * Number>();
     * 
     * pnr.load(br, graph);
     */

    // Create a simple layout frame
    // specify the Fruchterman-Rheingold layout algorithm
    layout = new AggregateLayout<Integer, Number>(new FRLayout<Integer, Number>(g));

    vv = new VisualizationViewer<Integer, Number>(layout);
    vv.setBackground(Color.white);
    // Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Integer, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Integer, Paint>() {
        public Paint transform(Integer v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.blue;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY) {
                return THIN;
            } else {
                return THICK;
            }
        }
    });

    /*
     * //add restart button JButton scramble = new JButton("Restart");
     * scramble.addActionListener(new ActionListener() { public void
     * actionPerformed(ActionEvent arg0) { Layout layout =
     * vv.getGraphLayout(); layout.initialize(); Relaxer relaxer =
     * vv.getModel().getRelaxer(); if(relaxer != null) { relaxer.stop();
     * relaxer.prerelax(); relaxer.relax(); } }
     * 
     * });
     * 
     * DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
     * vv.setGraphMouse(gm);
     */

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    // Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(g.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    // edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    // TO DO: edgeBetweennessSlider.add(new
    // JLabel("Node Size (PageRank With Priors):"));
    // I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    /*
     * eastControls.setOpaque(true); eastControls.setLayout(new
     * BoxLayout(eastControls, BoxLayout.Y_AXIS));
     * eastControls.add(Box.createVerticalGlue());
     */
    // eastControls.add(edgeBetweennessSlider);

    final Box cluster_panel = Box.createVerticalBox();
    cluster_panel.setBorder(BorderFactory.createTitledBorder("Cluster"));
    cluster_panel.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    /*
     * eastControls.setBorder(sliderBorder); //eastControls.add(eastSize);
     * eastControls.add(Box.createVerticalGlue());
     */

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    cluster_panel.add(groupVertices);
    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    // grid.add(scramble);
    grid.add(cluster_panel);
    // south.add
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    // p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    // p.add(gm.getModeComboBox());
    south.add(p);

    content.add(south, BorderLayout.SOUTH);
}

From source file:fr.free.hd.servers.gui.FaceView.java

private JPanel createKind() {
    JPanel panel = new JPanel(new GridLayout(3, 0));
    final JSlider sliderX = new JSlider();
    final JSlider sliderY = new JSlider();
    final JComboBox box = new JComboBox(HandKeyEnum.values());
    sliderX.setMinimum(-1000);
    sliderX.setMaximum(1000);/*from  w  ww.  jav  a  2s.  c  om*/
    sliderX.setMajorTickSpacing(100);
    sliderX.setPaintLabels(true);
    sliderX.setPaintTicks(true);
    sliderX.setPaintTrack(true);
    sliderY.setMinimum(-1000);
    sliderY.setMaximum(1000);
    sliderY.setMajorTickSpacing(100);
    sliderY.setPaintLabels(true);
    sliderY.setPaintTicks(true);
    sliderY.setPaintTrack(true);

    box.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            kind = (HandKeyEnum) e.getItem();
            updateLabel();
        }
    });
    panel.add(box);

    sliderX.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (kind) {
            case HAND_KEY_2D:
                face.setAnchorX_2D(sliderX.getValue());
                break;
            case HAND_KEY_2M:
                face.setAnchorX_2M(sliderX.getValue());
                break;
            case HAND_KEY_1M:
                face.setAnchorX_1M(sliderX.getValue());
                break;
            case HAND_KEY_2V:
                face.setAnchorX_2V(sliderX.getValue());
                break;
            case HAND_KEY_3D:
                face.setAnchorX_3D(sliderX.getValue());
                break;
            case HAND_KEY_3G:
                face.setAnchorX_3G(sliderX.getValue());
                break;
            case HAND_KEY_4G:
                face.setAnchorX_4G(sliderX.getValue());
                break;
            case HAND_KEY_5M:
                face.setAnchorX_5M(sliderX.getValue());
                break;
            }
            updateLabel();
        }
    });
    sliderY.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            switch (kind) {
            case HAND_KEY_2D:
                face.setAnchorY_2D(sliderY.getValue());
                break;
            case HAND_KEY_2M:
                face.setAnchorY_2M(sliderY.getValue());
                break;
            case HAND_KEY_1M:
                face.setAnchorY_1M(sliderY.getValue());
                break;
            case HAND_KEY_2V:
                face.setAnchorY_2V(sliderY.getValue());
                break;
            case HAND_KEY_3D:
                face.setAnchorY_3D(sliderY.getValue());
                break;
            case HAND_KEY_3G:
                face.setAnchorY_3G(sliderY.getValue());
                break;
            case HAND_KEY_4G:
                face.setAnchorY_4G(sliderY.getValue());
                break;
            case HAND_KEY_5M:
                face.setAnchorY_5M(sliderY.getValue());
                break;
            }
            updateLabel();
        }
    });
    panel.add(sliderX);
    panel.add(sliderY);
    return panel;
}