JTable and JXTables have a header cell that is generated above the scrollbar. It's a small cell but I would like to use it to render an icon and popup menu. How might I access this header cell?
Thanks
In JXTable, the property to set is the columnControl: basically, it can be any component you like. To keep the functionality of the default, you can subclass ColumnControlButton
Related
I'm trying to implement a JXTreeTable with scrollable cells.
I used custom TableCellRenderer and it looked good, but renderer does not handle events, therefore I added an custom editor to the JXTreeTable.
I thought the cells would be editable once I override isCellEditable() and let it return true anyway but It turned out not. Cells are still not editable, thus I cannot scroll the cells even there are scroll bars.
Any ideas?
I'm writing an application that has a JTable, and an edit button that sets the current selected row to be editable. Then once the user is done altering the data, they can click the edit button again (with text that now says "Save") to save the data.
The problem is though, when I set a row to be editable, there isn't a visible difference. I could add some code to the renderer to draw the editable cells a little differently, but I don't know what the proper way to make a cell look editable is. Change the color? Make it look like a JTextField? What's the standard method?
Thanks!
Really this is a user interface design question, not a programming one.
To do what you want you need to supply an appropriate cell renderer with the changes you desire but you will need to decide on your own settings. One option might just be to look at the difference between an editable and non-editable text area and apply those to all the cells on the table. This may be as simple as setting the renderers to disabled for any read-only rows.
As second picture says, I want to anchor 'HeaderModel' left and 'CellModel' right. If its possible...
A JTable will display whatever data is returned by the getValueAt() method. You can change a cell's appearance using a suitable renderer. You can obtain a copy of the default header renderer, as shown here. This complete example shows how to apply the renderer to the table's first column.
I want to have multiline feature for JTable cells. Wherein the cell automatically expands and shrinks itself when user writes or deletes text in/from cell. I have set columns width, but it doesnt automatically adjust itself according to user's input, rather text beyond the width are not seen at all, but i have a requirement to fix on the width. Can anyone help me with this, to have self adjusting and multiline feature for jtable cell. Would be very thankful.
Thanks in advance.
Several steps:
implement a custom renderer using a JTextArea as rendering component
implement a custom editor using a JTextArea inside a JScrollPane as editing component
add logic (aka: TableModelListener) which updates JTable's individual rowHeight based on the renderer's preferred size on receiving a change notification
I want to create a JTable with a header inside some cells. But I want to associate a text with this header. Is it possible? How to do?
All my best!
Leandro Lima
If I understand the question then you can create a panel using a BorderLayout. You add the table to the CENTER and the table header to the NORTH.
table.getColumnModel().getColumn(x).setHeaderValue( "text" );
I only way to do it I found was to create a table, without cells and with a column with a header title. So I get this header and put it inside other table by cell renderer.