3

Can anyone please tell me how to make an interface like that which is been shown below. Right now i'm using two JRadioButton for implementing that task. My code which i've done is shown below

JRadioButton but1 = new JRadioButton("Option 1");
JRadioButton but2 = new JRadioButton("Option 2");

ButtonGroup db=new ButtonGroup();
db.add(but1);
db.add(but2);

But how can we make the interface shown in the picture which does the same task that i've done through JRadioButtons.

enter image description here

Nidhish Krishnan
  • 20,593
  • 6
  • 63
  • 76

1 Answers1

5
  • required custom Icons and two JToggleButtons chained by ItemListener

  • create JSlider with two ranges (required custom painting)

  • great idea by @oliholz

Community
  • 1
  • 1
mKorbel
  • 109,525
  • 20
  • 134
  • 319
  • 1
    Nice link. I would probably use a `JSlider` with custom painting. Because that already has the "slider feeling" implemented and the logic is already there. – brimborium Nov 30 '12 at 12:59
  • There's a `BasicSliderUI` example [here](http://stackoverflow.com/a/6996263/230513). – trashgod Nov 30 '12 at 14:11