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: adding Checkboxes to JTextArea

  1. #1
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default adding Checkboxes to JTextArea

     
    JTextArea display = new JTextArea();
      CheckboxGroup idList = new CheckboxGroup();
        Checkbox cID=null;
    display.append(add(new Checkbox(idno, idList, false))  + " " + thirdrow + " " + firstrow + " " + "#" + secondrow + " " + fifthrow + " " + sixthrow + "/" + seventhrow + "/" + eightrow + " TO " + ninerow + "/" + tenrow + "/" + elevenrow + " " + "$" + twelverow + " "  + fourthrow + "\n" + "\n");

    idno is an int from the mysql..

    i want to insert the checkbox to the JTextArea so that the user could select which entry he want to make the update... the error or bug i get is shown in picture



  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding Checkboxes to JTextArea

    shown in picture
    What is shown looks like what is returned by the object's toString() method. When you build a String and concatenate an object into it, the compiler calls the object's toString() to get a String to concatentate.
    The append() method takes a String as an argument.
    If you want to put components into a text display area, look at using the JTextPane class.

  3. #3
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: adding Checkboxes to JTextArea

    Quote Originally Posted by Norm View Post
    What is shown looks like what is returned by the object's toString() method. When you build a String and concatenate an object into it, the compiler calls the object's toString() to get a String to concatentate.
    The append() method takes a String as an argument.
    If you want to put components into a text display area, look at using the JTextPane class.
    sorry i am really new to this topic of java... after reading the API file i don't really understand how do i merge the JTextArea with my Checkbox with the JTextPane??

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding Checkboxes to JTextArea

    merge the JTextArea with my Checkbox with the JTextPane??
    The JTextPane replaces the JTextArea.
    The JTextPane allows you to display text and to have components like a Checkbox in with the text.
    Very similar to how HTML allows text and controls to be displayed in the same area.

  5. #5
    Member
    Join Date
    Mar 2011
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: adding Checkboxes to JTextArea

    Quote Originally Posted by Norm View Post
    The JTextPane replaces the JTextArea.
    The JTextPane allows you to display text and to have components like a Checkbox in with the text.
    Very similar to how HTML allows text and controls to be displayed in the same area.
    hi.. sorry for asking this.. i understand how do i insert the text and component to the JTextPane now.. and from my research CheckBox seems like only allow 1box to be selected at any 1 time.. as for JCheckBox i don't really understand how do i handle the selected boxes... what i need is something like those email checkboxes whereby u got click on multi checkbox and do a delete.... and the check box name or id would like link or set which a pri key gotten from the database...
    Last edited by bczm8703; November 7th, 2011 at 02:45 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: adding Checkboxes to JTextArea

    CheckBox seems like only allow 1box to be selected at any 1 time..
    I don't think that is correct. You can select all or none. Are you thinking of RadioButtons where only one of a group can be selected at a time.
    how do i handle the selected boxes
    Read the Tutorial: How to Use Buttons, Check Boxes, and Radio Buttons (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

Similar Threads

  1. JTextArea Problem
    By grimx in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 10th, 2011, 07:13 PM
  2. How would you get a JTextArea to know how many lines it had?
    By javapenguin in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 20th, 2011, 07:58 PM
  3. Getting items from a table/checkboxes
    By beth in forum AWT / Java Swing
    Replies: 2
    Last Post: January 5th, 2011, 01:29 PM
  4. Expanding JTextArea
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 27th, 2010, 10:15 PM
  5. JTable CheckBoxes
    By aussiemcgr in forum AWT / Java Swing
    Replies: 1
    Last Post: August 9th, 2010, 01:04 PM