admin

Applet Runner 1.4 released

Applet Runner 1.4 demo

What’s new

  • Fixed possible NPE in IntelliJ IDEA 2023 CE
  • Catch Throwable for applet methods instead of Exception
  • Improved start-up description
  • Showing bookmarks doesn’t log warnings anymore
  • Added possible AppletRunnerNoParent applet parameter to define no parent class loader
  • Added possible AppletRunnerParentFirst applet parameter to define parent class loader as used first
  • Drop down menus shows above the buttons

Applet Runner Pro :

  • If applet is started remember location after restart
  • When adding a new panel, the location isn’t mandatory anymore
  • Set a title to the window when starting an applet in a window
  • Do not exit the application when closing an applet window
  • Save window location/size based on applet location (when specified)
  • Use preferred width and height set in applet html/jnlp at first start when opening in window
  • Put applet name in the window name

Superpose Texts and Images – Post on Screen Pro 1.0 Beta Released

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)

You can download and try it for free at https://www.japplis.com/post-on-screen/pro/

Applet Runner 1.3 released

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.

Applet Runner running in NetBeans with Japplis Toolbox applet

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.

Always On Top Text – Post On Screen 1.0 Beta Released

I’m pleased to announce the release of Post On Screen 1.0 beta.

Post On Screen showing text above a spreadsheet

Post On Screen will show a text on top of all other windows.

You can choose

  • Your text (of course)
  • The font
  • The colors (unique or gradient)
  • Animated gradient speed (0 for static)
  • Text transparency
  • Text size (Font size will adapt to the text window size)
  • Position

Post On Screen is freeware and works on Window, Mac OS X and Linux. You can download it at https://www.japplis.com/post-on-screen/

Paving the on-ramp – Day 2 – SwingUtilities.showInFrame

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");
}
}

Simplifies to

void main() {
println("Hello World");
}

Day 2 (as proposed by me – Anthony Goubard)

import javax.swing.*;

void main() {
    SwingUtilities.invokeAndWait(() -> {
     	JFrame frame = new JFrame("Test");
       	frame.add(new JLabel("Hello World"));
       	frame.pack();
       	frame.setLocationRelativeTo(null);
       	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       	frame.setVisible(true);
    }
}

Simplifies to

import javax.swing.*;

void main() {
    SwingUtilities.showInFrame("Test", () -> new JLabel("Hello World"));
}

The on-ramp

  • No need to understand the concept of the Event Dispatch Thread (EDT) where UI operations should be done
  • No need to understand yet the concept of laying out components (pack())
  • No need to know the class JFrame and 5 of its methods
  • The focus is more on the intention of the program: Showing the text “Hello World” in a window with title “Test”

Other benefits (than the on-ramp)

  • Cleaner Stack overflow Swing examples.
  • Ease of use with JShell.
  • 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.

Hello World in Java, the difference between now and what it could be

Ant Commander Pro 4.0 beta released

The first public available of Ant Commander Pro 4.0 file manager has been released. You can download it for free at https://www.antcommander.com.

Ant Commander Pro file manager screenshot
Ant Commander Pro Dual table

The main advantages compared to a standard file manager:

  • Smart incremental search (e.g. */ & .java & <5days & > 10 kb & ![junit])
  • Basic Git support
  • Detect (and ask) file conflicts before file operation (like copy/move)
  • Support local file, zip, jar, tar, gz, bzip2, ftp, ftps, sftp, webdav, ram, lst, http(s)
  • Multiple split panels in each tabs
  • Panels: Terminal, SSH, Text editor with syntax highlight
  • > 40 skins
  • Runs always on top, translucent, on Windows, Mac OS X, Linux, embedded in IntelliJ IDEA, Android Studio, Eclipse, NetBeans

Better JSON formatting with Japplis Toolbox 5.1

Japplis Toolbox 5.1 has been released.

Japplis Toolbox is a free desktop software (Windows, Mac OS X, Linux) with more than 50 text utilities.

What’s new:

  • Better JSON formatter (faster, can handle more text, better formatting)
  • New utility: sort by regular expression
    • In case you don’t want to sort by the start of a line, you can specify a regular expression group and it will sort the lines by it
  • When Live is selected, operation is executed on every valid change of the pattern
  • Improved showing Swing properties: border UI applied to view, input keys and actions shown for InputMap UI
  • Loading and saving files use UTF-8 encoding
  • Various bug fixes and small improvements

Japplis Toolbox Pro 5.1 has also been released.

What’s new:

  • Added option in settings to unpack gz files
  • Added option in settings to disable/enable line wrap for input and output text area

JSON formatter

Japplis Toolbox JSON formatter

JLearnIt 6.3 Released

JLearnIt 6.3 has been released.

What’s new:

  • 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

https://www.jlearnit.com