Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:20:24+00:00 2026-06-11T17:20:24+00:00

I have two distinct components: a TableView and a TitledPane next to the table.

  • 0

I have two distinct components: a TableView and a TitledPane next to the table.
What I´m trying to do is to redimension the tableview but only when the titledpane expands or collapse.
When the titledpane collapse the tableview gets bigger and when it expands the tableview gets smaller.
I don´t know what action should I take.
Anybody knows the solution?

Regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:20:26+00:00Added an answer on June 11, 2026 at 5:20 pm

    Check out the sample code below:

    import javafx.application.Application;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.collections.FXCollections;
    import javafx.collections.ObservableList;
    import javafx.scene.Scene;
    import javafx.scene.control.TableColumn;
    import javafx.scene.control.TableView;
    import javafx.scene.control.TitledPane;
    import javafx.scene.control.cell.PropertyValueFactory;
    import javafx.scene.layout.HBox;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    
    public class MyDemo extends Application {
    
        private TableView<Person> tableview = new TableView<Person>();
    
        // Suppose your preferred height values for those 2 component are as follows:
        private double TABLE_MIN_HEIGHT = 30.0;
        private double TABLE_MAX_HEIGHT = 500.0;
        private double TITLED_PANE_HEIGHT; // will be determined
    
        private final ObservableList<Person> data =
                FXCollections.observableArrayList(
                new Person("Jacob", "Smith", "jacob.smith@example.com"),
                new Person("Isabella", "Johnson", "isabella.johnson@example.com"),
                new Person("Ethan", "Williams", "ethan.williams@example.com"),
                new Person("Emma", "Jones", "emma.jones@example.com"),
                new Person("Michael", "Brown", "michael.brown@example.com"));
    
        public static void main(String[] args) {
            Application.launch(args);
        }
    
        @Override
        public void start(Stage stage) {
            TableColumn firstNameCol = new TableColumn("First Name");
            firstNameCol.setMinWidth(100);
            firstNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("firstName"));
    
            TableColumn lastNameCol = new TableColumn("Last Name");
            lastNameCol.setMinWidth(100);
            lastNameCol.setCellValueFactory(new PropertyValueFactory<Person, String>("lastName"));
    
            TableColumn emailCol = new TableColumn("Email");
            emailCol.setMinWidth(200);
            emailCol.setCellValueFactory(new PropertyValueFactory<Person, String>("email"));
    
            tableview.setItems(data);
            tableview.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
    
            final TitledPane titledPane = new TitledPane("TitledPane", new Text("Content\n\n\n\n"));
            titledPane.setAnimated(false); // we need to temporarily disable
            // animation to get the titledpanes computed height correctly.
    
            // Force to min height of table view
            tableview.setMaxHeight(TABLE_MIN_HEIGHT);
            tableview.setMinHeight(TABLE_MIN_HEIGHT);
    
            // Here you have 2 options
            int option = 2;
    
            if (option == 1) {
                // 1st simply force the table view height to its preferred max value
                // when the titled pane's expanded property changed:
                titledPane.expandedProperty().addListener(new ChangeListener<Boolean>() {
                    @Override
                    public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
                        tableview.setMaxHeight(newValue ? TABLE_MIN_HEIGHT : TABLE_MAX_HEIGHT);
                        tableview.setMinHeight(newValue ? TABLE_MIN_HEIGHT : TABLE_MAX_HEIGHT);
                    }
                });
            } else if (option == 2) {
                // 2nd. Similar to first but with "animation". Here observe height changes of titled pane:
                titledPane.heightProperty().addListener(new ChangeListener<Number>() {
                    @Override
                    public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                        tableview.setMaxHeight(TABLE_MAX_HEIGHT - (TABLE_MAX_HEIGHT * (newValue.doubleValue() / TITLED_PANE_HEIGHT)));
                        tableview.setMinHeight(TABLE_MAX_HEIGHT - (TABLE_MAX_HEIGHT * (newValue.doubleValue() / TITLED_PANE_HEIGHT)));
                    }
                });
            }
    
            HBox hBox = new HBox(10);
            hBox.getChildren().addAll(tableview, titledPane);
    
            Scene scene = new Scene(hBox);
            stage.setTitle("Table View Sample");
            stage.setWidth(650);
            stage.setHeight(700);
            stage.setScene(scene);
    
            TITLED_PANE_HEIGHT = titledPane.getHeight();
            System.out.println("TITLED_PANE_HEIGHT = " + TITLED_PANE_HEIGHT);
    
            stage.show();
    
            // Determine the titledPane computed height value after stage has been shown.
            TITLED_PANE_HEIGHT = titledPane.getHeight();
            System.out.println("TITLED_PANE_HEIGHT = " + TITLED_PANE_HEIGHT);
            // .. then enable animation
            titledPane.setAnimated(true);
        }
    
        public static class Person {
    
            private final SimpleStringProperty firstName;
            private final SimpleStringProperty lastName;
            private final SimpleStringProperty email;
    
            private Person(String fName, String lName, String email) {
                this.firstName = new SimpleStringProperty(fName);
                this.lastName = new SimpleStringProperty(lName);
                this.email = new SimpleStringProperty(email);
            }
    
            public String getFirstName() {
                return firstName.get();
            }
    
            public void setFirstName(String fName) {
                firstName.set(fName);
            }
    
            public String getLastName() {
                return lastName.get();
            }
    
            public void setLastName(String fName) {
                lastName.set(fName);
            }
    
            public String getEmail() {
                return email.get();
            }
    
            public void setEmail(String fName) {
                email.set(fName);
            }
        }
    }
    

    It is demo, improve it according to your needs. There maybe other approaches as well. HTH.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two distinct modules that can be used independently, but Module2 is dependent
A problem I'm trying to solve: given that you have two distinct strings composed
Suppose I have two distinct databases with identical schemas but different data. I want
I have two tables: Table 1 has Episode and Code, with Episode as distinct.
We have two distinct agile teams, each working on separate, but related, applications. Each
I have two distinct (no inheritance) interfaces: IInvestable and IPricable and two classes: IndexClass
I have two distinct scenarios. One, where there is a many to many case,
I have a clojure/ring project that has two distinct app/handlers running on different ports
I have this little problem. My client wanted two distinct swf on a web
I have these two queries to test my output SELECT DISTINCT( providerId ), SUM((

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.