Class SJProgressBar
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.progressbar.ProgressBar
com.vaadin.swingbridge.surrogates.SJProgressBar
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, com.vaadin.flow.component.shared.HasThemeVariant<com.vaadin.flow.component.progressbar.ProgressBarVariant>, ComponentMixin, ContainerMixin, JComponentMixin, Serializable
public class SJProgressBar
extends com.vaadin.flow.component.progressbar.ProgressBar
implements JComponentMixin
Surrogate for
Vaadin
JProgressBar.
Extends Vaadin ProgressBar directly (is-a) so it reaches the
migrator either through the :emulators JProgressBar
as peer, or as a richer-than-stock Vaadin component in its own right.
Model flow (SJSlider precedent)
The installedBoundedRangeModel is the source of truth. A
single ChangeListener on the model fans out to user
ChangeListeners and pushes value changes to the peer (this
ProgressBar's own element). Unlike SJSlider, Vaadin ProgressBar is
display-only — the browser can't drag a progress bar back, so there
is no peer-originated value-change to mirror, no R_callswing_envelope
SHelper.callSwing wrapping, and no preventPeerEvents
feedback-loop guard (the loop it defends against can't physically
happen).
VERTICAL: drop-and-WARN (R_vaadin_first)
VERTICAL is field-stored and the PCE fires, but the visual
stays horizontal. CSS transform: rotate(-90deg) was tried
first (SJSlider precedent) and rejected: a transform only rotates
the element's visual; its layout box keeps its pre-rotation
dimensions, so dropping a rotated ProgressBar into any non-fixed-size
container (BorderLayout.WEST, BoxLayout column, …) collapses it to
zero width because Vaadin ProgressBar has no intrinsic width — it
relies on its parent to stretch it. Making VERTICAL truly work needs
either a wrapper element with explicitly-sized rotated dimensions
(incompatible with surrogate is-a-ProgressBar — user code calls
Component.getElement() and expects the bar itself) or a shadow-DOM-aware
rewrite of Vaadin's internal width: calc(progress * 100%)
fill machinery. Neither is JLawyer-needed; revisit if a migration
target surfaces a real VERTICAL JProgressBar.
setString / setStringPainted via CSS overlay
Vaadin <vaadin-progress-bar> has no per-bar text slot. We
render the user-set string (or the JDK percent default) through a
::after pseudo-element reading a data-emul-progress-string
attribute on the host. The CSS rule is injected once per UI via
ensureProgressStringStyleInjected(UI); SJProgressBar just
toggles the attribute. Centered text crossing the fill boundary may
have low contrast on the filled half — accepted R_layouts_close_enough close-enough,
refined if a real-app migration target complains.
Threading
UI-thread-confined, with one exception: the installedBoundedRangeModel may be
mutated from any thread. A worker reporting progress hops onto this bar's UI thread for
each model change and blocks until the fan-out has run, so the peer write and every
ChangeListener run on the UI thread; while the bar is detached, inline on the worker
(SD_background_model_hop):
SJProgressBar bar = new SJProgressBar(0, files.size());
layout.add(bar);
executor.submit(() -> {
for (int i = 0; i < files.size(); i++) {
importFile(files.get(i));
bar.getModel().setValue(i + 1);
}
});
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface JComponentMixin
JComponentMixin.ActionStandin -
Field Summary
Fields inherited from interface JComponentMixin
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW -
Constructor Summary
ConstructorsConstructorDescriptionSJProgressBar(int orientation) SJProgressBar(int min, int max) SJProgressBar(int orientation, int min, int max) -
Method Summary
Modifier and TypeMethodDescriptionvoidprotected ChangeListenerJDK hook for subclasses that want to swap the model-attached listener.protected voidintintgetModel()intdoubleFraction in[0.0, 1.0]indicating model progress.The string to render whenisStringPainted()is true.JDK JProgressBar returns"ProgressBarUI".booleanbooleanvoidvoidsetBorderPainted(boolean b) voidsetIndeterminate(boolean indeterminate) voidsetMaximum(int maximum) Fires no"maximum"property change — seesetMinimum(int)(SD_property_fanout_audit).voidsetMinimum(int minimum) Fires no"minimum"property change: the JDK'sJProgressBar.setMinimumisgetModel().setMinimum(n)and the notification is the model'sChangeEvent(SD_property_fanout_audit).voidsetModel(BoundedRangeModel newModel) Fires no"model"property change.voidsetOrientation(int orientation) voidvoidsetStringPainted(boolean b) voidsetValue(int n) Methods inherited from class com.vaadin.flow.component.progressbar.ProgressBar
bindMax, bindMin, bindValue, getMax, getMin, getValue, isIndeterminate, setMax, setMin, setValueMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttachedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface ComponentMixin
_installSwingClass, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, dispatchEvent, doLayout, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getComponentListeners, getCursor, getFocusListeners, getFont, getForeground, getGraphics, getHierarchyBoundsListeners, getHierarchyListeners, getKeyListeners, getLocation, getMaximumSize, getMinimumSize, getMouseListeners, getName, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolTipText, getX, getY, grabFocus, hasFocus, invalidate, isDisplayable, isFocusable, isFocusOwner, isShowing, paint, paintAll, print, printAll, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, revalidate, setBackground, setBounds, setBounds, setCursor, setFocusable, setFont, setForeground, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validateMethods inherited from interface ContainerMixin
addContainerListener, getContainerListeners, getLayout, paintComponents, printComponents, removeContainerListener, setLayoutMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabledMethods inherited from interface com.vaadin.flow.component.HasSize
bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.HasTheme
addThemeName, addThemeNames, bindThemeName, bindThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeNameMethods inherited from interface com.vaadin.flow.component.shared.HasThemeVariant
addThemeVariants, bindThemeVariant, bindThemeVariants, removeThemeVariants, setThemeVariant, setThemeVariants, setThemeVariantsMethods inherited from interface JComponentMixin
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, isDoubleBuffered, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, requestDefaultFocus, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, unregisterKeyboardAction, updateUI
-
Constructor Details
-
SJProgressBar
public SJProgressBar() -
SJProgressBar
public SJProgressBar(int orientation) -
SJProgressBar
public SJProgressBar(int min, int max) -
SJProgressBar
public SJProgressBar(int orientation, int min, int max) -
SJProgressBar
-
-
Method Details
-
setValue
public void setValue(int n) -
getMinimum
public int getMinimum() -
setMinimum
public void setMinimum(int minimum) Fires no"minimum"property change: the JDK'sJProgressBar.setMinimumisgetModel().setMinimum(n)and the notification is the model'sChangeEvent(SD_property_fanout_audit). ContrastJSlider, whose ownsetMinimumdoes fire. -
getMaximum
public int getMaximum() -
setMaximum
public void setMaximum(int maximum) Fires no"maximum"property change — seesetMinimum(int)(SD_property_fanout_audit). -
getModel
-
setModel
Fires no"model"property change.JProgressBaris the exception in its family:AbstractButton,JSlider,JTable,JList,JTree,JComboBoxandJSpinnerall fire"model", butJProgressBar.setModelfires onlyAccessibleContext.ACCESSIBLE_VALUE_PROPERTY— on the accessible context's own listener list, whichaddPropertyChangeListenerhere never reaches (SD_property_fanout_audit). -
getPercentComplete
public double getPercentComplete()Fraction in[0.0, 1.0]indicating model progress. A span of zero (max == min) reads as zero, so the overlay shows0%; the JDK answersNaNthere. -
setIndeterminate
public void setIndeterminate(boolean indeterminate) - Overrides:
setIndeterminatein classcom.vaadin.flow.component.progressbar.ProgressBar
-
getOrientation
public int getOrientation() -
setOrientation
public void setOrientation(int orientation) -
isStringPainted
public boolean isStringPainted() -
setStringPainted
public void setStringPainted(boolean b) -
getString
The string to render whenisStringPainted()is true. Defaults to the JDK percent format ("33%") when no string is set — mirrorsJProgressBar.getStringwhich composes the locale-aware percent viaNumberFormat.getPercentInstance(). -
setString
-
isBorderPainted
public boolean isBorderPainted() -
setBorderPainted
public void setBorderPainted(boolean b) -
addChangeListener
-
removeChangeListener
-
getChangeListeners
-
fireStateChanged
protected void fireStateChanged() -
createChangeListener
JDK hook for subclasses that want to swap the model-attached listener. Mirrors SJSlider's same-named hook — modelListener is created directly in installModel; an override wouldn't reach our code path today, but a migrated subclass callingsuper.createChangeListener()gets the real listener. -
getUIClassID
JDK JProgressBar returns"ProgressBarUI". We don't drive a pluggableComponentUI(R_layouts_close_enough — Vaadin owns the DOM), but keep the ID so migrated code that introspects via BeanInfo still finds the expected value.- Specified by:
getUIClassIDin interfaceJComponentMixin
-