File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JTextArea in JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea in JTable" Watch "JTextArea in JTable" New topic
Author

JTextArea in JTable

illya figotin
Greenhorn

Joined: Aug 09, 2001
Posts: 5
I have the following question:
I want my JTable to be able to edit large text in some of the cells, so that when user clicks on a cell it should expand (like JComboBox expands), and alow the user to edit text in this larger window (JTextArea).
If anybody have any ideas, please let me know.
I really apreciate any help.
Thanks.
Javaoops
Ranch Hand

Joined: Jun 21, 2001
Posts: 57
Using TableCellRender you can customize the particular cells
illya figotin
Greenhorn

Joined: Aug 09, 2001
Posts: 5
Rajan:
I am using TableCellRenderer and also TableCellEditor.
The problem is that when I am editing the cell with JTextArea,
is shown completely in the cell rectangle. I want this JTextArea to be larger than other cells. In the case of JComboBox it works fine, it is shown over other cells when you edit it.
What do you think the problem here?
Thanks for you respond.
Javaoops
Ranch Hand

Joined: Jun 21, 2001
Posts: 57
Did u try to set your own width for textarea column.


illya figotin
Greenhorn

Joined: Aug 09, 2001
Posts: 5

See, I don't want to reseize whole row, I want to make this JTextArea to be visible over other cells,when the user edits it.
Like people do with JComboBox - it overlapps other cells. Or JPopup menu, it is a pop-up window. So, now I need to figure out how to make JTextArea a pop-up type of windo.
Do know how can I do it?
Thanks for your help.
Sayuri Coppinger
Greenhorn

Joined: Jun 06, 2001
Posts: 20
One of the parameters in the get table cell renderer component is the flag isSelected. You can check for this flag, and if it is selected you can change the way the component looks. That is you can change its size, font, background and so on...
illya figotin
Greenhorn

Joined: Aug 09, 2001
Posts: 5
Sayuri:
Yes, I check for isSelected. But the end, any changes I've made will disappear, because JTable puts my JTextArea in the cell area, so it is still in the cell rectangle, and it doesn't look like JTextArea.
Could you please advise me something in this case?
Thanks.
Ilya.
Sayuri Coppinger
Greenhorn

Joined: Jun 06, 2001
Posts: 20
If you want the cell to expand only when editing, you could use your own table cell editor (more or less the same concept as the cell renderer)
But if you want the cell to always have the same "look", then you will need to change the row height of the table, and make the appropriate changes in your renderer to always have the same preferred size...
Sayuri
Originally posted by illya figotin:
Sayuri:
Yes, I check for isSelected. But the end, any changes I've made will disappear, because JTable puts my JTextArea in the cell area, so it is still in the cell rectangle, and it doesn't look like JTextArea.
Could you please advise me something in this case?
Thanks.
Ilya.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JTextArea in JTable
 
Similar Threads
JTable
jtable
JTable
JTable
JTable