0

I am using the latest version of ControlsFX for JavaFX, and I am encountering a very strange bug.. and I'm hoping someone has found out a "fix" for it.

I've not created a simple test case for this, but if I create a custom Dialog, add a GridPane on it, add a SegmentedButton to the GridPane, the whole Dialog loses it's borders!

This occurs only on the first time I open the dialog. If I re-create the Dialog everything works just fine*

I'd really hate to dump the SegmentedButton due to a glitch like this.. has anyone else encountered this issue?

EDIT, here's a simple test that should demonstrate the bug. The effect is even worse now, in this test. It seems to be some sort of a clipping bug.

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ToggleButton;
import javafx.stage.Stage;
import org.controlsfx.control.SegmentedButton;
import org.controlsfx.dialog.Dialog;

public class DialogTest extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        Group root = new Group();
        Scene scene = new Scene(root);
        primaryStage.setScene(scene);

        primaryStage.show();

        Dialog dlg = new Dialog(primaryStage, "Test Dialog");
        dlg.setMasthead("Dialog test");
        dlg.setIconifiable(false);
        dlg.setResizable(false);

        SegmentedButton seg = new SegmentedButton();
        seg.getButtons().add(new ToggleButton("Button 1"));
        seg.getButtons().add(new ToggleButton("Button 2"));
        seg.getButtons().add(new ToggleButton("Button 3"));
        seg.getButtons().add(new ToggleButton("Button 4"));
        seg.getButtons().add(new ToggleButton("Button 5"));

        dlg.setContent(seg);

        dlg.show();
    }
}
user2499946
  • 679
  • 1
  • 10
  • 28
  • Can you create a simple [test/MCVE](http://stackoverflow.com/help/mcve) for this and post it here ? – ItachiUchiha Sep 08 '14 at 08:02
  • The Dialogs of ControlsFX are now part of JavaFX officially. So can you download the latest version of JavafX (8u40 which supports Dialogs) here : https://jdk8.java.net/download.html and verify that your bug still exists? – Maxoudela Sep 08 '14 at 10:10
  • I added a simple test, and I'll try the 8u40 later. – user2499946 Sep 08 '14 at 11:33
  • Well... I just tried the 8u40 and the bug seems to be gone. However, the dialogs now have ugly native borders (a Dialog is just a Stage that has a DialogPane), and the javadoc states that they _may_ offer lightweight dialogs in the future. The API is also quite different.. I'm back to ControlsFX without a second thought. – user2499946 Sep 08 '14 at 17:06

1 Answers1

1

After some experimentation, I've fixed the issue simply by calling dialog.getWindow().sizeToScene() before showing the dialog.

user2499946
  • 679
  • 1
  • 10
  • 28