When I put components like a ToolBar or a ListView inside a JFXPanel and lock Windows, those components are not properly displayed after unlocking. Only those elements which were selected or had focus are shown. The other parts are simply not displayed. They reappear bit by bit when I move the mouse to the position where they should be.
I observed the same behavior when pressing Ctrl+Alt+Del and Cancel afterwards.
I could reproduce the same issue on another computer running Windows 7 so it might not be limited to my computer.
By the way, this issue does not occur with Java 1.7.0_51.
The following code can be used to reproduce the issue. Except for the button "Hello", all other JavaFx components vanish when I start the application and lock/unlock Windows directly afterwards.
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;
import java.util.List;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initAndShowGui();
}
});
}
private static void initAndShowGui() {
final JFXPanel jfxPanel = new JFXPanel();
Platform.runLater(new Runnable() {
@Override
public void run() {
ToolBar toolBar = new ToolBar();
toolBar.setStyle("-fx-background-color: cyan");
toolBar.getItems().add(new Button("Hello"));
toolBar.getItems().add(new Button("World"));
ListView<Integer> listView = new ListView<>();
List<Integer> integers = new LinkedList<>();
for (int i = 0; i < 20; i++) {
integers.add(i);
}
listView.getItems().setAll(integers);
BorderPane borderPane = new BorderPane();
borderPane.setTop(toolBar);
borderPane.setBottom(listView);
jfxPanel.setScene(new Scene(borderPane));
}
});
JPanel contentPane = new JPanel();
contentPane.add(jfxPanel);
contentPane.setBackground(Color.BLUE);
JFrame jFrame = new JFrame();
jFrame.setContentPane(contentPane);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.pack();
jFrame.setSize(300, 500);
jFrame.setVisible(true);
}
}
I observed the same behavior when pressing Ctrl+Alt+Del and Cancel afterwards.
I could reproduce the same issue on another computer running Windows 7 so it might not be limited to my computer.
By the way, this issue does not occur with Java 1.7.0_51.
The following code can be used to reproduce the issue. Except for the button "Hello", all other JavaFx components vanish when I start the application and lock/unlock Windows directly afterwards.
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.ToolBar;
import javafx.scene.layout.BorderPane;
import javax.swing.*;
import java.awt.*;
import java.util.LinkedList;
import java.util.List;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initAndShowGui();
}
});
}
private static void initAndShowGui() {
final JFXPanel jfxPanel = new JFXPanel();
Platform.runLater(new Runnable() {
@Override
public void run() {
ToolBar toolBar = new ToolBar();
toolBar.setStyle("-fx-background-color: cyan");
toolBar.getItems().add(new Button("Hello"));
toolBar.getItems().add(new Button("World"));
ListView<Integer> listView = new ListView<>();
List<Integer> integers = new LinkedList<>();
for (int i = 0; i < 20; i++) {
integers.add(i);
}
listView.getItems().setAll(integers);
BorderPane borderPane = new BorderPane();
borderPane.setTop(toolBar);
borderPane.setBottom(listView);
jfxPanel.setScene(new Scene(borderPane));
}
});
JPanel contentPane = new JPanel();
contentPane.add(jfxPanel);
contentPane.setBackground(Color.BLUE);
JFrame jFrame = new JFrame();
jFrame.setContentPane(contentPane);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.pack();
jFrame.setSize(300, 500);
jFrame.setVisible(true);
}
}