Package hu.akarnokd.rxjava3.swing
Class SwingObservable
- java.lang.Object
-
- hu.akarnokd.rxjava3.swing.SwingObservable
-
public final class SwingObservable extends java.lang.ObjectMethods to wrap various Swing event sources.
-
-
Field Summary
Fields Modifier and Type Field Description static intMOUSE_ALLstatic intMOUSE_CLICKFlag constant formouse(Component, int)indicating only theMouseListenerevents should be forwarded.static intMOUSE_MOVEFlag constant formouse(Component, int)indicating only theMouseMotionListenerevents should be forwarded.static intMOUSE_WHEELFlag constant formouse(Component, int)indicating only theMouseWheelListenerevents should be forwarded.static intWINDOW_ACTIVEFlag constant for thewindow(Window, int)indicating only theWindowListenerevents should be forwarded.static intWINDOW_ALLstatic intWINDOW_FOCUSFlag constant for thewindow(Window, int)indicating only theWindowFocusListenerevents should be forwarded.static intWINDOW_STATEFlag constant for thewindow(Window, int)indicating only theWindowStateListenerevents should be forwarded.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static @NonNull Observable<java.awt.event.ActionEvent>actions(@NonNull javax.swing.AbstractButton button)static @NonNull Observable<java.awt.event.ActionEvent>actions(@NonNull javax.swing.JComboBox<?> button)static @NonNull Observable<javax.swing.event.AncestorEvent>ancestor(@NonNull javax.swing.JComponent component)static @NonNull Observable<javax.swing.event.CaretEvent>caret(@NonNull javax.swing.text.JTextComponent component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.AbstractButton component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.BoundedRangeModel component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.ButtonModel component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.colorchooser.ColorSelectionModel component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.JProgressBar component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.JSlider component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.JSpinner component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.JTabbedPane component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.JViewport component)static @NonNull Observable<javax.swing.event.ChangeEvent>change(@NonNull javax.swing.SpinnerModel component)static @NonNull Observable<java.awt.event.ComponentEvent>component(@NonNull java.awt.Component component)static @NonNull Observable<java.awt.event.ContainerEvent>container(@NonNull java.awt.Container component)static @NonNull Observable<javax.swing.event.DocumentEvent>document(@NonNull javax.swing.text.Document component)static @NonNull Observable<javax.swing.event.DocumentEvent>document(@NonNull javax.swing.text.JTextComponent component)static @NonNull Observable<java.awt.event.FocusEvent>focus(@NonNull java.awt.Component component)static @NonNull Observable<java.awt.event.HierarchyEvent>hierarchy(@NonNull java.awt.Component component)static @NonNull Observable<java.awt.event.HierarchyEvent>hierarchyBounds(@NonNull java.awt.Component component)static @NonNull Observable<javax.swing.event.HyperlinkEvent>hyperlink(@NonNull javax.swing.JEditorPane component)static @NonNull Observable<java.awt.event.InputMethodEvent>inputMethod(@NonNull java.awt.Component component)static @NonNull Observable<javax.swing.event.InternalFrameEvent>internalFrame(@NonNull javax.swing.JInternalFrame component)static @NonNull Observable<java.awt.event.ItemEvent>itemSelection(@NonNull java.awt.ItemSelectable component)static @NonNull Observable<java.awt.event.KeyEvent>keyboard(@NonNull java.awt.Component component)static @NonNull Observable<javax.swing.event.ListDataEvent>listChange(@NonNull javax.swing.JList<?> component)static @NonNull Observable<javax.swing.event.ListDataEvent>listChange(@NonNull javax.swing.ListModel<?> component)static @NonNull Observable<javax.swing.event.ListSelectionEvent>listSelection(@NonNull javax.swing.JList<?> component)static @NonNull Observable<javax.swing.event.ListSelectionEvent>listSelection(@NonNull javax.swing.ListSelectionModel component)static @NonNull Observable<javax.swing.event.MenuEvent>menu(@NonNull javax.swing.JMenu component)static @NonNull Observable<javax.swing.event.MenuDragMouseEvent>menuDrag(@NonNull javax.swing.JMenuItem component)static @NonNull Observable<javax.swing.event.MenuKeyEvent>menuKey(@NonNull javax.swing.JMenuItem component)static @NonNull Observable<javax.swing.event.MenuKeyEvent>menuKey(@NonNull javax.swing.JPopupMenu component)static @NonNull Observable<java.awt.event.MouseEvent>mouse(@NonNull java.awt.Component component)static @NonNull Observable<java.awt.event.MouseEvent>mouse(@NonNull java.awt.Component component, int flags)static @NonNull Observable<java.awt.event.MouseWheelEvent>mouseWheel(@NonNull java.awt.Component component)static <T> @NonNull ObservableTransformer<T,T>observeOnEdt()Sends the observed upstream event directly to the Event Dispatch thread individually (unlike observeOn which may occupy the EDT longer with a fast emitting source).static @NonNull Observable<javax.swing.event.PopupMenuEvent>popupMenu(@NonNull javax.swing.JComboBox<?> component)static @NonNull Observable<javax.swing.event.PopupMenuEvent>popupMenu(@NonNull javax.swing.JPopupMenu component)static @NonNull Observable<java.beans.PropertyChangeEvent>propertyChange(@NonNull java.awt.Component component)static @NonNull Observable<java.beans.PropertyChangeEvent>propertyChange(@NonNull java.awt.Component component, java.lang.String propertyName)static @NonNull Observable<javax.swing.event.RowSorterEvent>rowSorter(@NonNull javax.swing.JTable component)static @NonNull Observable<javax.swing.event.RowSorterEvent>rowSorter(@NonNull javax.swing.RowSorter<?> component)static @NonNull Observable<javax.swing.event.ChangeEvent>tableColumnMarginChange(@NonNull javax.swing.table.TableColumnModel component)static @NonNull Observable<javax.swing.event.TableColumnModelEvent>tableColumnModel(@NonNull javax.swing.JTable component)static @NonNull Observable<javax.swing.event.TableColumnModelEvent>tableColumnModel(@NonNull javax.swing.table.TableColumnModel component)static @NonNull Observable<javax.swing.event.ListSelectionEvent>tableColumnSelectionChange(@NonNull javax.swing.table.TableColumnModel component)static @NonNull Observable<javax.swing.event.TableModelEvent>tableModel(@NonNull javax.swing.JTable component)static @NonNull Observable<javax.swing.event.TableModelEvent>tableModel(@NonNull javax.swing.table.TableModel component)static @NonNull Observable<javax.swing.event.TreeExpansionEvent>treeExpansion(@NonNull javax.swing.JTree component)static @NonNull Observable<javax.swing.event.TreeModelEvent>treeModel(@NonNull javax.swing.JTree component)static @NonNull Observable<javax.swing.event.TreeModelEvent>treeModel(@NonNull javax.swing.tree.TreeModel component)static @NonNull Observable<javax.swing.event.TreeSelectionEvent>treeSelection(@NonNull javax.swing.JTree component)static @NonNull Observable<javax.swing.event.TreeSelectionEvent>treeSelection(@NonNull javax.swing.tree.TreeSelectionModel component)static @NonNull Observable<javax.swing.event.TreeExpansionEvent>treeWillExpand(@NonNull javax.swing.JTree component)static @NonNull Observable<javax.swing.event.UndoableEditEvent>undoableEdit(@NonNull javax.swing.text.Document component)static @NonNull Observable<javax.swing.event.UndoableEditEvent>undoableEdit(@NonNull javax.swing.text.JTextComponent component)static @NonNull Observable<VetoablePropertyChangeEvent>vetoableChange(@NonNull javax.swing.JComponent component)static @NonNull Observable<java.awt.event.WindowEvent>window(@NonNull java.awt.Window component)static @NonNull Observable<java.awt.event.WindowEvent>window(@NonNull java.awt.Window component, int flags)
-
-
-
Field Detail
-
MOUSE_CLICK
public static final int MOUSE_CLICK
Flag constant formouse(Component, int)indicating only theMouseListenerevents should be forwarded.- See Also:
- Constant Field Values
-
MOUSE_MOVE
public static final int MOUSE_MOVE
Flag constant formouse(Component, int)indicating only theMouseMotionListenerevents should be forwarded.- See Also:
- Constant Field Values
-
MOUSE_WHEEL
public static final int MOUSE_WHEEL
Flag constant formouse(Component, int)indicating only theMouseWheelListenerevents should be forwarded.Note that the
MouseWheelEventextendsMouseEventand the consumer should check and cast back the stream ofMouseEvent.- See Also:
- Constant Field Values
-
MOUSE_ALL
public static final int MOUSE_ALL
- See Also:
- Constant Field Values
-
WINDOW_ACTIVE
public static final int WINDOW_ACTIVE
Flag constant for thewindow(Window, int)indicating only theWindowListenerevents should be forwarded.- See Also:
- Constant Field Values
-
WINDOW_FOCUS
public static final int WINDOW_FOCUS
Flag constant for thewindow(Window, int)indicating only theWindowFocusListenerevents should be forwarded.- See Also:
- Constant Field Values
-
WINDOW_STATE
public static final int WINDOW_STATE
Flag constant for thewindow(Window, int)indicating only theWindowStateListenerevents should be forwarded.- See Also:
- Constant Field Values
-
WINDOW_ALL
public static final int WINDOW_ALL
- See Also:
- Constant Field Values
-
-
Method Detail
-
actions
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.ActionEvent> actions(@NonNull @NonNull javax.swing.AbstractButton button)
-
actions
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.ActionEvent> actions(@NonNull @NonNull javax.swing.JComboBox<?> button)
-
mouse
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.MouseEvent> mouse(@NonNull @NonNull java.awt.Component component)
-
mouse
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.MouseEvent> mouse(@NonNull @NonNull java.awt.Component component, int flags)
-
mouseWheel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.MouseWheelEvent> mouseWheel(@NonNull @NonNull java.awt.Component component)
-
keyboard
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.KeyEvent> keyboard(@NonNull @NonNull java.awt.Component component)
-
component
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.ComponentEvent> component(@NonNull @NonNull java.awt.Component component)
-
focus
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.FocusEvent> focus(@NonNull @NonNull java.awt.Component component)
-
hierarchyBounds
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.HierarchyEvent> hierarchyBounds(@NonNull @NonNull java.awt.Component component)
-
hierarchy
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.HierarchyEvent> hierarchy(@NonNull @NonNull java.awt.Component component)
-
inputMethod
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.InputMethodEvent> inputMethod(@NonNull @NonNull java.awt.Component component)
-
propertyChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.beans.PropertyChangeEvent> propertyChange(@NonNull @NonNull java.awt.Component component)
-
propertyChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.beans.PropertyChangeEvent> propertyChange(@NonNull @NonNull java.awt.Component component, java.lang.String propertyName)
-
document
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.DocumentEvent> document(@NonNull @NonNull javax.swing.text.Document component)
-
document
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.DocumentEvent> document(@NonNull @NonNull javax.swing.text.JTextComponent component)
-
undoableEdit
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.UndoableEditEvent> undoableEdit(@NonNull @NonNull javax.swing.text.Document component)
-
undoableEdit
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.UndoableEditEvent> undoableEdit(@NonNull @NonNull javax.swing.text.JTextComponent component)
-
caret
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.CaretEvent> caret(@NonNull @NonNull javax.swing.text.JTextComponent component)
-
ancestor
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.AncestorEvent> ancestor(@NonNull @NonNull javax.swing.JComponent component)
-
vetoableChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<VetoablePropertyChangeEvent> vetoableChange(@NonNull @NonNull javax.swing.JComponent component)
-
container
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.ContainerEvent> container(@NonNull @NonNull java.awt.Container component)
-
listSelection
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ListSelectionEvent> listSelection(@NonNull @NonNull javax.swing.JList<?> component)
-
listSelection
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ListSelectionEvent> listSelection(@NonNull @NonNull javax.swing.ListSelectionModel component)
-
hyperlink
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.HyperlinkEvent> hyperlink(@NonNull @NonNull javax.swing.JEditorPane component)
-
internalFrame
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.InternalFrameEvent> internalFrame(@NonNull @NonNull javax.swing.JInternalFrame component)
-
listChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ListDataEvent> listChange(@NonNull @NonNull javax.swing.ListModel<?> component)
-
listChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ListDataEvent> listChange(@NonNull @NonNull javax.swing.JList<?> component)
-
menuDrag
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.MenuDragMouseEvent> menuDrag(@NonNull @NonNull javax.swing.JMenuItem component)
-
menu
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.MenuEvent> menu(@NonNull @NonNull javax.swing.JMenu component)
-
menuKey
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.MenuKeyEvent> menuKey(@NonNull @NonNull javax.swing.JMenuItem component)
-
menuKey
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.MenuKeyEvent> menuKey(@NonNull @NonNull javax.swing.JPopupMenu component)
-
popupMenu
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.PopupMenuEvent> popupMenu(@NonNull @NonNull javax.swing.JComboBox<?> component)
-
popupMenu
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.PopupMenuEvent> popupMenu(@NonNull @NonNull javax.swing.JPopupMenu component)
-
rowSorter
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.RowSorterEvent> rowSorter(@NonNull @NonNull javax.swing.RowSorter<?> component)
-
rowSorter
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.RowSorterEvent> rowSorter(@NonNull @NonNull javax.swing.JTable component)
-
tableModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TableModelEvent> tableModel(@NonNull @NonNull javax.swing.table.TableModel component)
-
tableModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TableModelEvent> tableModel(@NonNull @NonNull javax.swing.JTable component)
-
tableColumnModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TableColumnModelEvent> tableColumnModel(@NonNull @NonNull javax.swing.table.TableColumnModel component)
-
tableColumnMarginChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> tableColumnMarginChange(@NonNull @NonNull javax.swing.table.TableColumnModel component)
-
tableColumnSelectionChange
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ListSelectionEvent> tableColumnSelectionChange(@NonNull @NonNull javax.swing.table.TableColumnModel component)
-
tableColumnModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TableColumnModelEvent> tableColumnModel(@NonNull @NonNull javax.swing.JTable component)
-
treeExpansion
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeExpansionEvent> treeExpansion(@NonNull @NonNull javax.swing.JTree component)
-
treeModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeModelEvent> treeModel(@NonNull @NonNull javax.swing.tree.TreeModel component)
-
treeModel
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeModelEvent> treeModel(@NonNull @NonNull javax.swing.JTree component)
-
treeSelection
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeSelectionEvent> treeSelection(@NonNull @NonNull javax.swing.tree.TreeSelectionModel component)
-
treeSelection
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeSelectionEvent> treeSelection(@NonNull @NonNull javax.swing.JTree component)
-
treeWillExpand
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.TreeExpansionEvent> treeWillExpand(@NonNull @NonNull javax.swing.JTree component)
-
observeOnEdt
@CheckReturnValue @NonNull public static <T> @NonNull ObservableTransformer<T,T> observeOnEdt()
Sends the observed upstream event directly to the Event Dispatch thread individually (unlike observeOn which may occupy the EDT longer with a fast emitting source).To be used with
Observable.compose(ObservableTransformer).This custom observeOn should allow more interleaving with other EDT-submitted tasks and not occupy the EDT for too long.
Example:
Observable.range(1, 5) .compose(SwingObservable.observeOnEdt()) .subscribe(System.out::println);- Scheduler:
- The operator doesn't run on any scheduler as it directly submits work to the EDT
via
EventQueue.invokeLater().
- Type Parameters:
T- the value type- Returns:
- the new ObservableTransformer.
- Since:
- 0.1.1
-
itemSelection
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.ItemEvent> itemSelection(@NonNull @NonNull java.awt.ItemSelectable component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.JTabbedPane component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.JSlider component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.JSpinner component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.SpinnerModel component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.AbstractButton component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.ButtonModel component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.JViewport component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.colorchooser.ColorSelectionModel component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.JProgressBar component)
-
change
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<javax.swing.event.ChangeEvent> change(@NonNull @NonNull javax.swing.BoundedRangeModel component)
-
window
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.WindowEvent> window(@NonNull @NonNull java.awt.Window component)
-
window
@CheckReturnValue @NonNull @SchedulerSupport("none") public static @NonNull Observable<java.awt.event.WindowEvent> window(@NonNull @NonNull java.awt.Window component, int flags)
-
-