JTable

B

Bumsys

I have two lines:
version
time.

How can do that in cell of jtable shows this lines in the center and
not in one line but in two lines?
 
J

John B. Matthews

I have two lines:
version
time.

How can do that in cell of jtable shows this lines in the center and
not in one line but in two lines?

I'm having trouble understanding your question.

You can change the appearance of a cell based on its content type using
a custom cell renderer:

<http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#re
nderer>

You can put whatever you want in the rows and columns using a suitable
TableModel:

<http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#da
ta>

Your example shows two columns and one row, so your subclass of
AbstractTableModel might include something like:

public int getRowCount() { return 2; }
public int getColumnCount() { return 1; }
public Object getValueAt(int row, int col) {
if (row == 0) return "version";
else return "time";
}
 
R

RedGrittyBrick

(e-mail address removed) wrote:

Omitted context reinstated:
I want to have mult-line cell in jtable and also that the data lies in
the center of the cell.

I'd try John's suggestion.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,124
Latest member
JuniorPell
Top