12 Replies - 6672 Views - Last Post: 03 March 2013 - 12:13 PM Rate Topic: -----

#1 Drive137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-February 11

JavaFX GUI problems

Posted 28 February 2013 - 03:24 PM

So, I am new to javaFx, and I am getting a whole lot of troubles from trying to run my project.

so I am just trying to get it to run right now. and It won't even do that and I am tired of sitting here getting nothing done and hurting my head. If some one could point out or explain to me what I am doing wrong on the set up on this I would be grateful.

Here is my StackTrace
Page language not specified.
/C:/Users/dspecht/Dropbox/csc150finale/bin/mainMenu.fxml:44
  at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:505)
  at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:589)
  at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2430)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2136)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at GameStartUp.start(GameStartUp.java:17)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)

LOADERS can not find the file
javafx.fxml.LoadException: Page language not specified.
	at javafx.fxml.FXMLLoader$Element.processEventHandlerAttributes(FXMLLoader.java:505)
	at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:589)
	at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2430)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2136)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
	at GameStartUp.start(GameStartUp.java:17)
	at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
	at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
	at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
	at java.lang.Thread.run(Unknown Source)



I have tried putting the jfxrt.jar into the build path and it has not worked. I have tried different methods of writing the start methods, and I have tried re installing e(fx)clispe.

Also I want to note I do not want to see just copy and paste code to help me, that is not going to help me or the small team this project is working on. This is just the GUI start of it, not the whole thing and I don't want the project done for me. I would just like some explanation of why this is not working at all.

Here is what I am working with code wise

