We are about to switch to a new forum software. Until then we have removed the registration on this forum.
hi,
somebody who know how to make each button from radio to the length from the text-label? (see line 10)
import controlP5.*;
ControlP5 cp5 = new ControlP5(this);
size(300, 200);
RadioButton r;
r = cp5.addRadioButton("radio")
.setNoneSelectedAllowed(false)
.setItemsPerRow(4)
//.setItemWidth(70) //its to short or to long
.addItem("sdfsdf ", 1)
.addItem("asdfasdf", 2)
.addItem("sdf", 3)
.addItem("dfsasdfasdf", 4)
;
for (Toggle t : r.getItems ()) {
t.getCaptionLabel().align(CENTER, CENTER);
t.getCaptionLabel().setControlFont(new ControlFont(createFont("Arial", 12)));
}
Answers
somebody an idea? ~:>
Changing the width of an individual item is easy but you can't set individual spacing!
You will get better results if you don't create a new ControlFont for each Toggle.
thank you colouredmirrorball! :)
now it works.
..ok, but is there any other/better method to change my font from the radioButtons?
In this simple example it would not matter much, but if you were doing this for a large list you'd end up with a large amount of controlFont objects which are all just the same, littering memory.
alright ;)
but is there a difference between:
t.getCaptionLabel().setControlFont(new ControlFont(createFont("Arial", 12)));
and
t.captionLabel().setFont(createFont("Arial", 12));
?
I don't think so. The Javadoc doesn't even mention the setControlFont() method.
ok, but it's better to use the first or the second variety?
I don't know for sure but it shouldn't matter much.