radio button - Java: How do I change the font size of a JRadioButton? -
how change font size of jradiobutton (in java)? want make text 24px instead of default matches label.
here's link picture of window... (i don't have enough reputation post image directly...)
http://i.stack.imgur.com/z60kn.png
and here's snippet of code...
// question 1: make labels / radio buttons / buttons / rows jlabel q1 = new jlabel("question 1: 2 + 4"); q1.setfont (q1.getfont ().derivefont (24.0f)); final jradiobutton q1a1 = new jradiobutton("5"); final jradiobutton q1a2 = new jradiobutton("6"); final jradiobutton q1a3 = new jradiobutton("7"); final jradiobutton q1a4 = new jradiobutton("8"); jbutton q1go = new jbutton("go"); jbutton q1exit = new jbutton("exit"); jpanel question = new jpanel(); jpanel answers = new jpanel(); jpanel buttons = new jpanel(); question.setlayout(new boxlayout(question, boxlayout.x_axis)); answers.setlayout(new boxlayout(answers, boxlayout.y_axis)); buttons.setlayout(new boxlayout(buttons, boxlayout.x_axis)); // add rows question.add(q1); answers.add(q1a1); answers.add(q1a2); answers.add(q1a3); answers.add(q1a4); buttons.add(q1go); buttons.add(q1exit); // add rows add(question); add(answers); add(answers); add(answers); add(answers); add(buttons); // group radio buttons buttongroup group = new buttongroup(); group.add(q1a1); group.add(q1a2); group.add(q1a3); group.add(q1a4);
thanks in advance!
-hewwocraziness
you've done it. want label have same font size jlabel right. can by
q1a1.setfont(q1.getfont()); //assign label's font radiobutton's font
or same way you've done label
q1a1.setfont(q1a1.getfont().derivefont(24.0f));
Comments
Post a Comment