Class SwingUtil


  • public class SwingUtil
    extends java.lang.Object
    Various Swing utilities.
    • Constructor Summary

      Constructors 
      Constructor Description
      SwingUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addModalTooltip​(javax.swing.AbstractButton button, java.lang.String on, java.lang.String off)  
      static javax.swing.JButton createSwingButton​(NavigationButton navigationButton, int iconSize, java.util.function.BiConsumer<NavigationButton,​javax.swing.JButton> specialCallback)
      Create swing button from navigation button.
      static java.awt.TrayIcon createTrayIcon​(java.awt.Image icon, java.lang.String title, java.awt.Frame frame)
      Create tray icon.
      static void fastRemoveAll​(java.awt.Container c)
      Removes all of a component's children faster than calling removeAll() on it in many cases
      static void pumpPendingEvents()
      Run any events currently in the event queue
      static void removeButtonDecorations​(javax.swing.AbstractButton button)  
      static void setFont​(java.awt.Font font)
      Sets default Swing font.
      static void setTheme​(javax.swing.LookAndFeel laf)
      Safely sets Swing theme
      static void setupDefaults()
      Sets some sensible defaults for swing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SwingUtil

        public SwingUtil()
    • Method Detail

      • setupDefaults

        public static void setupDefaults()
        Sets some sensible defaults for swing. IMPORTANT! Needs to be called before main frame creation
      • setTheme

        public static void setTheme​(@Nonnull
                                    javax.swing.LookAndFeel laf)
        Safely sets Swing theme
        Parameters:
        laf - the swing look and feel
      • setFont

        public static void setFont​(@Nonnull
                                   java.awt.Font font)
        Sets default Swing font. IMPORTANT! Needs to be called before main frame creation
        Parameters:
        font - the new font to use
      • createTrayIcon

        @Nullable
        public static java.awt.TrayIcon createTrayIcon​(@Nonnull
                                                       java.awt.Image icon,
                                                       @Nonnull
                                                       java.lang.String title,
                                                       @Nonnull
                                                       java.awt.Frame frame)
        Create tray icon.
        Parameters:
        icon - the icon
        title - the title
        frame - the frame
        Returns:
        the tray icon
      • createSwingButton

        public static javax.swing.JButton createSwingButton​(@Nonnull
                                                            NavigationButton navigationButton,
                                                            int iconSize,
                                                            @Nullable
                                                            java.util.function.BiConsumer<NavigationButton,​javax.swing.JButton> specialCallback)
        Create swing button from navigation button.
        Parameters:
        navigationButton - the navigation button
        iconSize - the icon size (in case it is 0 default icon size will be used)
        specialCallback - the special callback
        Returns:
        the swing button
      • removeButtonDecorations

        public static void removeButtonDecorations​(javax.swing.AbstractButton button)
      • addModalTooltip

        public static void addModalTooltip​(javax.swing.AbstractButton button,
                                           java.lang.String on,
                                           java.lang.String off)
      • fastRemoveAll

        public static void fastRemoveAll​(java.awt.Container c)
        Removes all of a component's children faster than calling removeAll() on it in many cases
      • pumpPendingEvents

        public static void pumpPendingEvents()
        Run any events currently in the event queue