Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Help to make a random character

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Help to make a random character

    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);


    }

    }


  2. #2
    Member
    Join Date
    Jul 2013
    Location
    Franklin, TN
    Posts
    47
    Thanks
    3
    Thanked 4 Times in 4 Posts

    Default Re: Help to make a random character

    Post your progress or problems you are having and we will assist you. We will not write code for you.

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help to make a random character

    Sorry iam new to this websit to

  4. #4
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: Help to make a random character

    Hey there, this codes generates a random character:
    ...code removed
    Last edited by copeg; July 30th, 2013 at 02:26 PM. Reason: Spoonfeeding removed

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Help to make a random character


  6. #6
    Member Andrew R's Avatar
    Join Date
    Jul 2013
    Location
    San Pedro Sula, Honduras
    Posts
    58
    My Mood
    Inspired
    Thanks
    11
    Thanked 1 Time in 1 Post

    Default Re: Help to make a random character

    Hmm. Thank you copeg. I'll keep that in mind.

Similar Threads

  1. [SOLVED] Make a polygon appear in random places using Japplet and Canvas
    By DANGEROUSSCION in forum Object Oriented Programming
    Replies: 3
    Last Post: February 23rd, 2013, 07:43 PM
  2. Trying to make 3 images become random in an Applet. Need help
    By slahsdash in forum What's Wrong With My Code?
    Replies: 20
    Last Post: March 9th, 2012, 09:39 PM
  3. The character '' is an invalid XML character exception getting
    By sumanta in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 9th, 2010, 12:13 PM