0

In the end it should look like thisenter image description here

I have a slider in a panel, that goes from 0 to 100. I want, that there is a name left of the slider and that after the name there is the current number the slider is currently at. In the picture there slider is currently at 10.

At the Moment I only have

class tester extends javax.swing.JFrame{ 
    Jframe frame = new JFrame;
    BorderLayout borderlayout = new BorderLayout();

    private void test() {
        JPanel panel = new JPanel();
        add(panel, borderlayout.CENTER); // the panel is in the center of the frame
        panel.setLayout(new javax.swing.BoxLayout(panel, BoxLayout.Y_AXIS));
        JSlider testslider= new JSlider(0,100);
        panel.add(testslider);
    } 
}

So a very standard slider. How do I get a name left of the slider and the current value on it?

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
relot
  • 651
  • 1
  • 6
  • 18
  • 1. Add two JLabels to the left of the JSlider in your JPanel. 2. The first JLabel will have the text. 3. The second should have text that is updated within a ChangeListener that is added to the JSlider, showing the value of the slider. – Hovercraft Full Of Eels Jun 20 '17 at 20:52
  • 1
    Note that your question is a multi-parter, including asking about placement of components and of showing the JSlider's value. In the future, break your problem down, try to solve each one, one at a time, and then if stuck, as a single-part question, showing your attempted solution with it. Good luck. – Hovercraft Full Of Eels Jun 20 '17 at 21:03

0 Answers0