Link to home
Start Free TrialLog in
Avatar of ivanthepro
ivanthepro

asked on

JTable cell wrap

Does anyone knows how to wrap text in a Jtable cell?

Thanks

Ivan
Avatar of sptw
sptw

Are you using you own CellRenderer??
ASKER CERTIFIED SOLUTION
Avatar of bapi
bapi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ivanthepro

ASKER

ive got no idea, im new to this...
pls help from the beginning pls
>>>> " wrap text in jtable cell"... do you want to customize the appearance of the text?
i only want some multiline and justified alignment.

thanks
someone give me some basic codes pls
1. Write a java file say cellWrapText.java which extends JPanel.On the JPanel add a TextArea with scroll pane.

2. Write a java file say cellEditorText.java which extends TableCellEditor. create an instance of CellWrapText and in the getTableCellEditorComponent method of cellEditorText.java set the text to the text area.

3.Write a java file for render which extends JTextArea  implements TableCellRenderer.

4. Finally in the main file where u are creating the JTable
a) get the column for which you want to wrap the text.
TableColumn column = columnmodel.getColumn(columnNumber);
column.setCellEditor(instance of CellEditorText u have created);
column.setCellRenderer(instance of cell renderer u have created and pass the JTable to it);
ivanthepro:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for bapi

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Venabili
EE Cleanup Volunteer