Hi
let say that iam gonna make a character that have
Str: O O O O O
Dex: O O O O O
Int: O O O O O
Wis: O O O O O
Cha: O O O O O
and i dont want to use numbers but i want to use dots. How do i make a random character generator that have maybe 20 point to spend randomly?
I have try to make alot of JRadioButton and ButtonGroup for each dot but i dont know how to code the Random in them.
Iam just at the beginning level of learning java so all i know is System.out.pring, JRadioButton, ButtonGroup, Jpanel, random.
Sorry for my bad english and hope somebody can help me or just point me to the right direction.
// this is my code
public class Window extends JFrame {
private static final long serialVersionUID = 1L;
JRadioButton b1, b2, b3, b4, b5;
ButtonGroup group;
ButtonGroup group2;
ButtonGroup group3;
ButtonGroup group4;
ButtonGroup group5;
public Window() {
super("Charactor");
setSize(600, 400);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel p2 = new JPanel();
// i dont know what to do with this random??
int dice = 0;
Random r = new Random();
dice = r.nextInt(5);
JRadioButton b1 = new JRadioButton();
JRadioButton b2 = new JRadioButton("Str");
b2.setHorizontalTextPosition(SwingConstants.LEFT);
JRadioButton b3 = new JRadioButton();
JRadioButton b4 = new JRadioButton();
JRadioButton b5 = new JRadioButton();
group = new ButtonGroup();
group2 = new ButtonGroup();
group3 = new ButtonGroup();
group4 = new ButtonGroup();
group5 = new ButtonGroup();
group.add(b1);
group2.add(b2);
group3.add(b3);
group4.add(b4);
group5.add(b5);
p2.add(b1);
p2.add(b2);
p2.add(b3);
p2.add(b4);
p2.add(b5);
p2.add(b1);
add(p2);
}
}