Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Canvas is not a valid type(Cannot integrate JavaFx Canvas into efxclipse application)
Canvas is not a valid type [message #1411858] Sun, 24 August 2014 17:07 Go to next message
Eclipse GuestFriend
Messages: 93
Registered: February 2013
Location: Vienna
Member
Hi

I can run efxclipse applications and I already tried out several different containers and controls within the fxml file. I create the UI content via InjectingFXMLLoader.create(...). Unfortunately, when adding a simple Canvas to the fxml file, I get the error "javafx.fxml.LoadException: Canvas is not a valid type.".
Is the JavaFx Canvas not yet supported by efxclipse or did I miss something important?
Any ideas?

I am running the standard "all-in-one" eclipse SDK download from the efxclipse homepage (Luna 4.4, Build id: I20140606-1215).

[Updated on: Mon, 25 August 2014 06:30]

Report message to a moderator

Re: Canvas is not a valid type [message #1412145 is a reply to message #1411858] Mon, 25 August 2014 12:04 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
There's nothing that needs to be ported to e(fx)clipse, when you launch
your application pure java/javafx is running. So there must be a problem
in your FXML/application code.

Tom

On 24.08.14 19:07, Michael Marton wrote:
>
> Hi
>
> I can run efxclipse applications and I already tried out several
> different containers and controls but when trying to integrate a simple
> Canvas into a fxml file, I get the error "javafx.fxml.LoadException:
> Canvas is not a valid type.". Is the JavaFx Canvas not yet ported to
> efxclipse or did I miss something important?
> Any ideas?
>
> I am running the standard "all-in-one" eclipse SDK download from the
> efxclipse homepage (Luna 4.4, Build id: I20140606-1215).
>
> best regards
> Michael
Re: Canvas is not a valid type [message #1412186 is a reply to message #1412145] Mon, 25 August 2014 14:00 Go to previous messageGo to next message
Eclipse GuestFriend
Messages: 93
Registered: February 2013
Location: Vienna
Member
Ok, then this was a misunderstanding from my side but still the JavaFx Canvas is not recognized.

- I downloaded the newest "eclipse SDK 4.4 1.0.0 SNAPSHOT", created a new workspace and a sample
"e4 Media Application": works fine

- I added an additional Part in the Application.e4xmi, created an additional fxml file and assigned a new part class to it
which loads the fxml file via "InjectingFXMLLoader.create(...)": works fine

this is the content of the working fxml:

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

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

<BorderPane xmlns:fx="[url]http://javafx.com/fxml/1[/url]" xmlns="[url]http://javafx.com/javafx/8[/url]">
	<center>
		<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
			<children>
				<Button layoutX="74.0" layoutY="14.0" mnemonicParsing="false" text="Button" />
			</children>
		</Pane>
	</center>
</BorderPane>


- then I added a Canvas to the fxml file and on startup a LoadException is thrown("Canvas is not a valid type")

this is the content of the non-working fxml:

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

<?import java.lang.*?>
<?import javafx.scene.canvas.*?>
<?import javafx.scene.layout.*?>

<BorderPane xmlns="[url]http://javafx.com/javafx/8[/url]" xmlns:fx="[url]http://javafx.com/fxml/1[/url]">
	<center>
		<Pane prefHeight="200.0" prefWidth="200.0" BorderPane.alignment="CENTER">
			<children>
				<Canvas height="200.0" width="200.0" />
			</children>
		</Pane>
	</center>
</BorderPane>


...and this is the code for loading the fxml

public class MyPart {

	@Inject
	private MPart part;
	private Node focusNode;

	
	@PostConstruct
	void init(BorderPane p) {
        InjectingFXMLLoader<Object> fxmlLoader = InjectingFXMLLoader.create(part.getContext(), getClass(), "MyPart.fxml");
        Node node = null;
        
        try {
            node = (Node) fxmlLoader.load();

            if(node != null) {
                p.setCenter(node);
                focusNode = node;
            }
        } catch (IOException exception) {
            exception.printStackTrace();
        }
	}	
}


Any ideas what could be wrong?

best regards
Michael




[Updated on: Mon, 25 August 2014 14:11]

Report message to a moderator

Re: Canvas is not a valid type [message #1412190 is a reply to message #1412186] Mon, 25 August 2014 14:11 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Please check your package-imports in the MANIFEST.MF? Is the package
javafx.scene.canvas imported?

Tom

On 25.08.14 16:00, Jan Schumacher wrote:
> Ok, then this was a misunderstanding from my side but still the JavaFx
> Canvas is not recognized.
> - I downloaded the newest "eclipse SDK 4.4 1.0.0 SNAPSHOT", created a
> new workspace and a sample "e4 Media Application": works fine
>
> - I added an additional Part in the Application.e4xmi, created an
> additional fxml file and assigned a new part class to it which loads the
> fxml file via "InjectingFXMLLoader.create(...)": works fine
>
> this is the content of the working fxml:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <?import java.lang.*?>
> <?import javafx.scene.control.*?>
> <?import javafx.scene.layout.*?>
>
> <BorderPane xmlns:fx="http://javafx.com/fxml/1"
> xmlns="http://javafx.com/javafx/8">
> <center>
> <Pane prefHeight="200.0" prefWidth="200.0"
> BorderPane.alignment="CENTER">
> <children>
> <Button layoutX="74.0" layoutY="14.0"
> mnemonicParsing="false" text="Button" />
> </children>
> </Pane>
> </center>
> </BorderPane>
>
>
> - then I added a Canvas to the fxml file and on startup a LoadException
> is thrown("Canvas is not a valid type")
> this is the content of the non-working fxml:
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <?import java.lang.*?>
> <?import javafx.scene.canvas.*?>
> <?import javafx.scene.layout.*?>
>
> <BorderPane xmlns="http://javafx.com/javafx/8"
> xmlns:fx="http://javafx.com/fxml/1">
> <center>
> <Pane prefHeight="200.0" prefWidth="200.0"
> BorderPane.alignment="CENTER">
> <children>
> <Canvas height="200.0" width="200.0" />
> </children>
> </Pane>
> </center>
> </BorderPane>
>
>
>
>
Re: Canvas is not a valid type [message #1412201 is a reply to message #1412190] Mon, 25 August 2014 14:37 Go to previous message
Eclipse GuestFriend
Messages: 93
Registered: February 2013
Location: Vienna
Member
apparently, the dependency to "javafx.scene.canvas" was the only one missing
from the "javafx.scene" package Sad
...added it and it works fine now.

have to look a little bit closer in future


thanks for your help

[Updated on: Mon, 25 August 2014 14:41]

Report message to a moderator

Previous Topic:Embedding JavaFX in SWT E4 RCP application doesn't work
Next Topic:CleanUpAddon and DndAddon
Goto Forum:
  


Current Time: Fri Mar 29 15:09:52 GMT 2024

Powered by FUDForum. Page generated in 0.03545 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top