Interface ProgressWorkerDialogBuilder<T,V>

Type Parameters:
T - the type of result this ProgressWorker produces.
V - the type of intermediate result this ProgressWorker produces.
All Superinterfaces:
DialogBuilder<ProgressWorkerDialogBuilder<T,V>>

public interface ProgressWorkerDialogBuilder<T,V> extends DialogBuilder<ProgressWorkerDialogBuilder<T,V>>
A builder for a ProgressWorker implementation which displays a progress bar in a modal dialog while background work is being performed. The progress bar can be of type 'indeterminate' or with the progress ranging from 0 to 100.

By default, the progress dialog uses a delayed show/hide mechanism to prevent flickering for fast operations:

  • The dialog is only shown if the operation takes longer than SHOW_DELAY milliseconds (default: 350ms)
  • If shown, the dialog remains visible for at least HIDE_DELAY milliseconds (default: 800ms)
These delays can be customized via delay(int, int) or the system properties.
See Also:
  • Field Details

    • SHOW_DELAY

      static final PropertyValue<Integer> SHOW_DELAY
      Specifies the delay in milliseconds before showing a progress dialog. Progress dialogs are only shown if the operation takes longer than this delay, preventing dialog flicker for fast operations.
      • Value type: Integer
      • Default value: 350
      See Also:
    • HIDE_DELAY

      static final PropertyValue<Integer> HIDE_DELAY
      Specifies the minimum duration in milliseconds that a progress dialog should remain visible. If a progress dialog is shown, it will remain visible for at least this duration even if the operation completes faster, preventing dialog flicker.
      • Value type: Integer
      • Default value: 800
      See Also:
  • Method Details

    • indeterminate

      ProgressWorkerDialogBuilder<T,V> indeterminate(boolean indeterminate)
      Parameters:
      indeterminate - true if the progress bar should be indeterminate
      Returns:
      this Builder instance
    • maximum

      ProgressWorkerDialogBuilder<T,V> maximum(int maximum)
      Note that calling this method renders the progress bar determinate
      Parameters:
      maximum - the maximum progress, 100 by default
      Returns:
      this Builder instance
      See Also:
    • stringPainted

      ProgressWorkerDialogBuilder<T,V> stringPainted(boolean stringPainted)
      Parameters:
      stringPainted - the string painted status of the progress bar
      Returns:
      this Builder instance
    • border

      Parameters:
      border - the border to add around the progress bar
      Returns:
      this Builder instance
    • northComponent

      ProgressWorkerDialogBuilder<T,V> northComponent(@Nullable JComponent northComponent)
      Parameters:
      northComponent - if specified this component will be added to the BorderLayout.NORTH position of the dialog
      Returns:
      this Builder instance
    • westComponent

      ProgressWorkerDialogBuilder<T,V> westComponent(@Nullable JComponent westComponent)
      Parameters:
      westComponent - if specified this component will be added to the BorderLayout.WEST position of the dialog
      Returns:
      this Builder instance
    • eastComponent

      ProgressWorkerDialogBuilder<T,V> eastComponent(@Nullable JComponent eastComponent)
      Parameters:
      eastComponent - if specified this component will be added to the BorderLayout.EAST position of the dialog
      Returns:
      this Builder instance
    • control

      ProgressWorkerDialogBuilder<T,V> control(Supplier<? extends Control> control)
      Parameters:
      control - the control to be added to the dialog as a button
      Returns:
      this Builder instance
    • control

      Parameters:
      control - this control will be added to the dialog as a button
      Returns:
      this Builder instance
    • progressBarSize

      ProgressWorkerDialogBuilder<T,V> progressBarSize(@Nullable Dimension progressBarSize)
      Parameters:
      progressBarSize - the size of the progress bar
      Returns:
      this Builder instance
    • delay

      ProgressWorkerDialogBuilder<T,V> delay(int show, int hide)
      Configures dialog delay settings to prevent flicker for fast operations. The dialog will only be shown if the operation takes longer than show milliseconds. If the dialog is shown, it will remain visible for at least hide milliseconds even if the operation completes faster.

      Setting the show delay to 0 guarantees that the dialog is shown for at least hide milliseconds.

      Parameters:
      show - the delay in milliseconds before showing the dialog
      hide - the minimum duration in milliseconds to keep the dialog visible once shown
      Returns:
      this Builder instance
      See Also:
    • onPublish

      ProgressWorkerDialogBuilder<T,V> onPublish(Consumer<List<V>> onPublish)
      Parameters:
      onPublish - called on the Event Dispatch Thread when chunks are available for publishing
      Returns:
      this builder instance
    • onResult

      ProgressWorkerDialogBuilder<T,V> onResult(Runnable onResult)
      Parameters:
      onResult - executed on the Event Dispatch Thread after a successful run
      Returns:
      this Builder instance
    • onResult

      ProgressWorkerDialogBuilder<T,V> onResult(Consumer<T> onResult)
      Parameters:
      onResult - executed on the Event Dispatch Thread after a successful run
      Returns:
      this Builder instance
    • onResult

      ProgressWorkerDialogBuilder<T,V> onResult(String title, String message)
      Parameters:
      title - the dialog title
      message - if specified then this message is displayed after the task has successfully run
      Returns:
      this Builder instance
    • onException

      ProgressWorkerDialogBuilder<T,V> onException(Consumer<Exception> onException)
      Parameters:
      onException - the exception handler
      Returns:
      this Builder instance
    • onException

      ProgressWorkerDialogBuilder<T,V> onException(String exceptionTitle)
      Parameters:
      exceptionTitle - the title of the exception dialog
      Returns:
      this Builder instance
    • execute

      ProgressWorker<T,V> execute()
      Builds and executes a new ProgressWorker based on this builder
      Returns:
      a ProgressWorker based on this builder
    • build

      ProgressWorker<T,V> build()
      Returns:
      a ProgressWorker based on this builder