TableColumn set width equal header - java

After i added a MenuButton I can not I can not get correct size
The tableView after load looks like this
How can i set each column's width to equal inner content width of that column ? OR Right blank space should be distributed in a balanced way
I can not do them both
tableColumns[i].setMinWidth(tableColumns[i].minWidthProperty().get() + 50);//does not work
tableView.columnResizePolicyProperty().set(...)//not work too

Related

How to get the text Width in pixels of each tree item from a TreeViewer in Java?

I want to get the text width in pixels of each tree item from a TreeViewer having 2 columns, so that I can get the maximum sized tree item to fix it as its respective column's width.
I have already tried using pack method, but it doesn't solve my purpose, as it fits column width to content size for the 1st level items, but not from 2nd level onward.
Please suggest any other way to autofit the column width to content size in JFace TreeViewer in Java.

JTable cell data showing "..." on column resize

Two questions:
1.) How do I put a min limit on column resize in JTable?
2.) How do I stop data from showing a "..." on column resize when data can't fit into cell?
//Minimum width 100 for first column
table.getColumnModel().getColumn(0).setMinWidth(100);
About the ..., I am not sure you can do anything but keeping the minimum width of the cell according to its value.

How to change the column width of a Individual column in excel in excel through Apache-POI

I want to change the column width of a column I have seen many answers suggesting the use of "AutoSizeColumn(int)" but the problem with that is that all columns have different sizes and it creates kind of a mess so i want to set all columns ( except one ) to one single width how do i do this??
You can set a default column width that controls all columns in the sheet that don't have their own custom width set. Use the setDefaultColumnWidth method.
Set the default column width for the sheet (if the columns do not define their own width) in characters
sheet.setDefaultColumnWidth(numChars);
Individual columns can override this default with the setColumnWidth method. The width here is in 1/256ths of a character, different from the default width units.
Set the width (in units of 1/256th of a character width)

Javafx tableview column header

I use font size to zoom data view when I increase font the size column header height increase in the right way but when reset font size column header height don't decreased how can I fix that , I am use java fx u40
Check if it is not just a refresh problem.
One way of checking this is:
yourTable.getColumns().get(0).setVisible(false);
yourTable.getColumns().get(0).setVisible(true);

Make the last column in a JavaFX TableView take the remaining space

How do I make the last column in a JavaFX TableView take the remaining space.
I have tried table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); but this makes the column sizes equal. I want only the last column to grow when the window width increases.
If you want all the columns in your tableview to fill up the window space available to the tableview AND be dynamically resized to adjust to changing the size of the window, then you need to bind the column properties to the tableview's width.
For example, say I have 5 columns in a tableview. I want them to always be a fixed percentage of the available width (so that when the window is resized, the proportions of the columns remain constant). You can easily form your own column sizing rules using the same property binding idiom (eg. I want the last column to take all the remaining space).
In the initialize() method of the controller that has my TableView control, I could do the following:
void initialize() {
// Initialize your logic here: all #FXML variables will have been injected
:
:
// TableView column control variables are prefixed with "tco"
tcoLast.setCellValueFactory(new PropertyValueFactory<Client.Expand, String>("lastName"));
tcoFirst.setCellValueFactory(new PropertyValueFactory<Client.Expand, String>("firstName"));
tcoDoB.setCellValueFactory(new PropertyValueFactory<Client.Expand, Integer>("doB"));
tcoMRN.setCellValueFactory(new PropertyValueFactory<Client.Expand, String>("defMRN"));
tcoGen.setCellValueFactory(new PropertyValueFactory<Client.Expand, String>("gender"));
// Cell factories for rendering certain columns in the TableView
tcoLast.setCellFactory(new ClientNameTableCellFactory());
tcoFirst.setCellFactory(new ClientNameTableCellFactory());
tcoDoB.setCellFactory(new ClientDoBTableCellFactory());
// Set fixed column widths that resize automatically
// Values are weighted to be a fraction of a total of 41 (arbitrary)
tcoLast.prefWidthProperty().bind(tbvMatches.widthProperty().multiply(11.0/41.0));
tcoFirst.prefWidthProperty().bind(tbvMatches.widthProperty().multiply(11.0/41.0));
tcoDoB.prefWidthProperty().bind(tbvMatches.widthProperty().multiply(8.0/41.0));
tcoMRN.prefWidthProperty().bind(tbvMatches.widthProperty().multiply(8.0/41.0));
tcoGen.prefWidthProperty().bind(tbvMatches.widthProperty().multiply(2.0/41.0));
:
:
}

Categories

Resources