• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

JTextArea in JTable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using TableCellRender you can customize the particular cells
 
illya figotin
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic