This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi,Ravi. I'm intrested in your cellrender.Do you use it due to multiline table?Once I implement a cellrender like you.But it looks not very nice in JDK1.4.Can you share your cellrender with me?If anyone can add a scrollbar,that's better.I guess your render just render the TextArea.Maybe you need a render can render scrollbar too.
Now scrollPane is visible but I can't do scrollable operations on it. Do I need a mouseListener here? I'm guessing I missing something here... Please let me know if you ever experienced a problem like this.
Putting a scroll pane type component in a JTable is difficult at best. The reason for this is that JTable doesn't contain components. It creates an image using the renderer for each cell and paints that. There is no component behind each cell. As a result you can't add a mouse listener to your renderer. The JTable uses the renderer to derive the image to use for the cell and then throws it away.
When a cell is clicked and goes into editing mode, the table then creates an actual component based on the corresponding editor that is mapped to it. This component has its bounds/location defined as the area the cell renderer derived image previously occupied.
Relating this to your problem, you could have a cell renderer that uses a JTextArea and editor that uses a JTextArea. However, the first click the user makes won't scroll. It will trigger editing mode. You can hack around this but it isn't pretty.
I would suggest using a JTextfield renderer that displays text as "Text..." or something. When going into editing mode you can have a popup show up that contains your JTextArea.
Joined: Feb 26, 2002
Neat Idea; TextField with a pop-up JTextArea... I'll work on it and let you know the results