Substance Look and Feel Applet alert during startup - java

recently I have discovered substance. When i try to load it in my java program (not applet!) I get errors during startup.
SwingUtilities.invokeLater(new Runnable()
{
#Override
public void run()
{
try
{
UIManager.setLookAndFeel(new SubstanceGraphiteAquaLookAndFeel());
}
catch (Exception e)
{
e.printStackTrace();
}
}
});
And those are the errors (Note: Those are pop ups, where --message-- is the title, and {name} are buttons):
--APPLET ALERT-- The applet is attempting to connect to jar: [...]/substance-6.0/org/pushingpixel/substance/api/skin/graphite.colorschemes. {Allow} {Disallow} {Stop Applet}
--APPLET ALERT-- The applet is attempting to invoke the java/lang/System.getenv() operatoin on KDE_FULL_SESSION {Allow} {Disallow} {Stop Applet}
The last message appears 5 times whilst writing the following into stderr
-->> returning Frame NULL
BaseDialog: owner frame is a java.awt.Frame
Also my first window will be loaded with the default swing ui.
After closing this and opening a new one (programmatically) the ui will be initialized.
Is there any way I can bypass the error?
Edit: I use the following libraries: laf-plugin-7.2; laf-widget-7.0; substance-6.0

I downloaded a fork from: https://github.com/Insubstantial/insubstantial/downloads
The other one was not signed because i compiled it myself.

Related

Opening an URL from default browser crashes the application

I have a GUI application written in JavaFX 14 (not the XML one). I currently have three lists that are connected each to a different custom class, in whom exists an ObservableList which updates the ListViews. I have three. Upon doubleclicking on an element of the first ListView, which also contains URLs, I want to open said URL inside the default browser, no matter the OS (I'm programming on Ubuntu 20.04, and this app will be used on W10 too).
listSquads.setOnMouseClicked(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
if(event.getClickCount()==2) {
try {
if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(new URI(bot.getSquadHandler().extractURL(listSquads.getSelectionModel().getSelectedItem())));
}
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
});
This is the code. The bot is a custom TwitchBot object, based on pIRCbot libraries. The squadHandler mentioned in the getter method is said custom class. Extract URL is a method that, as the name would suggest, extracts the exact URL given a string as input - this part works, as it's called upon in other parts of the code and works correctly, and I've also tested it.
However, upon double clicking on any given element of the ViewList, the app freezes to then crash a few seconds later. Why could that be? Is there a way to open the browser no matter the OS?
Thanks in advance! :)

UISpec4J and external application

I am trying to launch an external application for testing using UISpec4J.
Here are the questions and their answers I referred so far:
How to automate a swing java web start application which runs clicking a link into a web application, which is automated with Selenium WebDriver?
Getting all windows using UISpec4J
UISpec4J Capturing modal dialog, before the trigger finish
my.exe referred below is a Java application wrapped in exe using some tool. Internally it uses the jars and is Java GUI application.
This executable launches a splash screen first, then a dialog to choose where you want to connect to and after that main window is shown. Unless I can automate where I can connect to I won't get main window.
Based on these questions I have come up with following code fragments:
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
return WindowInterceptor.run(new Trigger() {
#Override
public void run() throws Exception {
// running jnlp by netx launcher
Runtime.getRuntime().exec("C:\\my.exe");
Thread.sleep(10000);
}
});
}
});
In the approach above I simple get "No window was shown" error.
this.setAdapter(new UISpecAdapter() {
#Override
public Window getMainWindow() {
final Window[] result = new Window[1];
WindowInterceptor
.init(new Trigger() {
#Override
public void run() throws Exception {
Runtime.getRuntime().exec("C:\\my.exe");
//Thread.sleep(10000);
}
})
//.processTransientWindow()
.process(new WindowHandler() {
public Trigger process(Window window) throws Exception {
result[0] = window;
return Trigger.DO_NOTHING;
}
})
.run();
return result[0];
}
});
In the second approach above, I still get "No window shown" error AND control never reaches to overriden "process" method.
I referred to http://www.uispec4j.org/reports/apidocs/org/uispec4j/interception/WindowInterceptor.html and recommended approach is to use init to capture modal dialog is init\process sequence.
To capture non-modal it is recommended that we should use following:
Window window = WindowInterceptor.run(panel.getButton("open").triggerClick());
But I have NO idea where and how I am supposed to call it..
From the first question I referred, mentioned above, we should be able to do that because the answer to it mentions launching jnlp application which is external application.
I tried with jre 6 update 0 and I can at least run test. In java update 37, from the third question I referred above, I get abstract method not implemented error.
What am I doing wrong? Any idea?
I am using latest UISpec4J package - version 2.4.
Thanks in advance,
-Neel.
I'm very new to UISpec4J but I'm guessing it needs to run in the same JVM in order to intercept and interact with the GUI components. When you start the exe file with exec, it will create a new process and a new, separate JVM. That'll not work, if I understand UISpec4J correctly.
Regarding the non-modal example, the documentation says "You would retrieve the window from within the test...", so in a setup method or in a test should work.

