Make JTable Column Header Not Movable/Resizable - java

Whatever I try I cannot get a JTable's header to be static. Right now you can click in the headers and drag them out or just relocate the entire columns of the table by moving the header.
Is there a way to prevent this and make the headers not editable?
Just to be clear I am not talking about the actual cells but the headers.

The class JTableHeader has a method
setReorderingAllowed(boolean reorderingAllowed)
did you try that already, or does it maybe help you with your problem?

Related

Edit column with stylename

I have a celltable with some columns, and want make 2 of them hidden, I tried to make a celltable column hidden, while doing following with css stylename:
firstColumn.setCellStyleNames("hide");
css:
.hide{
display:none;
}
but I get only the rows hidden, but not the header of the column, and the table not passed to the rest column, but there is still a white space on the column, I want to get hide all column with it header, how can I do it, any suggestion please?
The .setCellSomething will have effect only on the inner rows, not on the header. For that, use .setHeaderSomething, so:
firstColumn.setHeaderStyleNames("hide");
Gwt Project Docs - setHeaderStyleNames

Row header in JTable with same drag/drop behaviour as column header

I'm trying to have row headers in my JTable which have similar behaviour to the column headers, especially for the drag and drop part.
Something like this: JTable Row Header Implementation
And when I drag the row header, it should have the same visual effect as when I drag the column header and the same result (row/column is moved).
So far, one way I thought of is to create my own custom BasicTableHeaderUI and implement the paint() method. Not sure if that will cause problems if other look and feels were used?
You can add D&D listener to table cells or whole table, and than pass the event to EventHandler that handles D&D events on header.

How to change the font in the grid GXT3

Sorry for the simple question, how to change the font in the grid?
If you are talking about the text which might be displayed in one of your columns, you can do this easily with cells. When you set up your ColumnModel class, you can pass a custom cell to one of the columns. Then, with html and css, you can style up the column per your needs.
If you want to change the column headers, then you can simply pass some SafeHtml to that column's ColumnConfig.setHeader(SafeHtml) method. Again, this would be done when you set up your ColumnModel. This let's you style up the header however you wish.
If you do use images or css, I highly suggest using the ClientBundle and CSSResource classes.

JTable Row Header Text

Can somebody show me if there is a way to add a row header with a text, or maybe there is some type of trick, which will allow us to do something like this?
RowHeader is
one way
better way

How to change data in JTable cells?

I can set data in JTable constructor, and then user can change this data when program is running manually(typing from keyboard).
But what method should I use in case I want to change data in some column? To change column header I use TableColumn method setHeaderValue. What should I use to set value in JTable cell?
If you want to allow users to edit the data, then you need to set a TableCellEditor on the cells that you want people to edit. You probably also want to start using a TableModel instead of hard coding the data in the JTable itself.
See http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
While creating the JTable you first need to specify that the values of particular column are editable. You can obviously also provide the row basis edit functionality. but all these things you should define while ccreating the table itself. Please reply if you need any help on this.

Categories