2013-12-18 2 views
1

팝업 메시지를 표시하려면 javafx.stage.Popup을 확장해야합니다. 전체 응용 프로그램은 Windows 및 Ubuntu에서 잘 작동하지만 Mac Popups에서는 응용 프로그램이 전체 화면 일 때 현재 단계가 진행됩니다. Z- 인덱스, .toFront(), 소유자 윈도우 및 모든 설정을 사용하여 시도했다. 그러나 팝업은 결코 나타나지 않습니다! 같은 문제는 javafx.stage.FileChooser입니다. 앱이 항상 전체 화면이어야하므로 솔루션은 무엇입니까?팝업은 Mac에서만 실행되지만 전체 화면에서는 Windows/Linux에서는 실행되지 않습니다.

편집 : 다른 페이지에서 텍스트 필드는 커서가 전체 화면에서 깜박이지만 입력 된 키는받지 못합니다! 그리고 이것은 전체 화면에서 만 발생합니다! 전체 화면을 잃게되면 텍스트 입력란에 입력 된 키가 표시됩니다. 내가 버그 또는 뭔가

를 제출해야하는 경우 제안 해주십시오 :(꽤 성가신 나는 팝업에 대한 해결 방법을 알아 냈어요하지만 문제는 DirectoryChooser/FileChooser 지속

이것은 팝업 확장하는 클래스이다.

public class PopupDisplay extends Popup 
{ 
String Title=new String("Information"); 
String Prompt=new String("Prompt Text"); 
@FXML 
private AnchorPane anchorMain; 
@FXML 
private Label lblTitle=new Label(); 
@FXML 
private Font x1; 
@FXML 
private Label lblPrompt=new Label(); 
@FXML 
private Button btnOk; 
@FXML 
private GridPane gridMain; 
@FXML 
private HBox hboxTitle; 
static PopupDisplay instance; 
private ColorDxDesktop application; 
public void show(Stage stage, String titleKey,String promptKey, Locale enLocale) 
{ 
    AnchorPane root; 
    FXMLLoader loader=new FXMLLoader(); 
    ResourceBundle rb; 

    Prompt=promptKey; 
    Title=titleKey; 
    try 
    { 
     loader.setLocation(getClass().getResource("/com/sc/colordx/resources/")); 
     rb=ResourceBundle.getBundle("com.sc.colordx.resources.lang.Popup",application.getLocale()); 

     loader.setResources(rb); 
     PopupController.prompt=Prompt; 
     PopupController.title=Title; 

     root = (AnchorPane)loader.load(getClass().getResource("/com/sc/colordx/presentation/Popup.fxml").openStream()); 
     getScene().setRoot(root); 
     PopupController popupController=loader.getController(); 



     Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds(); 
     root.setPrefWidth(application.getStage().getWidth()); 
     root.setPrefHeight(application.getStage().getHeight()); 
     Node n=root.getChildren().get(0); 
     n.setLayoutX(screenBounds.getWidth()/2.5); 
     n.setLayoutY((screenBounds.getHeight()/2.5)); 
     //root.toFront(); 

     show(stage); 


    } 
    catch (IOException ex) 
    { 
     ex.printStackTrace(); 
    } 
} 


public static PopupDisplay getInstance() 
{ 
    return instance; 
} 
@FXML 
private void hide(MouseEvent event) 
{ 
    this.hide(); 
} 
public void showInProgress() 
{ 
    PopupController.showInProgress(); 


} 

그리고 이것은 팝업에 대한 FXML입니다 :

<?xml version="1.0" encoding="UTF-8"?> 

<?import java.lang.*?> 
<?import java.net.*?> 
<?import java.util.*?> 
<?import javafx.geometry.*?> 
<?import javafx.scene.*?> 
<?import javafx.scene.control.*?> 
<?import javafx.scene.layout.*?> 
<?import javafx.scene.text.*?> 

<AnchorPane id="AnchorPane" fx:id="anchorMain" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="-Infinity" minWidth="-Infinity" prefHeight="768.0" prefWidth="1024.0" styleClass="mainFxmlClass" xmlns:fx="http://javafx.com/fxml/1" xmlns="http://javafx.com/javafx/2.2" fx:controller="com.sc.colordx.controller.PopupController"> 
    <children> 
    <GridPane id="GridPane" fx:id="gridMain" alignment="CENTER" layoutX="309.0" layoutY="330.0" minWidth="400.0" style="-fx-background-color:black;" styleClass="visibleWindow, gridpane, gridpane-boder" vgap="20.0"> 
     <children> 
     <Label fx:id="lblPrompt" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="271.0" text="%keyPrompt" textFill="WHITE" textOverrun="CLIP" wrapText="true" GridPane.columnIndex="0" GridPane.halignment="CENTER" GridPane.rowIndex="1" GridPane.valignment="CENTER"> 
      <font> 
      <Font name="System Bold" size="14.0" fx:id="x1" /> 
      </font> 
      <GridPane.margin> 
      <Insets bottom="6.0" left="6.0" right="6.0" top="6.0" /> 
      </GridPane.margin> 
     </Label> 
     <HBox id="HBox" fx:id="hboxButtons" alignment="CENTER" spacing="7.0" style="" styleClass="hbox" GridPane.columnIndex="0" GridPane.hgrow="ALWAYS" GridPane.rowIndex="2" GridPane.vgrow="ALWAYS"> 
      <children> 
      <Button fx:id="btnOk" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onMouseClicked="#exitOkay" text="%keyYes" HBox.hgrow="ALWAYS" /> 
      <Button id="btnOk" fx:id="btnCancel" maxWidth="1.7976931348623157E308" mnemonicParsing="false" onMouseClicked="#hide" text="%keyNo" HBox.hgrow="ALWAYS" /> 
      </children> 
      <padding> 
      <Insets bottom="5.0" left="5.0" right="5.0" top="5.0" /> 
      </padding> 
      <stylesheets> 
      <URL value="@../resources/css/Popup.css" /> 
      </stylesheets> 
     </HBox> 
     <ProgressIndicator fx:id="progress" cache="true" cacheHint="QUALITY" progress="0.0" visible="false" GridPane.columnIndex="0" GridPane.rowIndex="1"> 
      <GridPane.margin> 
      <Insets left="300.0" /> 
      </GridPane.margin> 
     </ProgressIndicator> 
     </children> 
     <columnConstraints> 
     <ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" /> 
     </columnConstraints> 
     <padding> 
     <Insets /> 
     </padding> 
     <rowConstraints> 
     <RowConstraints minHeight="10.0" vgrow="SOMETIMES" /> 
     <RowConstraints minHeight="10.0" vgrow="SOMETIMES" /> 
     <RowConstraints minHeight="10.0" vgrow="SOMETIMES" /> 
     </rowConstraints> 
     </GridPane> 
     </children> 
     <stylesheets> 
     <URL value="@../resources/css/Popup.css" /> 
     </stylesheets> 
</AnchorPane> 

답변

1

내가 한 그래서 MAC에서 자바 FX 응용 프로그램을 실행하는 동안이 팝업으로 얻고 있었다 같은 일 initStyle(StageStyle.UTILITY);으로 새 스테이지 (높이/너비 = 0 인 더미/보이지 않음)가 만들어지고 내 팝업이 바인딩됩니다. 팝업을 표시 할 때마다 dummyStage.show();popup.toFront();을 사용하므로 Mac에서 문제를 처리하는 트릭이 나옵니다.

+0

예 해결 방법을 알고 있습니다. 예를 들어. stackpane을 사용하고 현재 스테이지 루트 및 팝업 화면 루트를 추가하여 팝업을 표시합니다. 하지만 FileChooser로 해결 방법을 적용 할 수 없으므로 Popup 자체를 사용하여 적절한 솔루션이 필요합니다. –

관련 문제