Java applet on GlassFish 3.0.1 server

I have developed an applet and I am using a JSP to upload it. I have worked it using Netbeans 6.9. The applet works fine without JSP. When I run JSP on Glassfish server, applet does not run.
My applet takes 43 seconds to do processing and get displayed, I think this may be the problem.
When I run the same JSP with the same applet but with slight modification, applet runs correctly with JSP. Modification is that I comment out a function call (called from init() method) which is responsible for large execution time. The long running method reads three files and generates the output in the choice buttons, i.e. generates the choices.
But I need that function in my applet, that is very important function.
Every catch statement has a printstacktrace() method call in it.
public void start(){
initialise_maps();
}
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable()
{
public void run() {
initComponents();
}
});
} catch (Exception ex)
{
ex.printStackTrace();
}
// initialise_maps();
}
Modification is that I comment out a function call (called from init() method) which is responsible for large execution time.
It seems it will be necessary to refactor that method call to the start() method, or do it in a separate Thread (e.g. using a SwingWorker).
The long running method reads three files and generates the output in the choice buttons, i.e. generates the choices.
Add the choice boxes in the init() method, but populate them in the start() method (if not already done - the start method is called every time the browser is restored from minimized, as well as directly after init()).

Java - Pause initComponents from running?

I am building a JApplet in NetBeans. When the application is initially ran it needs to download some files onto local PC first for it to properly work. Once it is done downloading these files than the GUI should be drawn. How do I pause the JApplet from drawing the GUI until the files are downloaded? Please also note I will need to show the user another GUI that indicates that files are being downloaded, what is the best way of solving this problem? Thank you.
#Override
public void init() {
//THIS IS WHERE THE CODE FOR DOWNLOADING FILES SHOULD BE AND ITS GUI
/* Create and display the applet */
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
#Override
public void run() {
initComponents();//Draws the main GUI after files have been downloaded
}
});
} catch (Exception ex) {}
}
Sounds like you need a Splash Screen.

Java - Applet calling/invoking another Applet

I wrote earlier about the following problem and received an answer to use either Splash Screen or JDialog. As I was researching about the above 2 solutions, now I think that I might be able to solve my problem by using another applet.
The problem: Before my main applet GUI runs I need to download certain files to local PC for the GUI to work. Therefore, I am now thinking of having 2 applets where Applet1 downloads the files, Applet2 is the main GUI.
I would use the Splash Screen or JDialog but at the moment they don't seem to be what I need. How can I invoke Applet2 from Applet1 automatically in the same window, and fully close Applet1 once Applet1 is done downloading files? Is the Applet idea better solution for my problem than Splash Screen or JDialog?
Here is the code of my main applet (in this case it would be Applet2):
#Override
public void init() {
/* Create and display the Applet2 once Applet1 is done */
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
#Override
public void run() {
initComponents();//Draw the GUI
}
});
} catch (Exception ex) {}
}
My earilier post:
Java - Pause initComponents from running?

Categories