How can I change the icon image of my JavaFX application?
And is possible to run my application without java installed on computer?
You can set the image of your primary stage
#Override
public void start(final Stage stage)
{
stage.getIcons().add(new Image("icon.png"));
}
And yes you can run your application on a system without the run-time, for this you must have the run-time embedded in your application
stage.getIcons().add(new Image("yourImage.extension"));
In regards to your second question, I know this exists, but I never used it.
That would be a self contained app. Check this site:
http://docs.oracle.com/javafx/2/deployment/self-contained-packaging.htm
Related
I'm facing the Developer Tools problem since yesterday. I use
Unity (several different versions, e.g. 2018.4.23),
Jetbrains Rider (updated today to 2020.1.3, yesterday 2020.1.2)
macOS Catalina 10.15.5
I was refactoring some stuff and Developer Tools asked me for the access: Developer Tools Access needs to take control of another process for debugging to continue. Enter your password to allow this...
Since then, two things are happening.
If Developer Tools Access is enabled (also tried doing this through sudo /usr/sbin/DevToolsSecurity --enable command) nearly every time when I'm changing something in code, Unity stops working (loading wheel present) and I can't turn its application off. I tried using Activity Monitor, it doesn't show any activities. I can only see the loading wheel.
I even tried killing the Unity process through kill unitypid, it "kills" the process since it's not present on the processes list, but I still can see it on my desktop, being just as down as before.
Checking Unity logs, I can see it stops on:
Begin MonoManager ReloadAssembly
custom-attrs.c:1250: (null)
assembly:/Applications/Unity/Hub/Editor/2018.4.17f1/Unity.app/Contents/Managed/UnityEngine/UnityEngine.CoreModule.dll type:UnityException member:(null) signature:<none>
Stacktrace:
Native stacktrace:
0 libmonobdwgc-2.0.dylib 0x00000001460b4976 mono_handle_native_crash + 242
If Developer Tools Access is disabled, the application asks me a few times to enable it. After pressing Cancel a few times, Unity crashes and turns off and gives me the ability to send log error to Apple with the exception:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Application Specific Information:
abort() called
Don't really know what to do. I tried updating Rider, Catalina, installing a new Unity version.
Update: I formatted the disk and installed Catalina again, it still doesn't work.
Your help would be much appreciated!
After further investigation, I've discovered the following repro:
Create a custom attribute that derives from the PropertyAttribute that calls AssetDatabase.FindAssets("somethingsomething") in it's constructor.
Create a class (in my case it derives from the MonoBehaviour class in order to be able to call the constructor because of the gameObject placed on the scene) that contains a field that has a custom attribute mentioned above.
Add FormerlySerializedAs attribute to this field (e.g. during refactoring).
Create a gameObject with your class attached.
This will result in a pop-up window with a message that I've mentioned in my question:
Developer Tools Access needs to take control of another process for debugging to continue. Enter your password to allow this...
Example:
using System.Diagnostics;
using UnityEditor;
using UnityEngine;
public class CustomObjectPathAttribute : PropertyAttribute
{
/// <summary>
/// Default constructor.
/// </summary>
public CustomObjectPathAttribute()
{
var guids = AssetDatabase.FindAssets("Resources");
}
}
using UnityEngine.Serialization;
[System.Serializable]
public class TestClass
{
/// <summary>
/// Path to the file.
/// </summary>
[FormerlySerializedAs("pathToFile")]
[CustomObjectPath]
public string pathToFile2 = string.Empty;
}
using System.Collections.Generic;
using UnityEngine;
public class MyBehaviour : MonoBehaviour
{
private List<TestClass> testClasses;
void Start()
{
testClasses = new List<TestClass>();
}
}
Attach the MyBehaviour script to the gameObject placed on the scene. The issue will occur after project recompilation.
Using AssetDatabase.FindAssets("Resources") in the custom attribute's constructor works fine if there's no FormerlySerializedAs attribute attached to the field in the TestClass.
I've reported the bug to the Unity QA Team and they successfully reproduced the issue. Here's the link to the Unity Issue Tracker: https://issuetracker.unity3d.com/issues/crash-when-using-assetdatabase-dot-findassets-in-a-custom-propertyattribute-and-when-formerlyserializedas-attribute-is-also-used
There's nothing more I can do at this point except of
not refactoring my fields when they have custom property attributes
attached,
not using AssetDatabase.FindAssets in my property
constructor.
This is happening to me in 2019.3.x
It generally happens when I'm testing animations and making changes while in play mode.
Nothing short of a reboot will fix the issue.
I am searching for a way to separate the UI tests from the original repository where the main app stays. Is it possible to have the UI test code in another repository, "reference" the main app in some way, and test it?
Starting in Xcode 9, this is possible as long as you're willing to give up a few features. After creating a UI test bundle, you can go to the target settings to specify that it has no target application. (You may also be able to create a UI test bundle without specifying one to begin with.) After you've removed the target application, rather than using the default initializer for XCUIApplication, you can use the initializer that accepts a bundle identifier.
Your tests will end up looking something like the following:
var app: XCUIApplication {
return XCUIApplication(bundleIdentifier: "com.yourdomain.product")
}
func setup() {
app.launch()
}
func test() {
app.navigationBar.buttons["Add"].tap()
}
If you go this route, you will lose the ability to use a few features. Namely:
You won't be able to use Xcode's built in test recorder. The record button is disabled unless you have a target application configured. That being said, you could create an empty app in your project and just switch to the application you'd like to record instead. (That being said, I haven't found Xcode's record feature to be very useful, even for single project apps.)
Xcode won't automatically install your application for you. That usually isn't an issue since is located in a different repository (and sometimes isn't even an Xcode project), so you'll just need to install it before starting your tests. The iOS simulator allows you to drag and drop a .app file, so installing the app is easy enough.
I'm using the javafx-maven-plugin and IntelliJ IDEA on Windows 7.
I'm trying to get a splash screen to show while my JavaFX application boots up, like this:
I tried using the SplashScreen-Image manifest entry—and that works, but only if you click on the .jar—I'm deploying the application as a Native Bundle and so the user clicks an .exe (or a shortcut to an .exe) not the actual .jar.
When you click the .exe no splash screen is shown.
This SSCCE I made will help you help me.
If I'm deploying my app using the javafx-maven-plugin, (which, if I'm not mistaken, uses the JavaFX Packager Tool, which uses Inno Setup), how can I get a splash screen to show after the user clicks the .exe?
More Findings:
Looking at the installation directory, I find a .dll called runtime\bin\splashscreen.dll. Does that mean it can be done?
The native launcher does not respect that spash-screen, it is only when being invoked by the java-executable. As the native launcher is loading the JVM internally, this won't work.
I haven't found a proper way to get this working, not even with some preloaders. Maybe you can find this helpful: https://gist.github.com/FibreFoX/294012b16fa10519674b (please ignore the deltaspike-related stuff)
Copied code:
#Override
public void start(Stage primaryStage) throws Exception {
// due to the nature of preloader being ignored within native-package, show it here
SplashScreen splashScreen = new SplashScreen();
splashScreen.show(new Stage(StageStyle.TRANSPARENT));
// needed for callback
final SomeJavaFXClassWithCDI launcherThread = this;
// for splashscreen to be shown, its needed to delay everything else as parallel task/thread (it would block otherwise)
Task cdiTask = new Task<Void>() {
#Override
protected Void call() throws Exception {
// boot CDI after javaFX-splash (this will "halt" the application due to the work done by CDI-provider
bootCDI(launcherThread);
// push javaFX-work to javaFX-thread
Platform.runLater(() -> {
primaryStage.setTitle("Some Title");
// TODO prepare your stage here !
// smooth fade-out of slashscreen
splashScreen.fadeOut((ActionEvent event) -> {
primaryStage.show();
splashScreen.hide();
});
});
return null;
}
};
// run task
new Thread(cdiTask).start();
}
In short: I'm creating my splashscreen myself.
Disclaimer: I'm the maintainer of the javafx-maven-plugin
I'm trying to use System.AppDomain.CurentDomain.ApplicationExit += new System.EventHandler(SomeFunction); to call the function SomeFunction when the application closes. In this case Unity 3D. But it doesn't work. I have no idea why. It is an editor script and is not an instance (static). What do you think I'm doing wrong?
There is no OnApplicationQuit method for Windows. According to the official documentation:
On Windows Store Apps and Windows Phone 8.1 there is no application quit event. Consider using OnApplicationFocus event when focusStatus equals false.
Therefore, instead of checking whether or not the application closed, you'll want to check whether or not the application obtained or lost focus.
In C#:
void OnApplicationFocus(bool focus)
{
if (!focus)
{
//Do something
}
}
The documentation does not explicitly mention it, but it can be assumed OnApplicationQuit is intended for Android only as iOS also does not support it.
You could use
function OnApplicationQuit() {
//put script in here
}
So that before the application quits it calls that function and does what ever is in the { and }
I am new to Processing development environment, I did my homework and all I found is to import processing libraries into Java IDE (eclipse) and use debugging, I am wondering if there is a PDE plugin that can help with intellisense and debugging as for small sketches PDE is very convenient.
Debugging
Since the launch of Processing 3, debugging is now a native feature of the Processing IDE.
In the screenshot below, you'll see a new Debug menu. I set breakpoints on the setup() and draw() methods as indicated by the <> marks in the line numbers. To the right is a popout window listing variable and object values, etc.
Intellisense
From the Preferences menu, check the box Code completion with Ctrl-space.
Then, you can start typing a function like ellipse and press CTRL+Space to pop intellisense. Moreover, with that turned on, accessing properties or methods of an object by typing a . after should automatically pop intellisense.
Using Another IDE
Finally, you could take advantage of a more powerful IDE by importing the processing core.jar into any Java project. The core.jar file is located relative to your Processing installation, such as:
OSX: /Applications/Processing 3.0.1.app/Contents/Java/core/library/core.jar
Windows: \Program Files\processing-3.0.2\core\library\core.jar
In Processing 1 and 2, this must be run as Applet. In Processing 3, run as Java Application. Here's an example to demonstrate:
import processing.core.*;
public class Main extends PApplet {
// In Eclipse, run this project as Java Application (not Applet)
public static void main(String[] args) {
String[] a = {"MAIN"};
PApplet.runSketch(a, new Main());
}
public void settings() { // <-- that's different
size(500, 500); // necessary here to prevent runtime IllegalStateException
}
public void setup() {
// other one and done operations
}
public void draw() {
ellipse(mouseX, mouseY, 40, 40);
}
}
Check out this post if you want to write Processing code in Eclipse across multiple classes.
https://processing.org/tutorials/eclipse/
Unfortunately you can't get those features within the compact Processing development environment.
You can get autocompletion/intellisense with a decent Java IDE like IntelliJ or eclipse.
Personally I'm pretty happy with how the Proclipsing eclipse plugin integrates with Processing (easy project export, library management, etc.)
Check out this video guide on setting up:
If you use the latest Processing 2.0b7 version, and enable the 'EXPERIMENTAL' mode (top right corner), you have access to a small set of tools (breakpoints, step by step) and a realtime debugging console. It can't compare to other platforms such as VS or Eclipse, but it is a good start and gets some of the work done.
I've never tried, but for Processing 2.x there is this tool for debugging. It has been discussed in this topic in procesing forum.