-
Bug
-
Resolution: Fixed
-
P4
-
None
-
fx2.0
-
JavaFX 2.0 beta b28 + JDK 1.6.0_25 + WinXP SP3
(JavaFX 2.0 beta b28 + JDK 1.6.0_25 + WinXP SP3)
Node.toFront() / toBack() does not automatically move a node to front or to back - need to manually do
a *real refresh*, for example, to resize the application window a little(just moving the application window
around will not work)
Below is a piece of codes for re-producing
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
/**
*
* @author lianqi.li
*/
public class ToFrontToBackIssue extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(ToFrontToBackIssue.class, args);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 300, 300);
stage.setTitle("ToFront-ToBack Test");
final Rectangle rect1 = new Rectangle(10, 10, 100, 100);
rect1.setFill(Color.RED);
final Rectangle rect2 = new Rectangle(40, 40, 100, 100);
rect2.setFill(Color.BLUE);
final Button bToFront = new Button("To Front");
bToFront.setLayoutX(60);
bToFront.setLayoutY(250);
bToFront.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rect1.toFront();
}
});
final Button bToBack = new Button("To Back");
bToBack.setLayoutX(160);
bToBack.setLayoutY(250);
bToBack.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rect1.toBack();
}
});
root.getChildren().addAll(rect1, rect2, bToFront, bToBack);
stage.setScene(scene);
stage.setVisible(true);
}
}
Node.toFront() / toBack() does not automatically move a node to front or to back - need to manually do
a *real refresh*, for example, to resize the application window a little(just moving the application window
around will not work)
Below is a piece of codes for re-producing
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
/**
*
* @author lianqi.li
*/
public class ToFrontToBackIssue extends Application {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(ToFrontToBackIssue.class, args);
}
@Override
public void start(Stage stage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root, 300, 300);
stage.setTitle("ToFront-ToBack Test");
final Rectangle rect1 = new Rectangle(10, 10, 100, 100);
rect1.setFill(Color.RED);
final Rectangle rect2 = new Rectangle(40, 40, 100, 100);
rect2.setFill(Color.BLUE);
final Button bToFront = new Button("To Front");
bToFront.setLayoutX(60);
bToFront.setLayoutY(250);
bToFront.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rect1.toFront();
}
});
final Button bToBack = new Button("To Back");
bToBack.setLayoutX(160);
bToBack.setLayoutY(250);
bToBack.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
rect1.toBack();
}
});
root.getChildren().addAll(rect1, rect2, bToFront, bToBack);
stage.setScene(scene);
stage.setVisible(true);
}
}