Can I use Javax imports in a JavaFX program? - javafx

I'm coding a JavaFX program GUI program. I need to find the length of audio files and I need to use a 'Javax' import for that. (It seems I can achieve that using 'media' import in JavaFX. But I'm struggling to figure out how to). I understand that it's best not to mix Java Swing and JavaFX. But can I use 'Javax' imports in a JavaFX program?

Related

Create QML component library

I wasn't able to create and use a QML component library by following the fragmented parts of tutorials and Qt documentation, so I'm just gonna ask somebody to answer it all at once.
I want to create a single file (located in /usr/lib/project/components.rcc), that will include all components in ~/Project/src/components/ and their child components located in ~/Projects/src/components/insertparentcomponentname/. I want to be able to use those components in normal QML code.
The question is, how can I create this file and how can I import components in it to use in QML?
( Using Qt Quick 2.0 and C++ with CMake on Arch Linux )

Is there a vscode QT widget that can be embedded in an application

I am creating a free application with pyqt5.
In this application, i need to give the users the possibility to type custom python scripts.
I don't want to develop a whole python syntax parser and provide autocompletion as it seems a long process and the scripting is not the most important part of the application.
I ask whether vscode (or other script editing tool) offer the possibility to embed a special editor as a QWidget inside an application that provides syntax analysis and autocompletion.
Thanks for help
Yes, there is: QScintilla, the Qt port of scintilla, a library for text editing oriented to source code editing.
This is how you set up a basic editor with minimal syntax highlighting:
class Editor(Qsci.QsciScintilla):
def __init__(self):
super().__init__()
font = self.font()
font.setFamily('mono')
self.setFont(font)
# create a "Lexer", which is what allows syntax highlighting
# within the editor; the following is the class for python
# syntax, but there are other classes for different languages
lexer = Qsci.QsciLexerPython()
lexer.setDefaultFont(font)
self.setLexer(lexer)
You can find the documentation at the official site
Is it mandatory to embbed the editor inside your application?
Maybe you could make your app open a system editor instead and let the user choose the tool of his preference.

Scene Builder - Custom Control Reuse

