-
Bug
-
Resolution: Duplicate
-
P4
-
7u15, 7u25, 7u40, 8
-
None
-
Ubuntu 12.04 LTS 32 bit {
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)
&&
Java(TM) SE Runtime Environment (build 1.8.0-ea-b108)
Java HotSpot(TM) Server VM (build 25.0-b50, mixed mode)
}
Ubuntu 13.04 64bit 7u40
Mac OS X 10.8 x64 7u25
Windows 7 x64 7u40, 7u7
Windows 8 x64 7u40Ubuntu 12.04 LTS 32 bit { Java(TM) SE Runtime Environment (build 1.7.0_40-b43) Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode) && Java(TM) SE Runtime Environment (build 1.8.0-ea-b108) Java HotSpot(TM) Server VM (build 25.0-b50, mixed mode) } Ubuntu 13.04 64bit 7u40 Mac OS X 10.8 x64 7u25 Windows 7 x64 7u40, 7u7 Windows 8 x64 7u40
The code below is supposed to show a pink anchor pane for 1 second after onShow, then switch to a green anchor pane. If you run it as it, it switches from pink to white. depending on hierarchy (like adding a scrollPane: Scene > BorderPane > center >ScrollPane >content> ap), clicking can cause it to turn green. If you comment the first select, it works fine. Calling requestLayout and layout() does not work. Nor does resizing the window or updating controls inside the pink/green anchor panes (if there are some inside). What does work is running the onShow code in the start() method or commenting out the first select. Original program also exibited this bug when opening files, which was all in a button onclick handler and selected several items before selecting the first.
```java
package javafxbugtest;
import javafx.application.*;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.stage.*;
public class JavaFXBugTest extends Application{
private AnchorPane ap;
private AnchorPane curr_child;
public void start(final Stage stage){
stage.setTitle("Strange Happenings");
ap = new AnchorPane();
ap.setPrefSize(1024,600);
stage.setScene(new Scene(ap));
stage.setOnShown(new EventHandler<WindowEvent>(){
public void handle(WindowEvent we){
final AnchorPane greenap = newAp("green");
select(greenap); // comment this out and it works
select(newAp("pink"));
Thread t = new Thread(new Runnable(){
public void run(){
try{
Thread.sleep(1000);
}catch (InterruptedException ex){}
Platform.runLater(new Runnable(){
public void run(){select(greenap);}
});
}
});
t.start();
}
});
stage.show();
}
public AnchorPane newAp(String color){
AnchorPane ap = new AnchorPane();
ap.setStyle("-fx-background-color: " + color + ";");
ap.setMinSize(1000, 1000);
return ap;
}
public void select(AnchorPane child){
if (curr_child != null)
ap.getChildren().remove(curr_child);
ap.getChildren().add(child);
curr_child = child;
}
public static void main(String[] args){
launch(args);
}
}
```
```java
package javafxbugtest;
import javafx.application.*;
import javafx.event.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.stage.*;
public class JavaFXBugTest extends Application{
private AnchorPane ap;
private AnchorPane curr_child;
public void start(final Stage stage){
stage.setTitle("Strange Happenings");
ap = new AnchorPane();
ap.setPrefSize(1024,600);
stage.setScene(new Scene(ap));
stage.setOnShown(new EventHandler<WindowEvent>(){
public void handle(WindowEvent we){
final AnchorPane greenap = newAp("green");
select(greenap); // comment this out and it works
select(newAp("pink"));
Thread t = new Thread(new Runnable(){
public void run(){
try{
Thread.sleep(1000);
}catch (InterruptedException ex){}
Platform.runLater(new Runnable(){
public void run(){select(greenap);}
});
}
});
t.start();
}
});
stage.show();
}
public AnchorPane newAp(String color){
AnchorPane ap = new AnchorPane();
ap.setStyle("-fx-background-color: " + color + ";");
ap.setMinSize(1000, 1000);
return ap;
}
public void select(AnchorPane child){
if (curr_child != null)
ap.getChildren().remove(curr_child);
ap.getChildren().add(child);
curr_child = child;
}
public static void main(String[] args){
launch(args);
}
}
```
- duplicates
-
JDK-8123224 Display bug in Pane.getChildren().setAll()
-
- Closed
-