import java.io.IOException;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class GameStartUp extends Application {

	@Override
	public void start(Stage primaryStage) {
		try { 
			
		// Main Menu set up 
			Parent rootMenu = (Parent) FXMLLoader.load(getClass().getResource("mainMenu.fxml"));
		
		Scene mainMenuScene = new Scene(rootMenu);
		primaryStage.setScene(mainMenuScene);
		primaryStage.setTitle("Menu");
		primaryStage.show();
		
		// Options Set up 
			Parent rootOptions = (Parent) FXMLLoader.load(getClass().getResource("Options.fxml"));
			
			Stage OptionsStage = new Stage();
			OptionsStage.setTitle("Options Menu");
			OptionsStage.initOwner(primaryStage);
			
		Scene optionsMenuScene = new Scene(rootOptions);
		
		
		} catch(IOException e) { 
			System.err.println("LOADERS can not find the file");
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		launch(args);
	}
}



Thank you for the time of reading this and possible a helpful response

Is This A Good Question/Topic? 0
  • +

Replies To: JavaFX GUI problems

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 03:28 PM

You need to show us your fxml file. Line 44 seems to be giving you the error.
Was This Post Helpful? 0
  • +
  • -

#3 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: JavaFX GUI problems

Posted 28 February 2013 - 03:37 PM

I suspect line 17 in the error message corresponds to line 16 in the code you posted and that the Options.fxml file is either not being found or it's loading with errors. I've never seen "Page language not specified" before, so I'm guessing it's a problem with the fxml file. Can you post that?
Was This Post Helpful? 0
  • +
  • -

#4 Drive137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-February 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:03 PM

Ok, I here is both FXML files for you

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

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.effect.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="265.0" prefWidth="180.00009999999747" xmlns:fx="http://javafx.com/fxml">
  <children>
    <Group id="Group">
      <children>
        <Pane prefHeight="14.0" prefWidth="180.0">
          <children>
            <MenuBar prefHeight="31.000199999994948" prefWidth="180.0">
              <menus>
                <Menu mnemonicParsing="false" text="File">
                  <items>
                    <MenuItem mnemonicParsing="false" text="New Game" />
                    <SeparatorMenuItem mnemonicParsing="false" />
                    <MenuItem mnemonicParsing="false" text="Options" />
                    <SeparatorMenuItem mnemonicParsing="false" />
                    <MenuItem mnemonicParsing="false" text="Close" />
                  </items>
                </Menu>
                <Menu mnemonicParsing="false" text="Help">
                  <items>
                    <MenuItem mnemonicParsing="false" text="Controls" />
                    <SeparatorMenuItem mnemonicParsing="false" />
                    <MenuItem mnemonicParsing="false" text="About" />
                  </items>
                </Menu>
              </menus>
            </MenuBar>
          </children>
        </Pane>
      </children>
    </Group>
    <Button layoutX="45.0" layoutY="78.0" mnemonicParsing="false" text="Leader Board" />
    <Button layoutX="45.0" layoutY="155.0" mnemonicParsing="false" text="Options" />
    <Button layoutX="45.0" layoutY="117.0" mnemonicParsing="false" text="Start Game" />
    <Button fx:id="Exit" layoutX="46.0" layoutY="194.0" mnemonicParsing="false" onAction="Platform.exit()" onMouseClicked="Platform.exit()" onMouseReleased="Platform.exit()" text="Exit" />
  </children>
  <effect>
    <DropShadow color="#646464" offsetX="5.0" offsetY="5.0" />
  </effect>
</AnchorPane>



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

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.collections.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.image.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.paint.*?>

<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="341.0" prefWidth="253.0" xmlns:fx="http://javafx.com/fxml">
  <children>
    <Group id="Group" fx:id="MenuGroup">
      <children>
        <MenuBar prefWidth="319.0">
          <menus>
            <Menu mnemonicParsing="false" text="File">
              <items>
                <MenuItem mnemonicParsing="false" text="New Game" />
                <SeparatorMenuItem mnemonicParsing="false" />
                <MenuItem mnemonicParsing="false" text="Options" />
                <SeparatorMenuItem mnemonicParsing="false" />
                <MenuItem mnemonicParsing="false" text="Close" />
              </items>
            </Menu>
            <Menu mnemonicParsing="false" text="Help">
              <items>
                <MenuItem mnemonicParsing="false" text="Controls" />
                <SeparatorMenuItem mnemonicParsing="false" />
                <MenuItem mnemonicParsing="false" text="About" />
              </items>
            </Menu>
          </menus>
        </MenuBar>
      </children>
    </Group>
    <TabPane layoutY="24.0" prefHeight="317.0" prefWidth="319.0" tabClosingPolicy="UNAVAILABLE">
      <tabs>
        <Tab id="GameOptionsPanel" style="" text="Game options">
          <content>
            <Group id="Group">
              <children>
                <Pane prefHeight="274.5" prefWidth="193.0">
                  <children>
                    <Label layoutX="37.0" layoutY="35.0" text="Difficulties" textAlignment="CENTER" underline="true" />
                    <RadioButton layoutX="31.0" layoutY="60.0" mnemonicParsing="false" text="Beginner">
                      <toggleGroup>
                        <ToggleGroup fx:id="DiffSelection" />
                      </toggleGroup>
                    </RadioButton>
                    <RadioButton layoutX="32.0" layoutY="87.0" mnemonicParsing="false" selected="true" text="Intermediate" toggleGroup="$DiffSelection" />
                    <RadioButton layoutX="31.0" layoutY="111.0" mnemonicParsing="false" text="Hard" toggleGroup="$DiffSelection" />
                    <RadioButton disable="true" layoutX="31.0" layoutY="138.0" mnemonicParsing="false" text="Heroic" toggleGroup="$DiffSelection" />
                    <RadioButton disable="true" layoutX="31.0" layoutY="165.0" mnemonicParsing="false" text="Legandary" toggleGroup="$DiffSelection" />
                    <RadioButton disable="true" layoutX="31.0" layoutY="195.0" mnemonicParsing="false" text="GOD LIKE" toggleGroup="$DiffSelection" />
                    <Separator layoutX="116.0" layoutY="35.0" orientation="VERTICAL" prefHeight="175.99997792968497" />
                    <Separator layoutX="19.0" layoutY="211.0" prefWidth="101.0" />
                    <Separator layoutX="19.0" layoutY="34.0" prefWidth="101.0" />
                    <Separator layoutX="16.0" layoutY="35.0" orientation="VERTICAL" prefHeight="175.9998779296875" />
                    <Button id="Exit" cancelButton="true" layoutX="47.0" layoutY="250.0" mnemonicParsing="false" onAction="Platform.exit();" onMouseClicked="Platform.exit()" text="Exit" />
                  </children>
                </Pane>
              </children>
            </Group>
          </content>
        </Tab>
        <Tab id="CharacterOptionsPanel" style="" text="Character Optinos">
          <content>
            <Pane prefHeight="200.0" prefWidth="200.0">
              <children>
                <ComboBox layoutX="142.0" layoutY="20.0" prefHeight="23.999908447265625" prefWidth="86.0" promptText="Select One">
                  <items>
                    <FXCollections fx:factory="observableArrayList">
                      <String fx:value="Zombie" />
                      <String fx:value="Priest" />
                      <String fx:value="Hero" />
                      <String fx:value="Female" />
                    </FXCollections>
                  </items>
                </ComboBox>
                <Label layoutX="14.0" layoutY="24.0" text="Character Select" />
                <Separator layoutY="53.0" prefWidth="253.0" />
                <ImageView fitHeight="150.0" fitWidth="200.0" layoutX="27.0" layoutY="86.0" pickOnBounds="true" preserveRatio="true" />
              </children>
            </Pane>
          </content>
        </Tab>
      </tabs>
    </TabPane>
  </children>
</AnchorPane>



I am not sure at The Page error aswell,
Was This Post Helpful? 0
  • +
  • -

#5 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:08 PM

Just as a stab in the dark try adding

<?language javascript?>


to the top of your fxml files.
Was This Post Helpful? 0
  • +
  • -

#6 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:18 PM

What is Platform.exit() referring to at line 61 of Options.fxml?
Was This Post Helpful? 0
  • +
  • -

#7 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:21 PM

It's the method you call to quit the application.
Was This Post Helpful? 0
  • +
  • -

#8 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1363
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:26 PM

Alternatively you could try changing the references to Platform.exit() to instead reference a method in your GameStartUp class.

So for instance onMouseClicked="#exitHandler"

Then you add the corresponding method in your .java file that calls the Platform.exit().

@FXML
public void exitHandler(ActionEvent e) {
     Platform.exit();
}

Was This Post Helpful? 0
  • +
  • -

#9 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2205
  • View blog
  • Posts: 5,239
  • Joined: 10-September 10

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:28 PM

Yep. Thanks. Haven't done it that way myself so didn't recognize it.

Your first suggestion, adding

<?language javascript?>

seems to fix it.
Was This Post Helpful? 0
  • +
  • -

#10 Drive137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-February 11

Re: JavaFX GUI problems

Posted 28 February 2013 - 04:40 PM

Thank you for the <?language javascript?> that seems to have fixed the page error now I am getting

Buildfile: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build.xml
setup-staging-area:
   [delete] Deleting directory C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\externalLibs
   [delete] Deleting directory C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\project
   [delete] Deleting directory C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\projectRefs
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\externalLibs
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\project
     [copy] Copying 1 file to C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\project
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\projectRefs
do-compile:
   [delete] Deleting directory C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build\src
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build\libs
    [mkdir] Created dir: C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build\classes
     [copy] Copying 1 file to C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build\src

BUILD FAILED
C:\Users\dspecht\Dropbox\TestingObjectAccuired\build\build.xml:53: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "C:\Program Files\Java\jre7"

Total time: 438 milliseconds



Unsure as to what this is pointing at, it may be it is not finding the javac complier that is used in eclipse and java in general.

Thank you for the help so far guys it is proving use full and I understand why some of it didnt work, and ya you could do

System.exit(0);

as well to exit the program, but by researched showed Platform.exit() was used more to close javafx projects

Sorry for the double post guys, can't find the edit feature at the moment, I seem to be trying to complie this time but now I am getting a slightly different stacktrace

javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
/C:/Users/dspecht/Dropbox/csc150finale/bin/mainMenu.fxml
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2147)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
  at GameStartUp.start(GameStartUp.java:17)
  at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
  at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
  at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
  at java.security.AccessController.doPrivileged(Native Method)
  at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
  at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
  at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
  at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
  at java.lang.Thread.run(Unknown Source)

