Results 1 to 5 of 5
  1. #1
    Joe100 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default JTable Containing JTextArea

    Hallo,
    i am generating a JTable in my UI:

    Java Code:
    for(int i=0;i<topics.size();i++){
    postTextArea.setText(topics.getContent());
    Object[] tmp = {topics.getUsername(),postTextArea, "options"};
    			
    tabModel.addRow(tmp);
    			
    			
    		}
    		add(table, "cell 1 2,grow");
    What i want: the JTextArea containing the specific text is being displayed in this table.
    What happens: at the points in the table, where the JTextArea should be displayed, there are information like
    "javax.swing.JTextArea[,0,0,0x0,invalid,layout=javax.swing.plaf.basic.Bas icTextUI$UpdateHandler,alignmentX=0.0,alignmentY=0 .0,border=javax.swing.plaf.basic.BasicBorders$Marg inBorder@8dcd5d,flags=296,maximumSize=,minimumSize =,preferredSize=,caretColor=sun.swing.PrintColorUI Resource[r=51,g=51,b=51],disabledTextColor=javax.swing.plaf.ColorUIResourc e[r=184,g=207,b=229],editable=true,margin=javax.swing.plaf.InsetsUIRes ource[top=0,left=0,bottom=0,right=0],selectedTextColor=sun.swing.PrintColorUIResource[r=51,g=51,b=51],selectionColor=javax.swing.plaf.ColorUIResource[r=184,g=207,b=229],colums=0,columWidth=0,rows=0,rowHeight=0,word=fal se,wrap=false]"

    I dont want the Informatin, i want the JTextArea to be displayed. What am i doing wrong? How can i fix this?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're seeing the result of the toString() method call on your JTextArea.

    Have you read the JTable tutorial in the Swing tutorials? In particular the section on cell renderers (and editors)?

  3. #3
    Joe100 is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    I have read about CellRenderer yes. I have read an example with a button. But i wasn`t able to find out, how to use them in my context.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Joe100 View Post
    I have read about CellRenderer yes. I have read an example with a button. But i wasn`t able to find out, how to use them in my context.
    The concept for using it to display any component is the same, though I've never displayed anything more than a row in height, and I'm sure you'd have to fiddle with settings to make rows larger. If I were you, I'd start experimenting with using cell renderers.

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

Similar Threads

  1. Using JTextArea
    By tnixon22 in forum New To Java
    Replies: 10
    Last Post: 01-23-2011, 07:01 PM
  2. JTable vs JTextArea scrolling text question
    By adonos in forum AWT / Swing
    Replies: 2
    Last Post: 05-24-2010, 08:15 PM
  3. JTextArea on PopUp -JTextArea isn't editable
    By Richy76 in forum AWT / Swing
    Replies: 3
    Last Post: 02-01-2010, 07:51 PM
  4. How to add JTextArea in JTable - Swing
    By phungho2000 in forum AWT / Swing
    Replies: 5
    Last Post: 12-17-2008, 09:18 PM
  5. Replies: 2
    Last Post: 05-15-2008, 10:15 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
  •