javafx tableview column resizing issue

javafx tableview column resizing issue

By : Naveen Kumar
Date : November 20 2020, 11:01 PM
seems to work fine I had the same issue on my program, and I fixed it this way.
Leave the TableView as CONSTRAINED_RESIZE_POLICY. Then, on the TableColumn you want a certain width, set the max , min, and pref size to the same size. This way, it will be no bigger and no smaller than your size.
code :
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.TableColumn?>
<?import javafx.scene.control.TableView?>
<?import javafx.scene.layout.BorderPane?>

<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.91" xmlns:fx="http://javafx.com/fxml/1">
      <TableView prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
          <TableColumn prefWidth="75.0" text="First Name" />
          <TableColumn prefWidth="75.0" text="Last Name" />
            <TableColumn prefWidth="75.0" text="Email Address" />
            <TableColumn maxWidth="50.0" minWidth="50.0" prefWidth="50.0" text="Age" />
            <TableColumn maxWidth="50.0" minWidth="50.0" prefWidth="50.0" text="Height" />
            <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

import java.io.IOException;

public class Main extends Application {

    public static void main(String[] args) {

    public void start(Stage primaryStage) throws IOException {

        FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource("fxml/Environment.fxml"));
        Parent root = loader.load();
        Scene scene = new Scene(root,800,800);

Share : facebook icon twitter icon
JavaFX: bind TableView column with number of rows of another TableView

JavaFX: bind TableView column with number of rows of another TableView

By : Oliversc
Date : March 29 2020, 07:55 AM
This might help you I have a TableView of Roads with a column Name and a column Number of Lanes. Number of Lanes show a integer that is the number of lanes of a road. When add a new road, I have another TableView where set the properties for a lane. My Lane class is: , Are you looking for something like:
code :
public class Road {
   private final ObservableList<Lane> lanes = FXCollections.observableArrayList();
   public final ObservableList<Lane> getLanes() {
      return lanes ;

   private final ReadOnlyIntegerWrapper numberOfLanes = new ReadOnlyIntegerWrapper(this, "numberOfLanes");
   public final int getNumberOfLanes() {
      return numberOfLanes.get();
   public ReadOnlyIntegerProperty numberOfLanesProperty() {
      return numberOfLanes.getReadOnlyProperty();

   public Road() {
Resizing Columns of a TableView in javaFX

Resizing Columns of a TableView in javaFX

By : user3042294
Date : March 29 2020, 07:55 AM
this one helps. TableView.setColumnResizePolicy() is what you are looking for.
For Example:
code :
TableView automatic row height resizing - JavaFX

TableView automatic row height resizing - JavaFX

By : Daniel Jesus G P
Date : March 29 2020, 07:55 AM
wish helps you I resolved this by placing an invalidation listener on the observablelist such updateItem is called every time the list size changes.
code :
public void updateItem(ObservableList<Foo2> item, boolean empty) {
    super.updateItem(item, empty);
    if (empty || item == null) {
    } else {
        GridPane grid = new GridPane();
        int modulus;
        if (item.size() < 4) {
            modulus = 1;
        else if (item.size() < 9) {
            modulus = 2;
        else {
            modulus = 3;
        for (int i = 0; i < item.size(); ++i) {
            Label label = new Label();
            grid.add(label, i % modulus, (i % item.size()) / modulus);
        item.addListener(new InvalidationListener() {
            public void invalidated(Observable observable) {
                updateItem(item, empty);
JavaFx 2.1, 2.2 TableView update issue

JavaFx 2.1, 2.2 TableView update issue

By : Scott Tan
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further See the answer to Updating rows in Tableview. Add these getters and it will just work.
Additionally since the data is an ObservableList which is set as items to tableView, any changes to this data list will be reflected to the table.getItems() too. Namely no need to table.setItems(data) again.
JavaFX TableView performance issue

JavaFX TableView performance issue

By : Sergio
Date : March 29 2020, 07:55 AM
I wish this help you I made a lazy-load on tableview using the CellFactory class... I´ll try to explain, anyone with better english than mine fell free to edit and make it more understandable!
First I use a mandatory property in a Bean to check if that bean has already been loaded or not. This way I don't need to create an attribute specifically for that.
Related Posts Related Posts :
  • How to parse a string in java to get only some parts of it
  • How to replace special character using regex in Mule Dataweave transformation?
  • Storing some value in variable while using lambda expression
  • Ignore unit test: cannot find Symbol
  • How do I fill a shape created by random points (drawLine)?
  • exception-handling method exit without finishing
  • Spring boot gradle cannot load sqlserver dependency
  • Duplication of Property's ChangeListener after every window's appearance
  • Extracting multiple fields from one list and save it to another list or same type new list. In java 8
  • Running Tomcat server with SSL certificate triggers could not find or load main class cert.pkcs12
  • Java - How to keep JVM running while listening to clipboard changes?
  • Java: Load data into variables from a .yaml file
  • Eclipse can't open sub-project of maven-parent-project
  • Usage of XX:HeapDumpSegmentSize and XX:SegmentedHeapDumpThreshold
  • Receiving couldn't find class error even Setting Soot library classpath
  • Convert List of List of Object to a map - using lambdas in java 8
  • How to solve Endless Building process of spring boot framework?
  • Error: java.lang.UnsupportedOperationException: Not supported yet
  • Writing java object into .csv
  • How to set divider location for JSplitPane on start-up
  • Use JOOQ to do a delete specifying multiple columns in a "not in" clause
  • user input name times age
  • ConcurrentHashmap simultaneous write and get operations
  • How to concatenate a string from path to directory and a multiple zip files names in a directory?
  • Spring MVC Encode non-English parameters
  • How to join two (or more) streams (JavaDStream) in apache spark
  • Unable to restart glassfish 3 server
  • Could not find support-v4.aar(com.android.support:support-v4:24.1.1)
  • How to create jar file from existing jar file?
  • Whats difference between this two: BigInteger.valueOf(10000) and BigInteger.valueOf(0010000)?
  • Firebase Messaging - "too many alarms" on Samsung's Android devices
  • Apache POI: How do you restart numbering on a numbered list in word document?
  • Unsupported field: Year when formatting an instant to Date ISO
  • java serialize transient elements
  • why the program hang up when using ArrayBlockingQueue
  • Data objects conversion - instance method vs static method
  • Which checksum algorithm is being used by adobe acrobat pdf for file attachment
  • how to get list of all available images for a region in amazon web services using aws-java-sdk?
  • BufferedReader can not read the int in text
  • How to configure hadoop's mapper so that it takes <Text,IntWritable>
  • Change name of libGDX DesktopLauncher in mac OSX menu bar
  • parse the json file with mutiple objects using Jackson
  • It the planning entity must have one to one relationship with planning value?
  • My code is showing error
  • How can I modify the colors of pixels in a Texture?
  • compiling and executing java from bash script
  • How to test Spring mvc controller tests for response entity?
  • How to Switch between Native Mobile App to Web Application to verify the elements on it
  • Command 'web mvc all --package ~.web' not found
  • Reverse an array using swapping in Java
  • Trying to create a chessboard using an array and graphics
  • Can DatagramSocket Receive multicast Packets
  • What is abstract data type ? Is it a class in Java?
  • Non-gui checkout register menu: how to format it?
  • Glassfish The server exited prematurely with exit code 134
  • android: SharedPreferences not saving data
  • How to implement different log output by classloader in just one Java application?
  • Migrating to Google Cloud Endpoints Framework for Java
  • Does the Swing event dispatch thread run at higher priority than the main thread?
  • Android Studio Failing to Store Arguments as Part of Fragment Bundle
  • shadow
    Privacy Policy - Terms - Contact Us © soohba.com