LOADERS can not find the file
javafx.fxml.LoadException: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2147)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2028)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2744)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2723)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2709)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2696)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2685)
	at GameStartUp.start(GameStartUp.java:17)
	at com.sun.javafx.application.LauncherImpl$5.run(LauncherImpl.java:319)
	at com.sun.javafx.application.PlatformImpl$5.run(PlatformImpl.java:215)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:179)
	at com.sun.javafx.application.PlatformImpl$4$1.run(PlatformImpl.java:176)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:176)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
	at com.sun.glass.ui.win.WinApplication$3$1.run(WinApplication.java:73)
	at java.lang.Thread.run(Unknown Source)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[2,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
	at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
	at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
	at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2117)
	... 17 more



Was This Post Helpful? 0
  • +
  • -

#11 Drive137  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 20-February 11

Re: JavaFX GUI problems

Posted 02 March 2013 - 09:44 PM

So, I have been stuck at the point Above for a while, and even remaking the project does not help and I really have no clue what these error/exception messages are. I do have time to work on this but this is getting to the point that I can't even get a basic things like this to run atm
Was This Post Helpful? 0
  • +
  • -

#12 farrell2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 856
  • View blog
  • Posts: 2,620
  • Joined: 29-July 11

Re: JavaFX GUI problems

Posted 02 March 2013 - 11:51 PM

I don't think you can call PLatform.exit() like that in a button's onAction in FXML. You also need to pass in the appropriate fx:controller in your AnchorPane. I didn't see that.

<AnchorPane fx:controller="your.app.package.MainMenuController"


Was This Post Helpful? 0
  • +
  • -

#13 Ghlavac  Icon User is offline

  • D.I.C Addict

Reputation: 84
  • View blog
  • Posts: 519
  • Joined: 14-January 09

Re: JavaFX GUI problems

Posted 03 March 2013 - 12:13 PM

The reason for FXML is to separate the logic from the actual UI, hard coding the exit isn't exactly wise todo in a file that's more or less only meant to display the UI.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1