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

  • Home
  • SEARCH
  • 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 7702875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:19:42+00:00 2026-05-31T23:19:42+00:00

I have three problems: I want to create resizable shapes with box bounding… I

  • 0

I have three problems:

  1. I want to create resizable shapes with box bounding…
  2. I also want to know how to get child seleted in a Pane.
  3. I’m creating multiple shapes on a pane. I want to change some property of that shape say Fill.. How do i do it??

Thanx

  • 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-05-31T23:19:43+00:00Added an answer on May 31, 2026 at 11:19 pm

    Next example will answer your questions:

    • for (1) it uses binding, connecting pane size with rectangle size
    • for (2) it adds setOnMouseClick for each rectangle which stores clicked one in the lastOne field.
    • for (3) see code of setOnMouseClick() handler

      public class RectangleGrid extends Application {
      
        private Rectangle lastOne;
      
        public void start(Stage stage) throws Exception {
          Pane root = new Pane();
      
          int grid_x = 7; //number of rows
          int grid_y = 7; //number of columns
      
          // this binding will find out which parameter is smaller: height or width
          NumberBinding rectsAreaSize = Bindings.min(root.heightProperty(), root.widthProperty());
      
          for (int x = 0; x < grid_x; x++) {
              for (int y = 0; y < grid_y; y++) {
                  Rectangle rectangle = new Rectangle();
                  rectangle.setStroke(Color.WHITE);
      
                  rectangle.setOnMouseClicked(new EventHandler<MouseEvent>() {
                      @Override
                      public void handle(MouseEvent t) {
                          if (lastOne != null) {
                              lastOne.setFill(Color.BLACK);
                          }
                          // remembering clicks
                          lastOne = (Rectangle) t.getSource();
                          // updating fill
                          lastOne.setFill(Color.RED);
                      }
                  });
      
                  // here we position rects (this depends on pane size as well)
                  rectangle.xProperty().bind(rectsAreaSize.multiply(x).divide(grid_x));
                  rectangle.yProperty().bind(rectsAreaSize.multiply(y).divide(grid_y));
      
                  // here we bind rectangle size to pane size 
                  rectangle.heightProperty().bind(rectsAreaSize.divide(grid_x));
                  rectangle.widthProperty().bind(rectangle.heightProperty());
      
                  root.getChildren().add(rectangle);
              }
          }
      
          stage.setScene(new Scene(root, 500, 500));
          stage.show();
        }
      
        public static void main(String[] args) { launch(); }
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a few problems with my mod_rewrite rules. There a three different url
I don't know where to look for about this problem ... I have three
I have some strange problem with table in Firefox. What I want to create
I want to create multiple children using fork() , but I am facing problems.
Lets say that I have a drop down list that I want to create
I have three tables being used for this problem: songs, blacklist, and whitelist. The
Well here's my problem I have three tables; regions, countries, states. Countries can be
I have the following problem. I have three classes, A, B and C. A
I have a MySQL Left Join problem. I have three tables which I'm trying
Here's a tricky iPhone problem I've been working on. I have three UIScrollViews on

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.