Class JProgressUpdateGlassPane

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.sm.smtools.application.util.JProgressUpdateGlassPane
All Implemented Interfaces:
KeyListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class JProgressUpdateGlassPane extends JPanel implements MouseListener, MouseMotionListener, KeyListener
The JProgressUpdateGlassPane class provides the basic functionality for a progress updating glasspane.

In order to meaningfully use the progress updater, a user first has to set the total number of expected progress updates via setTotalNrOfProgressUpdates(int). Each time an update is done, the user should call signalProgressUpdate() which repaints the glasspane.

If needed, the glasspane can block the mouse and keyboard input to the GUI via the setBlocking(boolean) method. Note that the menubar can still be accessed via its defined accelerator controls.

The following visualisations are supported:

Bar:

Circles:

Sector (fixed):

Sector (rotating):

Version:
08/02/2015
Author:
Sven Maerivoet
See Also:
  • Constructor Details

    • JProgressUpdateGlassPane

      public JProgressUpdateGlassPane()
      Constructs an unblocking JProgressUpdateGlassPane object and resets it.

      A bar is used as the type of visualisation, fractions are not shown in the percentage completed.

    • JProgressUpdateGlassPane

      public JProgressUpdateGlassPane(JProgressUpdateGlassPane.EVisualisationType visualisationType, boolean showFractions)
      Constructs an unblocking JProgressUpdateGlassPane object and resets it.
      Parameters:
      visualisationType - the type of the visualisation to show
      showFractions - a boolean indicating whether or not fractions are shown in the percentage completed
  • Method Details

    • setFading

      public final void setFading(boolean fading)
      Sets whether or not fading is enabled.
      Parameters:
      fading - a boolean specifying whether fading is enabled or not
    • setShowTimeEstimation

      public final void setShowTimeEstimation(boolean showTimeEstimation)
      Sets whether or not an estimation of the time left should be shown.
      Parameters:
      showTimeEstimation - a boolean specifying whether or not an estimation of the time left should be shown
    • setVisualisationType

      public final void setVisualisationType(JProgressUpdateGlassPane.EVisualisationType visualisationType)
      Sets the visualisation type to use.
      Parameters:
      visualisationType - the type of the visualisation to use
    • getVisualisationType

      public final JProgressUpdateGlassPane.EVisualisationType getVisualisationType()
      Returns the visualisation type to use.
      Returns:
      the type of the visualisation to use
    • setShowFractions

      public final void setShowFractions(boolean showFractions)
      Sets whether or not fractions are shown in the percentage completed (not shown by default).
      Parameters:
      showFractions - a boolean indicating whether or not fractions are shown in the percentage completed
    • getShowFractions

      public final boolean getShowFractions()
      Returns whether or not fractions are shown in the percentage completed (not shown by default).
      Returns:
      a boolean indicating whether or not fractions are shown in the percentage completed
    • setMessageText

      public final void setMessageText(String messageText)
      Sets the optional message text.
      Parameters:
      messageText - the message text to show
    • reset

      public final void reset()
      Resets the progress update glasspane, by setting the percentage completed to zero and making the glasspane visible.
    • setTotalNrOfProgressUpdates

      public final void setTotalNrOfProgressUpdates(int totalNrOfProgressUpdates)
      Sets the total number of progress updates expected, corresponding to 100% completion.
      Parameters:
      totalNrOfProgressUpdates - the total number of progress updates expected
    • signalProgressUpdate

      public final void signalProgressUpdate()
      Increases the number of progress updates already completed and repaints the glasspane.
    • setPercentageCompleted

      public final void setPercentageCompleted(double percentageCompleted)
      Directly sets the percentage completed.
      Parameters:
      percentageCompleted - the percentage completed
    • getPercentageCompleted

      public final double getPercentageCompleted()
      Returns the percentage completed.
      Returns:
      the percentage completed
    • done

      public final void done()
      Resets the progress update glasspane and makes the glasspane invisible.
    • setBlocking

      public final void setBlocking(boolean blocking)
      Sets whether or not the glasspane should block all user mouse-input.
      Parameters:
      blocking - a boolean that indicates whether or not the glasspane should block all user mouse-input
    • paintComponent

      public void paintComponent(Graphics g)
      Overrides:
      paintComponent in class JComponent
    • mouseClicked

      public final void mouseClicked(MouseEvent e)
      Specified by:
      mouseClicked in interface MouseListener
    • mousePressed

      public final void mousePressed(MouseEvent e)
      Specified by:
      mousePressed in interface MouseListener
    • mouseReleased

      public final void mouseReleased(MouseEvent e)
      Specified by:
      mouseReleased in interface MouseListener
    • mouseEntered

      public final void mouseEntered(MouseEvent e)
      Specified by:
      mouseEntered in interface MouseListener
    • mouseExited

      public final void mouseExited(MouseEvent e)
      Specified by:
      mouseExited in interface MouseListener
    • mouseMoved

      public final void mouseMoved(MouseEvent e)
      Specified by:
      mouseMoved in interface MouseMotionListener
    • mouseDragged

      public final void mouseDragged(MouseEvent e)
      Specified by:
      mouseDragged in interface MouseMotionListener
    • keyPressed

      public void keyPressed(KeyEvent e)
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased

      public void keyReleased(KeyEvent e)
      Specified by:
      keyReleased in interface KeyListener
    • keyTyped

      public void keyTyped(KeyEvent e)
      Specified by:
      keyTyped in interface KeyListener