2016-07-23 6 views
0

私はEclipseを使用してシーンビルダを使用してGUIを構築しました。JavaFX fxmlが起動していない/何もしていない

EclipseでMainAppクラスを実行してGUIを表示しようとしていますが、すべてがコンパイルされ、コンソールにエラーメッセージが表示されず、javaプロセスが開きますが、実際に何も起こりません。

私はoracleのサイトを通過し、コードを変更しようとしましたが、何も機能しません。私はJavaを更新し、Eclipseにjavafxなどを再インストールしました。私はまた、同じ効果をnetbeansプログラムを試してみました。

私は、単純な何かが欠けていた場合のMacOS X

package main; 

import java.util.logging.Level; 
import java.util.logging.Logger; 
import javafx.application.Application; 
import javafx.fxml.FXMLLoader; 
import javafx.scene.Parent; 
import javafx.scene.Scene; 
import javafx.scene.layout.StackPane; 
import javafx.stage.Stage; 

public class MainApp extends Application { 

/** 
* @param args the command line arguments 
*/ 
public static void main(String[] args) { 
    Application.launch(MainApp.class, (java.lang.String[])null); 
} 

@Override 
public void start(Stage primaryStage) { 
    try { 
     Parent root = FXMLLoader.load(getClass().getResource("GUI.fxml")); 

     Scene scene = new Scene(root); 

     primaryStage.setScene(scene); 
     primaryStage.show(); 
    } catch (Exception ex) { 
     Logger.getLogger(MainApp.class.getName()).log(Level.SEVERE, null, ex); 
    } 
} 
`package main; 

上のコントローラクラス

public class Controller implements Initializable { 

@FXML 
Button checkButton; 
@FXML 
Button callButton; 
@FXML 
Button raiseButton; 
@FXML 
Button foldButton; 


public void buttonClicked() { 
    System.out.println("Button was clicked"); 
} 

@Override 
public void initialize(URL location, ResourceBundle resources) { 
    // TODO Auto-generated method stub 

} 
} 
} 

FXMLファイル

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


<?import javafx.scene.chart.CategoryAxis?> 
<?import javafx.scene.chart.LineChart?> 
<?import javafx.scene.chart.NumberAxis?> 
<?import javafx.scene.control.Button?> 
<?import javafx.scene.control.ButtonBar?> 
<?import javafx.scene.control.Label?> 
<?import javafx.scene.control.SplitPane?> 
<?import javafx.scene.control.TextArea?> 
<?import javafx.scene.image.Image?> 
<?import javafx.scene.image.ImageView?> 
<?import javafx.scene.layout.AnchorPane?> 

<AnchorPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="500.0" prefWidth="800.0" style="-fx-background-color: #FFFFFF;" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.Controller"> 
    <children> 
     <SplitPane dividerPositions="0.29949874686716793" layoutX="123.0" layoutY="67.0" prefHeight="433.0" prefWidth="800.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="67.0"> 
     <items> 
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> 
       <children> 
        <LineChart layoutY="206.0" prefHeight="215.0" prefWidth="235.0"> 
        <xAxis> 
         <CategoryAxis side="BOTTOM" /> 
        </xAxis> 
        <yAxis> 
         <NumberAxis side="LEFT" /> 
        </yAxis> 
        </LineChart> 
        <LineChart prefHeight="215.0" prefWidth="235.0"> 
        <xAxis> 
         <CategoryAxis side="BOTTOM" /> 
        </xAxis> 
        <yAxis> 
         <NumberAxis side="LEFT" /> 
        </yAxis> 
        </LineChart> 
       </children> 
      </AnchorPane> 
      <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> 
       <children> 
        <SplitPane dividerPositions="0.6783216783216783" orientation="VERTICAL" prefHeight="498.0" prefWidth="555.0" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0"> 
        <items> 
         <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="100.0" prefWidth="160.0" /> 
         <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="127.0" prefWidth="553.0"> 
          <children> 
           <TextArea disable="true" layoutX="9.0" layoutY="23.0" prefHeight="106.0" prefWidth="536.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="9.0" AnchorPane.rightAnchor="8.0" AnchorPane.topAnchor="23.0" /> 
           <Label layoutX="14.0" layoutY="6.0" text="Live guidance:" /> 
          </children> 
         </AnchorPane> 
        </items> 
        </SplitPane> 
       </children> 
      </AnchorPane> 
     </items> 
     </SplitPane> 
     <ImageView fitHeight="62.0" fitWidth="200.0" layoutX="14.0" layoutY="5.0"> 
     <image> 
      <Image url="@../../../../../Desktop/Dissertation%20files/logo.jpg" /> 
     </image> 
     </ImageView> 
     <ButtonBar layoutX="456.0" layoutY="16.0" prefHeight="40.0" prefWidth="200.0"> 
     <buttons> 
      <Button fx:id="checkButton" mnemonicParsing="false" onAction="#buttonClicked" onMouseClicked="#buttonClicked" style="-fx-background-radius: 10;" text="Check" /> 
      <Button fx:id="callButon" mnemonicParsing="false" onAction="#buttonClicked" onMouseClicked="#buttonClicked" style="-fx-background-radius: 10;" text="Call" /> 
      <Button fx:id="raiseButton" mnemonicParsing="false" onAction="#buttonClicked" onMouseClicked="#buttonClicked" prefHeight="27.0" prefWidth="81.0" style="-fx-background-radius: 10;" text="Raise" /> 
      <Button fx:id="foldButton" mnemonicParsing="false" onAction="#buttonClicked" onMouseClicked="#buttonClicked" style="-fx-background-radius: 10;" text="Fold" /> 
     </buttons> 
     </ButtonBar> 
    </children> 
</AnchorPane> 

謝罪を実行します。

+0

「パッケージ名」の代わりにあなたの元のパッケージ名を入れて。 (私は 'MainApp'に' ''がないと仮定し、 'Controller'の余分なものは単純にコピー&ペーストのエラーです) –

+0

あなたのGUI.fxmlファイルはどこにありますか?フォルダやパッケージ内、またはdirのルートにありますか? – NwDev

+0

@ James_Dはい謝罪、初めて本当にstackoverflowを使用して私の悪い。 – OliverJohnson

答えて

0

クラスとFXMLファイルが同じパッケージの下にある場合は、ローダラインは、この

Parent root = FXMLLoader.load(getClass().getResource("/package_name/fxml2GUI.fxml")); 

ようにする必要がありますそれは私のために正常に動作

関連する問題