Class DelayedComponentLoaderPanel

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
com.gargoylesoftware.base.gui.DelayedComponentLoaderPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable

public class DelayedComponentLoaderPanel extends JComponent
A panel that supports delayed loading of its contents. This is useful when the component that will fill this panel will take a long time to load. A "please wait" message will be displayed while the component is being loaded. When loading is complete, the new component will be made a child of this panel so that it can become visible.

The following sample will create a delayed loader with a default "please wait" message.

 final DelayedComponentLoaderPanel panel = new DelayedComponentLoaderPanel();
 panel.setComponentLoader( new DefaultComponentLoader(MyExpensiveComponent.class) );
 
This sample has a custom message.
 final JLabel label = new JLabel("My custom wait message");
 final DelayedComponentLoaderPanel panel = new DelayedComponentLoaderPanel(label);
 panel.setComponentLoader( new DefaultComponentLoader(MyExpensiveComponent.class) );
 
Version:
$Revision: 1.6 $
See Also:
  • Field Details

  • Constructor Details

    • DelayedComponentLoaderPanel

      public DelayedComponentLoaderPanel()
      Create a new panel that will display a simple "please wait" message when it is loading.
    • DelayedComponentLoaderPanel

      public DelayedComponentLoaderPanel(Component waitingComponent)
      Create a new panel that will display the specified waitingComponent while it is loading.
      Parameters:
      waitingComponent - The component to display while loading is in progress.
  • Method Details

    • setComponentLoader

      public void setComponentLoader(ComponentLoader loader)
      Set the new component loader. The waiting component will be displayed immediately and component loading will start on a background thread. If the new loader is null then no loading will take place and the waiting component will be displayed indefinitely
      Parameters:
      loader - The new component loader.
    • replaceComponent

      private void replaceComponent(Component component)
      Replace the current child with the specified component
      Parameters:
      component - The new component.
    • addDelayedComponentLoaderListener

      public void addDelayedComponentLoaderListener(DelayedComponentLoaderListener listener)
      Add the specified listener.
      Parameters:
      listener - The new listener
    • removeDelayedComponentLoaderListener

      public void removeDelayedComponentLoaderListener(DelayedComponentLoaderListener listener)
      Remove the specified listener.
      Parameters:
      listener - the listener to remove.
    • fireComponentLoadingEvent

      private void fireComponentLoadingEvent(int action, ComponentLoader loader, Component loadedComponent)
      Fire the component loading event.
      Parameters:
      action - The action id
      loader - The loader
      loadedComponent - The component that was just loaded.
    • assertNotNull

      protected final void assertNotNull(String fieldName, Object object)
      Throw an exception if the specified object is null
      Parameters:
      fieldName - The name of the paremeter we are checking
      object - The value of the parameter we are checking