Tengo un problema companeros, decidi colocarle un stage.initStyle(StageStyle.UNDECORATED);
porque queria un MenuBar personalizado pero resulta que ahora que le intento colocar algunas propiedades que tiene el MenuBar por defecto, al colocar el codigo refente al ON MOUSE DRAGGED y al ON MOUSE PRESSED para poder mover la ventana dando click al MenuBar, resulta que ahora la ventana comienza a temblar desde que mantengo el MenuBar presionado.
les dejo un video de ejemplo:
y esas son imagenes para ver si pueden ver el error:
Este es parte del codigo relacionado al al DRAGGING que esta en la seccion del controladores en JavaFX:
// DRAGGED WINDOW METHOD
@FXML private void dragWindowAction(MouseEvent event){
x = event.getSceneX();
y = event.getSceneY();
}
@FXML private void dragWindow(MouseEvent event){
Stage stage = (Stage) drag_window.getScene().getWindow();
stage.setX(event.getSceneX() - x);
stage.setY(event.getScreenY() - y);
}
Aqui la parte del MenuBar de FXML:
<AnchorPane fx:id="drag_window" onMouseDragged="#dragWindow" onMousePressed="#dragWindowAction" style="-fx-background-color: #0C2D48;" BorderPane.alignment="CENTER">
<Label fx:id="close_button" accessibleRole="BUTTON" alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" onMouseClicked="#closeButtonAction" prefHeight="40.0" prefWidth="50.0" style="-fx-background-color: cc0000;" AnchorPane.rightAnchor="0.0">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<Image url="@../../../icon/close.png" />
</ImageView>
</graphic>
</Label>
<Label fx:id="minimize_button" alignment="BOTTOM_CENTER" contentDisplay="CENTER" maxHeight="1.7976931348623157E308" onMouseClicked="#minimizeButtonAction" prefHeight="40.0" prefWidth="50.0" AnchorPane.rightAnchor="50.0">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<Image url="@../../../icon/minus-sign.png" />
</ImageView>
</graphic>
</Label>
<Label fx:id="fullscreen_button" alignment="CENTER" maxHeight="1.7976931348623157E308" onKeyPressed="#fullscreenButtonAction" onMouseClicked="#fullscreenButtonAction" prefHeight="40.0" prefWidth="150.0" style="-fx-background-color: #000000;" text="Full Screen Mode" textFill="WHITE" AnchorPane.rightAnchor="100.0">
<graphic>
<ImageView fitHeight="15.0" fitWidth="15.0" pickOnBounds="true" preserveRatio="true">
<Image url="@../../../icon/fullscreen.png" />
</ImageView>
</graphic>
<font>
<Font name="Segoe UI" size="12.0" />
</font>
</Label>
<Label layoutX="52.0" layoutY="5.0" text="Cash System Pro 2022." textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI Bold" size="14.0" />
</font>
<padding>
<Insets left="10.0" />
</padding>
</Label>
<Label layoutX="185.0" text="Ventana principal" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="185.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="510.0" text="Reportes" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="510.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="306.0" text="Historial de ventas" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="306.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="581.0" text="Gonfiguraciones" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="581.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="432.0" text="Inventario" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="432.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="1043.0" prefHeight="40.0" prefWidth="50.0" text="Internet:" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="1043.0" AnchorPane.rightAnchor="407.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="872.6" prefWidth="126.3" text="Successful connection" textFill="#3cff7d" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="872.6" AnchorPane.rightAnchor="501.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="821.0" prefHeight="40.0" prefWidth="40.0" text="Server:" textFill="WHITE" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="821.0" AnchorPane.rightAnchor="639.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
<Label layoutX="1102.4" prefWidth="130.0" text="Good / no fluctuations" textFill="#3cff7d" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="1102.4" AnchorPane.rightAnchor="268.0" AnchorPane.topAnchor="0.0">
<font>
<Font name="Segoe UI" size="13.0" />
</font>
</Label>
</AnchorPane>
dragWindow()
stage.setX(event.getSceneX() - x);
debe serstage.setX(event.getScreenX() - x);