Class SwingUtil


  • public class SwingUtil
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static javax.swing.filechooser.FileFilter JAVA_FILE_FILTER  
      static javax.swing.filechooser.FileFilter PNG_FILE_FILTER  
      static javax.swing.filechooser.FileFilter XML_FILE_FILTER  
    • Constructor Summary

      Constructors 
      Constructor Description
      SwingUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String chooseFilenameWithConfirm​(java.awt.Component comp, javax.swing.JFileChooser fileChooser)  
      static java.lang.Object coerce​(java.lang.Object val, java.lang.Class clz)  
      static boolean confirmOverwrite​(java.awt.Component comp, java.io.File file)  
      static java.lang.Double convertDouble​(java.lang.String str)  
      static java.lang.Integer convertInteger​(java.lang.String str)  
      static void copyToClipboard​(java.lang.Object o, boolean isFormatted)  
      static javax.swing.JButton createButton​(java.lang.String title, java.lang.String tip, java.awt.event.ActionListener action)  
      static javax.swing.JButton createButton​(javax.swing.ImageIcon icon, java.lang.String tip, java.awt.event.ActionListener action)  
      static javax.swing.filechooser.FileFilter createFileFilter​(java.lang.String description, java.lang.String extension)
      Example usage:
      static java.awt.datatransfer.Transferable getContents​(java.awt.datatransfer.Clipboard clipboard)  
      static java.lang.Double getDouble​(javax.swing.JTextField txt, java.lang.Double defaultVal)  
      static java.lang.Object getFromClipboard()  
      static java.lang.Integer getInteger​(javax.swing.JTextField txt, java.lang.Integer defaultVal)  
      static void reportException​(java.awt.Component c, java.lang.Exception e)  
      static void setEnabledWithBackground​(java.awt.Component comp, boolean isEnabled)  
      static java.lang.Object value​(javax.swing.JComboBox cb, java.lang.Object[] val)  
      static java.lang.String value​(javax.swing.text.JTextComponent txt)  
      • Methods inherited from class java.lang.Object

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

      • XML_FILE_FILTER

        public static javax.swing.filechooser.FileFilter XML_FILE_FILTER
      • JAVA_FILE_FILTER

        public static javax.swing.filechooser.FileFilter JAVA_FILE_FILTER
      • PNG_FILE_FILTER

        public static javax.swing.filechooser.FileFilter PNG_FILE_FILTER
    • Constructor Detail

      • SwingUtil

        public SwingUtil()
    • Method Detail

      • createFileFilter

        public static javax.swing.filechooser.FileFilter createFileFilter​(java.lang.String description,
                                                                          java.lang.String extension)
        Example usage:
         SwingUtil.createFileFilter("JEQL script (*.jql)", "jql")
         
        Parameters:
        description -
        extension -
        Returns:
        the file filter
      • chooseFilenameWithConfirm

        public static java.lang.String chooseFilenameWithConfirm​(java.awt.Component comp,
                                                                 javax.swing.JFileChooser fileChooser)
        Parameters:
        comp -
        fileChooser -
        Returns:
        filename chosen, or null if choose was cancelled for some reason
      • confirmOverwrite

        public static boolean confirmOverwrite​(java.awt.Component comp,
                                               java.io.File file)
      • setEnabledWithBackground

        public static void setEnabledWithBackground​(java.awt.Component comp,
                                                    boolean isEnabled)
      • coerce

        public static java.lang.Object coerce​(java.lang.Object val,
                                              java.lang.Class clz)
      • convertInteger

        public static java.lang.Integer convertInteger​(java.lang.String str)
      • convertDouble

        public static java.lang.Double convertDouble​(java.lang.String str)
      • getInteger

        public static java.lang.Integer getInteger​(javax.swing.JTextField txt,
                                                   java.lang.Integer defaultVal)
      • getDouble

        public static java.lang.Double getDouble​(javax.swing.JTextField txt,
                                                 java.lang.Double defaultVal)
      • value

        public static java.lang.String value​(javax.swing.text.JTextComponent txt)
      • value

        public static java.lang.Object value​(javax.swing.JComboBox cb,
                                             java.lang.Object[] val)
      • copyToClipboard

        public static void copyToClipboard​(java.lang.Object o,
                                           boolean isFormatted)
      • getFromClipboard

        public static java.lang.Object getFromClipboard()
      • getContents

        public static java.awt.datatransfer.Transferable getContents​(java.awt.datatransfer.Clipboard clipboard)
      • reportException

        public static void reportException​(java.awt.Component c,
                                           java.lang.Exception e)
      • createButton

        public static javax.swing.JButton createButton​(javax.swing.ImageIcon icon,
                                                       java.lang.String tip,
                                                       java.awt.event.ActionListener action)
      • createButton

        public static javax.swing.JButton createButton​(java.lang.String title,
                                                       java.lang.String tip,
                                                       java.awt.event.ActionListener action)