After the release last month of freeware Post on Screen 1.0 Beta, I’m please to announce the release of Post on Screen Pro 1.0 Beta.
Post on Screen Pro is the professional version of Post on Screen with many more options than just displaying text above your other windows. Post on Screen Pro can also
Add images (like logo’s) on top of other windows
Include multiple text per post (use left right arrows to change text in your post)
Save the created post
Have multiple posts on the screen
Have a tool bar to easily change your post
Have a gradient outline for the text
Use current date & time for the text (e.g. DateTime:HH:mm)
I’m please to announce the release of Applet Runner 1.3. Applet Runner is a free IDE plug-in (Eclipse, IntelliJ IDEA/JetBrains, NetBeans) that lets you run Java applications embedded in the IDE.
What’s new:
Applet.stop() is called when the applet is closed
If you buy Applet Runner Pro, you will be able to fill in the license key in Applet Runner for NetBeans and Eclipse
Better codebase detection if the URL class location contains ‘/com/’ or ‘/org/’
Many improvements in the application framework (about 150)
Fixed license agreement window not appearing on top of other windows
Translate Ctrl, Shift, Alt to the correct keyboard sign for Mac OS X
Added SettingPanel#getLabel that can also handle tooltips
If Flat IntelliJ look and feel is selected -> unlock the possibility to provide an IntelliJ Theme
Improved quality of taking a screenshot of a component
Improved creating square buttons for IconFontSwing#decorateButton
Catch possible error when getting the clipboard data flavor
Fixed start-up error if FlatLaf not in classpath
Added possibility to skip entering the license key the first day of the installation
Added scroll bar if the setting panel doesn’t fit in the window
Note that Applet Runner Pro 1.3 has also been released. Applet Runner Pro allows to have multiple applets running at the same time and is available as standalone application for Windows, Mac OS & Linux.
There is recently an increased interest to ease the learning curve of Java for students on Day 1 of class. Brian Goetz (the architect of Java) made a proposal to eliminate some code. My proposition is a (independent) continuation to ease the learning of Java.
Day 1 (as proposed by Brian Goetz)
class HelloWord { public static void main(String[] args) { System.out.println("Hello World"); } }
Event Dispatch Thread detection. Let’s face, it when it’s a small program, a lot of people forget to do the UI in the EDT.
Single Java execution java HelloWorld.java would require less code.
No language or compiler change needed.
Proposed implementation
// public domain license - Should be in SwingUtilities
/**
* Show a window containing the provided component.
* The window will exit the application on close.
*
* @param title the title of the window
* @param panel the supplier for the component to show in the window
* @return the created component
*/
public static <T extends JComponent> T showInFrame(String title, Supplier<T> panel) {
Function<T, JFrame> frameSupplier = createdPanel -> {
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(createdPanel);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
return frame;
};
boolean isInEDT = SwingUtilities.isEventDispatchThread();
if (isInEDT) {
T createdPanel = panel.get();
frameSupplier.apply(createdPanel);
return createdPanel;
} else {
List<T> result = new ArrayList<>();
List<Exception> exception = new ArrayList<>();
try {
SwingUtilities.invokeAndWait(() -> {
try {
T createdPanel = panel.get();
frameSupplier.apply(createdPanel);
result.add(createdPanel);
} catch (Exception ex) {
exception.add(ex);
}
});
} catch (InterruptedException | InvocationTargetException ex) {
throw new RuntimeException(ex);
}
if (!exception.isEmpty()) {
Exception ex = exception.get(0);
if (ex instanceof RuntimeException) throw (RuntimeException) ex;
else throw new RuntimeException(ex);
}
return result.get(0);
}
}
Advanced
The created component is returned so you can use it further in your code. With the returned component, you also have access to the created JFrame by using SwingUtilities.windowForComponent method.
I’ve decided to wrap the exception in a RuntimeException is there is an error during the creation of the component. So you get a similar behavior whether you call this method from the Event Dispatch Thread or not.
Even though the example is with a JLabel, I would expect most of the usage will be passing a Suppier<JPanel> and probably like MyPanel::new as it’s quite common in Swing to have classes extending JPanel.
Another possibility would be to return void and use SwingUtilities.invokeLater() method. This way no need to do all the exception code and no need to have List<T> result. Comment in the reddit discussion if it’s your preference (Link below).
My history
Back when I was a student (1995), I remember it took me half a day to try to show a window on Windows 95 as I was using Borland C++. I copied the code word by word from a book as otherwise it wouldn’t work. A few days later while asking a teacher if we could have an interesting project, he told us “Sun Microsystem has just released a new language, it’s in alpha version but let’s do a project with it.”. I took the language, typed Frame frame = new Frame("Test"); frame.show(); and voilà! It was a whoa moment where I realized I would spend a lot of time with this language 😃.
Conclusion
Quite often, you see in conferences presentations about “what’s new in Java xx”, that we may forget that for some people everything is new. Paving the on-ramp doesn’t have to be a compiler or language change, it could be methods, documentation, videos, …
I think the next step would be to create a RFE ticket in the JDK bug system, but first I will wait for comments in the reddit discussion.
New ‘complete unknown’ mode in practice options to ask for word missing translations
Save action no longer show the file chooser (use Save as for the file chooser)
Log practice answers
Various improvements and bug fixing in the application framework
– Improved memory usage
– Various fixes for the applet mode
– Show the license if not already done