I had created simple app using NetBeans
wizard but it was flashing while creating alert
I recreated it but same thing happen.
When I click on
button
it does flash rectangular region at top left corner of the screen and then loadAlert
.
Here is code :
public class MyAlert extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
Scene scene = new Scene(root);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
FXML.fxml:
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="myalert.FXMLDocumentController">
<children>
<Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
</children>
</AnchorPane>
ControllerClass:
public class FXMLDocumentController implements Initializable {
@FXML
private void handleButtonAction(ActionEvent event) {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Message");
alert.setHeaderText("Error Message");
alert.show();
}
I'm using JDK 1.8.0 u131
With old processor
Processor: 2* Pentium@ Dual-Core CPU E5300 @ 2.60GH
Memory: 1.9 GiB of RAM
OS Kubuntu 18.04
Don't know if this is case.
I've checked on windows 7 if getting same behavior, but application run smoothly without flash as I've mentioned in my question.
I'm using Kubuntu 18.04
and Desktop Effects
are enabled and day ago Compositor
was failed and that was the reason of flashing screen when launching Frame
or Alert
dialog.
The Compositor can be found in the System Settings under Display and Monitor > Compositor.
I re-enabled and problem is solved.
This question is helpful only for
KDE Plasma Desktop
users.