Class JTableToCsvAction

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

    public class JTableToCsvAction
    extends javax.swing.AbstractAction
    Save a JTable or AbstractTableModel to CSV file after prompting for filename.

    First line contains Column Headings. Save order can replicate current JTable sort, filters, visible columns and column order. Entire Table Model can be saved by not specifying a JTable. Can exclude specific columns ( e.g. JButtons ) from the save.

    Since:
    4.19.5
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class javax.swing.AbstractAction

        changeSupport, enabled
      • Fields inherited from interface javax.swing.Action

        ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
    • Constructor Summary

      Constructors 
      Constructor Description
      JTableToCsvAction​(java.lang.String actionName, javax.swing.JTable jtable, javax.swing.table.TableModel model, java.lang.String defaultFileName, int[] excludedCols)
      Create a new Save to CSV Action.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void actionPerformed​(java.awt.event.ActionEvent e)
      • Methods inherited from class javax.swing.AbstractAction

        addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
      • Methods inherited from class java.lang.Object

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

        accept
    • Constructor Detail

      • JTableToCsvAction

        public JTableToCsvAction​(java.lang.String actionName,
                                 javax.swing.JTable jtable,
                                 @Nonnull
                                 javax.swing.table.TableModel model,
                                 @Nonnull
                                 java.lang.String defaultFileName,
                                 @Nonnull
                                 int[] excludedCols)
        Create a new Save to CSV Action.
        Parameters:
        actionName - Action Name
        jtable - to save the view, else null for whole table.
        model - Table Model to use.
        defaultFileName - File Name to use as default.
        excludedCols - int Array of Table Model columns to exclude.
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent e)