This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextArea in JTable

 
illya figotin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using TableCellRender you can customize the particular cells
 
illya figotin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did u try to set your own width for textarea column.


 
illya figotin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic