Class ApplicationFrame

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, WindowConstants
Direct Known Subclasses:
DicomBrowser, DicomCleaner, DicomImageViewer, DoseUtility, DownloadOrTransmit, ECGViewer

public class ApplicationFrame extends JFrame

This class provides the infrastructure for creating applications (which extend this class) and provides them with utilities for creating a main window with a title and default close and dispose behavior, as well as access to properties, and a window snapshot function.

See Also:
  • Field Details

    • resourceBundleName

      protected static String resourceBundleName
    • resourceBundle

      protected static ResourceBundle resourceBundle
    • statusBarManager

      protected com.pixelmed.display.StatusBarManager statusBarManager
  • Constructor Details

    • ApplicationFrame

      public ApplicationFrame()

      Construct a window with the default size and title and no property source.

      Does not show the window.

      Will exit the application when the window closes.

    • ApplicationFrame

      public ApplicationFrame(int closeOperation)

      Construct a window with the default size and title and no property source.

      Does not show the window.

      Parameters:
      closeOperation - argument to setDefaultCloseOperation()
    • ApplicationFrame

      public ApplicationFrame(String title)

      Construct a window with the default size, specified title and no property source.

      Does not show the window.

      Will exit the application when the window closes.

      Parameters:
      title - the title for the top bar decoration
    • ApplicationFrame

      public ApplicationFrame(String title, int closeOperation)

      Construct a window with the default size, specified title and no property source.

      Does not show the window.

      Parameters:
      title - the title for the top bar decoration
      closeOperation - argument to setDefaultCloseOperation()
    • ApplicationFrame

      public ApplicationFrame(String title, String applicationPropertyFileName)

      Construct a window with the default size, and specified title and property sources.

      Does not show the window.

      Will exit the application when the window closes.

      Parameters:
      title - the title for the top bar decoration
      applicationPropertyFileName - the name of the properties file
    • ApplicationFrame

      public ApplicationFrame(String title, String applicationPropertyFileName, int closeOperation)

      Construct a window with the default size, and specified title and property sources.

      Does not show the window.

      Parameters:
      title - the title for the top bar decoration
      applicationPropertyFileName - the name of the properties file
      closeOperation - argument to setDefaultCloseOperation()
    • ApplicationFrame

      public ApplicationFrame(String title, String applicationPropertyFileName, int w, int h)

      Construct a window with the specified size, title and property sources.

      Does not show the window.

      Will exit the application when the window closes.

      Parameters:
      title - the title for the top bar decoration
      applicationPropertyFileName - the name of the properties file
      w - width
      h - height
    • ApplicationFrame

      public ApplicationFrame(String title, String applicationPropertyFileName, int w, int h, int closeOperation)

      Construct a window with the specified size, title and property sources.

      Does not show the window.

      Parameters:
      title - the title for the top bar decoration
      applicationPropertyFileName - the name of the properties file
      w - width
      h - height
      closeOperation - argument to setDefaultCloseOperation()
  • Method Details

    • localizeJOptionPane

      protected static void localizeJOptionPane()
    • getReleaseString

      protected static String getReleaseString()

      Get the release string for this application.

      Returns:
      the release string
    • getBuildDate

      protected static String getBuildDate()

      Get the date the package was built.

      Returns:
      the build date
    • getStatusBar

      protected JLabel getStatusBar()

      Setup a StatusBarManager and return its StatusBar.

      The initial string in the StatusBar is composed of the build date and release string.

      Returns:
      the StatusBar
    • makePathToFileInUsersHomeDirectory

      protected static String makePathToFileInUsersHomeDirectory(String fileName)

      Given a file name, such as the properties file name, make a path to it in the user's home directory.

      Parameters:
      fileName - the file name to make a path to
    • loadProperties

      protected void loadProperties()

      Store the properties from the current properties file.

    • storeProperties

      protected void storeProperties(String comment) throws IOException

      Store the current properties in the current properties file.

      Parameters:
      comment - the description to store as the header of the properties file
      Throws:
      IOException
    • getProperties

      protected Properties getProperties()

      Get the properties for the application that have already been loaded (see loadProperties()).

      Returns:
      the properties
    • getApplicationPropertyFileName

      protected String getApplicationPropertyFileName()

      Get the name of the property file set for the application.

      Returns:
      the property file name
    • setApplicationPropertyFileName

      protected void setApplicationPropertyFileName(String applicationPropertyFileName)

      Set the name of the property file set for the application.

      Parameters:
      applicationPropertyFileName - the property file name
    • getPropertyInsistently

      public static String getPropertyInsistently(Properties properties, String key) throws Exception

      Searches for the property with the specified key in the specified property list, insisting on a value.

      Parameters:
      properties - the property list to search
      key - the property name
      Throws:
      Exception - if there is no such property or it has no value
    • getPropertyInsistently

      public String getPropertyInsistently(String key) throws Exception

      Searches for the property with the specified key in this application's property list, insisting on a value.

      Parameters:
      key - the property name
      Throws:
      Exception - if there is no such property or it has no value
    • getPropertyOrDefaultAndAddIt

      public static String getPropertyOrDefaultAndAddIt(Properties properties, String key, String defaultValue)

      Get the value of a property from the specified property list or a default, adding it.

      Adds the default property to he specified property list if not already present.

      Parameters:
      properties - the property list to search
      key - the property name
      defaultValue - the value to use if absent
    • getPropertyOrDefaultAndAddIt

      public String getPropertyOrDefaultAndAddIt(String key, String defaultValue)

      Get the value of a property from this application's property list or a default, adding it.

      Adds the default property to this application's property list if not already present.

      Parameters:
      key - the property name
      defaultValue - the value to use if absent
    • getBooleanPropertyOrDefaultAndAddIt

      public static boolean getBooleanPropertyOrDefaultAndAddIt(Properties properties, String key, boolean defaultValue)

      Get the value of a boolean property from the specified property list or a default, adding it.

      Adds the default property to he specified property list if not already present.

      Parameters:
      properties - the property list to search
      key - the property name
      defaultValue - the value to use if absent
    • getBooleanPropertyOrDefaultAndAddIt

      public boolean getBooleanPropertyOrDefaultAndAddIt(String key, boolean defaultValue)

      Get the value of a boolean property from this application's property list or a default, adding it.

      Adds the default property to this application's property list if not already present.

      Parameters:
      key - the property name
      defaultValue - the value to use if absent
    • getIntegerPropertyOrDefaultAndAddIt

      public static int getIntegerPropertyOrDefaultAndAddIt(Properties properties, String key, int defaultValue)

      Get the value of an integer property from the specified property list or a default, adding it.

      Adds the default property to he specified property list if not already present.

      Parameters:
      properties - the property list to search
      key - the property name
      defaultValue - the value to use if absent
    • getIntegerPropertyOrDefaultAndAddIt

      public int getIntegerPropertyOrDefaultAndAddIt(String key, int defaultValue)

      Get the value of an integer property from this application's property list or a default, adding it.

      Adds the default property to this application's property list if not already present.

      Parameters:
      key - the property name
      defaultValue - the value to use if absent
    • takeSnapShot

      protected File takeSnapShot(Rectangle extent)

      Store a JPEG snapshot of the specified window in the user's home directory.

      Parameters:
      extent - the rectangle to take a snapshot of (typically this.getBounds() for whole application)
    • setInternationalizedFontsForGUI

      public static void setInternationalizedFontsForGUI()

      Setup internationalized fonts if possible.

      Invoked by createGUI().

    • setBackgroundForGUI

      public static void setBackgroundForGUI()

      Setup background for UI.

      Invoked by createGUI().

    • setPreferredLookAndFeelForPlatform

      public static void setPreferredLookAndFeelForPlatform()

      Setup preferred Look and Feel.

      Invoked by createGUI().

    • createGUI

      protected void createGUI()

      Do what is necessary to build an application window.

      Invoked by constructors.

      Sub-classes should call this if they do not use the super() constructors, but should NOT usually need to override it, but rather should override the methods that it calls.

    • main

      public static void main(String[] arg)

      For testing.

      Shows an empty default sized window.

      Parameters:
      arg - ignored