0

我测试了这个代码,它在双击选项卡时调整选项卡窗格的大小。

tabPane.setOnMouseClicked(new EventHandler<MouseEvent>()
        {
            private double sizeX, sizeY;
            private boolean first = true;

            @Override
            public void handle(MouseEvent me) 
            {
                if (first)
                {
                    sizeX = mainPane.getWidth();
                    sizeY = mainPane.getHeight();
                    first = false;
                }

                if (me.getButton().equals(MouseButton.PRIMARY) && me.getClickCount() % 2 == 0)
                {
                    if (sizeX != mainPane.getWidth() || sizeY != mainPane.getHeight())
                    {
                        mainPane.setPrefSize(sizeX, sizeY);

                    }
                    else
                    {
                        mainPane.setPrefSize(primaryScreenBounds.getWidth(), primaryScreenBounds.getHeight());
                    }
                }
            }
        });

当我双击时,我想覆盖主舞台上的所有其他组件。我怎么能做到这一点?

4

0 回答 0