I've been at this problem trying to find workarounds for weeks now and I am starting to give up. I must be doing something fundamentally wrong. Anyway, this is my situation. I have previously made a neat little program using JavaFX but have now discovered Scene Builder and want to build it all again using this tool. The project includes several components that are frequently reused such as the one below. This is made up of a label, a slider, a text field and another custom component, an InfoIcon.
I have understood that the done thing is to import the custom component (the InfoIcon) as a .jar file into Scene Builder when building my SliderVariable as I call it. This works great and I can run a small demo of my SliderVariable from within Eclipse by creating a main method, a scene and making a SliderVariable in this scene. As mentioned this works great. Importing or Including the InfoIcon does not do what I want (I don't think) because then I cannot easily make changes to the InfoIcon (or its controller) and update my SliderVariable and then see the effects in the final product.
The problems arise when I want to take it one step further and in turn use my SliderVariable in Scene Builder. I do as with the InfoIcon. I export my slider variable to a non-executable jar and then import it into Scene Builder. Here Scene Builder complains that it cannot find any UI components and thus fails to import it. I have discovered that this is because when I export the SliderVariable as a jar it does not also package its dependencies meaning the InfoIcon doesn't get bundled with it and that the compiler cannot find this component as I try to use it.
I have tried to solve this with FatJar which I cannot get working (and it seems like it is not in use any more). I have tried Maven where I couldn't import the Maven project dependency of the InfoIcon in the FXML of the SliderVariable. Finally I have also tried simply not importing a jar but instead including the source code of InfoIcon in a separate package of SliderVariable but then I couldn't import it into my FXML. I am desperate. What do people normally do if they want to reuse custom components with their own controllers in Scene Builder? Is this even done? Should I just give up :'(?
This unwieldly post must be highly confusing but I do not know how to make it clearer. Any sort of response would be greatly appreciated and if you do not believe this forum is the right place to post something like this (which it probably isn't) please point me to someplace else where I am more welcome.
Many thanks.
EDIT 1: I have now added a folder in my project called Dependencies. In here I put a copy (not a reference to) my InfoIcon.jar.
I then add this .jar file to my Build Path and remove the old one. I then enter SceneBuilder and reimport the InfoIcon jar but this time from the Dependencies folder I just created. At this point the small project test I've made still runs fine. I then export as JAR file with the following settings and hit finish.
I then try to import it into Scene Builder and Scene Builder tells me it cannot find any UI components.
EDIT 2: Should I select these items?
Note that the jar file is in Dependencies but also in Referenced Libraries (which is not visible here). This type of selection makes it so that Scene Builder can find and Import the InfoIcon but not the SliderVariable.
When you export InfoIcon, you can simply select the packages and classes related to it in the Eclipse's package explorer (or other similar explorer views), and choose export.
Similarly, when you try to export SliderVariable control, you need to choose everything you have selected in InfoIcon, on top of other files that are needed by SliderVariable control itself.
If InfoIcon is imported into SliderVariable project as a JAR file, then you would need to manually select that JAR file during the export of SliderVariable.

Moving Flex MXML Application into Flash

is it possible to move a flex mxml project into flash?
i have the project complete in mxml with actionscript but due to the fact that flex is limited in its visual animations ( no timeline! ) i would prefer to switch to using flash.
the project is relatively huge, all done in mxml and i cant just re-create it in flash, it will take months!
what do you think? is there a conversion ability or a use of flex component inside flash? if so, how?
Thanks.
There is no conversion utility, but as noted in the comments you can build your animation in the Flash authoring tool and import it to Flex (Flash Builder.)
The way you do this will depend on what type of animation you're trying to do. If it's just a simple path or the animation of some type of built in shape you'll want to export the animation to FXG to easily import it into Flex. Select the object you're trying to export and hit file->export->Export Selection. In the export window select "Adobe FXG" as the export format. Try this article for more information.
If you're building an animation that needs to be controlled via scripting or is more complicated you'll need to export it as Flash content (SWF or SWC are fine.) Then load the object in to your Flex application dynamically and script it accordingly. Be aware that cross-swf scripting security issues may arise if you use a swf loaded at run time.
You might consider converting the Flex project into a Flex library project and placing the resulting swc into the class path of the Flash project.

How about using FLEX 3 component inside Flash file?

Is it possible to use Flex 3 component/code inside Flash (cs4) SWF file ?
I know its possible in the opposite direction.
With my minimal testing it seems you can't use Flex components when building a "pure AS3" project. (Can we start calling it PAS3 or something? Like "passé". Or "pastry". :)
I did this admittedly limited testing by creating a test project with one AS class as the "document class", which would instantiate and addChild one mx.controls.Button. I copied the whole mx package from the path mentioned by hasseg into the project source path.
This is what I found out:
By removing the use of mx_internal from a certain Version.as file, I got Flash IDE to compile my test project without warning. Nothing showed up on the stage though.
Using Flex Builder (and the flex compiler, obviously) I also managed to compile the project without errors. I put breakpoints in the code and watched it build itself in the debugger. The components were instantiated flawlessly, but still nothing showed up on the stage. This swf also crashed the browser numerous times.
I haven't used Flex code in a "pure AS3" project myself, but I don't see why you couldn't do that.
You can download the Flex SDK and get the Flex components from there, both as an swc file (under /frameworks/libs) and as AS3 source code (under /frameworks/projects/framework/src).
It looks like this can be done after all: http://labs.wichers.nu/2007/12/25/using-flex-compiled-code-within-flash/
In general you need to use MXML to initialise the Flex framework and use Flex components.
Mike Chambers from Adobe says:
There is not support for using the Flex Framework in an AS only project. While it is theoretically possible, you would have to manually bootstrap a lot of the application initialization code that Flex handles (something which would be rather complex). - Source
To see how complex, you can tell the compiler to keep the intermediate AS3 files that it generates from the MXML. Open your AS3 project properties and set -keep-generated-actionscript as an argument to the compiler. Compile your project then look in the obj/generated folder. Using Flex 4, I get 13 small files the main of which extends spark.components.Application and overrides a few methods.
So it's possible but you probably wouldn't want to do it. Flex is meant to make your life easier, not harder.

Resources