Class RowComboBoxPanel

    • Nested Class Summary

      • Nested classes/interfaces inherited from class javax.swing.DefaultCellEditor

        javax.swing.DefaultCellEditor.EditorDelegate
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.Runnable comboBoxFocusRequester
      To request the focus for the combobox (with SwingUtilities.invokeLater())
      protected boolean consumeComboBoxActionEvent
      React on action events on the combobox?
      protected int currentRow
      The current row.
      protected javax.swing.JPanel editor
      The surrounding panel for the combobox.
      protected java.lang.Object prevItem
      The previously selected value in the editor.
      protected javax.swing.JPanel renderer
      The surrounding panel for the combobox.
      protected java.util.EventObject startEditingEvent
      The event that causes the editing to start.
      protected javax.swing.JTable table
      The table.
      protected boolean tableListenerAdded
      Listeners for the table added?
      • Fields inherited from class javax.swing.DefaultCellEditor

        clickCountToStart, delegate, editorComponent
      • Fields inherited from class javax.swing.AbstractCellEditor

        changeEvent, listenerList
    • Constructor Summary

      Constructors 
      Constructor Description
      RowComboBoxPanel()  
      RowComboBoxPanel​(java.lang.Object[] values)  
      RowComboBoxPanel​(java.lang.Object[] values, javax.swing.ListCellRenderer<?> customRenderer)
      Create a new CellEditor and CellRenderer.
      RowComboBoxPanel​(javax.swing.ListCellRenderer<?> customRenderer)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void eventEditorMousePressed()
      Open combobox (Editor) when clicked.
      protected void eventRowComboBoxActionPerformed​(java.lang.Object choice)
      Method for our own VALUECOL row specific JComboBox.
      protected void eventTableSelectionChanged()
      Stop editing if a new row is selected.
      java.lang.Object getCellEditorValue()
      Get current contents (value) in cell.
      protected int getCurrentRow()  
      protected javax.swing.JComboBox<java.lang.String> getEditorBox​(int row)  
      protected java.awt.Component getEditorComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int col)
      (Re)build combobox with all allowed state values, select current and add action listener.
      protected java.awt.Component getRendererComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int col)
      (Re)build combobox with only the active state value.
      java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, int row, int col)
      Create the editor component for the cell and add a listener for changes in the table.
      java.awt.Component getTableCellRendererComponent​(javax.swing.JTable table, java.lang.Object value, boolean isSelected, boolean hasFocus, int row, int col)
      Create the renderer component for the cell and add a listener for changes in the table.
      boolean isCellEditable​(java.util.EventObject evt)
      Is the cell editable?
      void setItems​(java.lang.Object[] items)
      Put contents into the combobox.
      protected void updateData​(int row, boolean isSelected, javax.swing.JTable table)
      Refresh contents of editor.
      • Methods inherited from class javax.swing.DefaultCellEditor

        cancelCellEditing, getClickCountToStart, getComponent, getTreeCellEditorComponent, setClickCountToStart, shouldSelectCell, stopCellEditing
      • Methods inherited from class javax.swing.AbstractCellEditor

        addCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListener
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface javax.swing.CellEditor

        addCellEditorListener, removeCellEditorListener
    • Field Detail

      • editor

        protected javax.swing.JPanel editor
        The surrounding panel for the combobox.
      • renderer

        protected javax.swing.JPanel renderer
        The surrounding panel for the combobox.
      • table

        protected javax.swing.JTable table
        The table.
      • comboBoxFocusRequester

        protected java.lang.Runnable comboBoxFocusRequester
        To request the focus for the combobox (with SwingUtilities.invokeLater())
      • currentRow

        protected int currentRow
        The current row.
      • prevItem

        protected java.lang.Object prevItem
        The previously selected value in the editor.
      • startEditingEvent

        protected java.util.EventObject startEditingEvent
        The event that causes the editing to start. We need it to know if we should open the popup automatically.
    • Constructor Detail

      • RowComboBoxPanel

        public RowComboBoxPanel​(java.lang.Object[] values,
                                javax.swing.ListCellRenderer<?> customRenderer)
        Create a new CellEditor and CellRenderer.
        Parameters:
        values - array (list) of options to display
        customRenderer - renderer to display things
      • RowComboBoxPanel

        public RowComboBoxPanel​(javax.swing.ListCellRenderer<?> customRenderer)
    • Method Detail

      • getTableCellEditorComponent

        public final java.awt.Component getTableCellEditorComponent​(javax.swing.JTable table,
                                                                    java.lang.Object value,
                                                                    boolean isSelected,
                                                                    int row,
                                                                    int col)
        Create the editor component for the cell and add a listener for changes in the table.
        Specified by:
        getTableCellEditorComponent in interface javax.swing.table.TableCellEditor
        Overrides:
        getTableCellEditorComponent in class javax.swing.DefaultCellEditor
        Parameters:
        table - parent JTable of NamedBean
        value - current value for cell to be rendered.
        isSelected - tells if this row is selected in the table.
        row - the row in table.
        col - the column in table, in this case Value (Aspect or Appearance).
        Returns:
        A JPanel containing a JComboBox with valid options as the CellEditor for the Value.
      • getEditorComponent

        protected java.awt.Component getEditorComponent​(javax.swing.JTable table,
                                                        java.lang.Object value,
                                                        boolean isSelected,
                                                        int row,
                                                        int col)
        (Re)build combobox with all allowed state values, select current and add action listener.
        Parameters:
        table - parent JTable of NamedBean
        value - current value for cell to be rendered.
        isSelected - tells if this row is selected in the table.
        row - the row in table.
        col - the column in table, in this case Value (Aspect or Appearance).
        Returns:
        a JPanel containing a JComboBox
        See Also:
        getTableCellEditorComponent(JTable, Object, boolean, int, int), getEditorBox(int)
      • getTableCellRendererComponent

        public final java.awt.Component getTableCellRendererComponent​(javax.swing.JTable table,
                                                                      java.lang.Object value,
                                                                      boolean isSelected,
                                                                      boolean hasFocus,
                                                                      int row,
                                                                      int col)
        Create the renderer component for the cell and add a listener for changes in the table.
        Specified by:
        getTableCellRendererComponent in interface javax.swing.table.TableCellRenderer
        Parameters:
        table - the parent Table.
        value - current value for cell to be rendered.
        isSelected - tells if this row is selected in the table.
        hasFocus - true if the row has focus.
        row - the row in table.
        col - the column in table, in this case Value (Aspect/Appearance).
        Returns:
        A JPanel containing a JComboBox with only the current Value as the CellRenderer.
      • getRendererComponent

        protected java.awt.Component getRendererComponent​(javax.swing.JTable table,
                                                          java.lang.Object value,
                                                          boolean isSelected,
                                                          boolean hasFocus,
                                                          int row,
                                                          int col)
        (Re)build combobox with only the active state value.
        Parameters:
        table - the parent Table.
        value - current value for cell to be rendered.
        isSelected - tells if this row is selected in the table.
        hasFocus - true if the row has focus.
        row - the row in table.
        col - the column in table, in this case Value (Aspect/Appearance).
        Returns:
        a JPanel containing a JComboBox
        See Also:
        getTableCellRendererComponent(JTable, Object, boolean, boolean, int, int)
      • isCellEditable

        public boolean isCellEditable​(java.util.EventObject evt)
        Is the cell editable? If the mouse was pressed at a margin we don't want the cell to be editable.
        Specified by:
        isCellEditable in interface javax.swing.CellEditor
        Overrides:
        isCellEditable in class javax.swing.DefaultCellEditor
        Parameters:
        evt - The event-object
        Returns:
        true when user clicked inside cell, not on cell border
      • getCellEditorValue

        public java.lang.Object getCellEditorValue()
        Get current contents (value) in cell.
        Specified by:
        getCellEditorValue in interface javax.swing.CellEditor
        Overrides:
        getCellEditorValue in class javax.swing.DefaultCellEditor
        Returns:
        value (String in 4.6 applications)
      • setItems

        public final void setItems​(@Nonnull
                                   java.lang.Object[] items)
        Put contents into the combobox.
        Parameters:
        items - array (strings) of options to display
      • eventRowComboBoxActionPerformed

        protected void eventRowComboBoxActionPerformed​(@Nonnull
                                                       java.lang.Object choice)
        Method for our own VALUECOL row specific JComboBox.
        Parameters:
        choice - the selected item (Aspect/Appearance) in the combobox list
      • getEditorBox

        protected javax.swing.JComboBox<java.lang.String> getEditorBox​(int row)