Results 1 to 2 of 2
  1. #1
    nancyhung is offline Member
    Join Date
    Jan 2008
    Posts
    5
    Rep Power
    0

    Default Can we add JCheckBox array into JTextArea?

    I cannot add the JCheckBox array one by one within the JTextArea, but only can add them into the JPanel one by one.

    Is it possible to add the JCheckBox array within the JTextArea ??

    Thanks !!

    Nancy



    Code:

    ..
    ..
    ...
    rightUpper_left = new JPanel(); //right upper left panel
    rightUpper_left.setLayout(new GridLayout(3, 1));

    textArea2 = new JTextArea(22,60);
    textArea2.setEditable(false);

    image = new JCheckBox[3];

    for (int i = 0; i < 3; i++)
    {
    image[i] = new JCheckBox(getImageData(i+1) + "" + anno_label);
    //textArea2.append(image[i] + "");
    //textArea2.append(image[i].toString());
    rightUpper_left.add(image[i]);
    }

    for (int i = 0; i < 3; i++)
    {
    CheckBoxHandler handler = new CheckBoxHandler();
    image[i].addItemListener(handler);
    }

    textArea2.setText(getImage());
    rightUpper_left.add(new JScrollPane(textArea2,JScrollPane.VERTICAL_SCROLLB AR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEED ED));
    ..
    ..

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Is it possible to add the JCheckBox array within the JTextArea ??
    It may be but probably won't work very well. It is better to add JCheckboxes to a JPanel. Since both the JTextArea and the JCheckBox consume/use MouseEvents there will probably be some confusion about who is use the events.

Similar Threads

  1. JTextArea setting
    By newtojava7 in forum New To Java
    Replies: 1
    Last Post: 01-29-2008, 02:57 AM
  2. JTextArea
    By saytri in forum New To Java
    Replies: 0
    Last Post: 01-13-2008, 01:07 AM
  3. jcheckbox issues need help. thanks.
    By carlos123 in forum New To Java
    Replies: 3
    Last Post: 11-05-2007, 10:37 PM
  4. Replies: 1
    Last Post: 08-08-2007, 01:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •