Package javax.swing.table

Examples of javax.swing.table.AbstractTableModel


  }
 
  @SuppressWarnings("serial")
  private JScrollPane createStatisticsTable() {
   
    model = new AbstractTableModel() {
     
      private String[] columnNames = { "Counter", "Value" };

      public int getRowCount() {
        return getCounters().size();       
View Full Code Here


      super(owner, resources.getString("SelectAFileFormat"),true);

      filterList = list;
      chosenIndex = -1;

      TableModel dataModel = new AbstractTableModel() {
        public String getColumnName(int columnIndex) {return resources.getString("AvailableFilters");}
        public int getColumnCount() { return 1; }
        public int getRowCount() { return (filterList==null) ? 0 : filterList.size();}
        public Object getValueAt(int row, int col) { return ((FileFilter)filterList.get(row)).getDescription(); }
      };
View Full Code Here

   *
   */
  public NameFormatterTab(HelpDialog helpDialog) {
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {
      public int getRowCount() {
        return rowCount;
      }

      public int getColumnCount() {
View Full Code Here

    public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
        _prefs = prefs;
        this.frame = frame;
        setLayout(new BorderLayout());

        TableModel tm = new AbstractTableModel() {
                public int getRowCount() { return rowCount; }
                public int getColumnCount() { return 2; }
                public Object getValueAt(int row, int column) {
                  if (row == 0)
                    return (column==0 ? GUIGlobals.NUMBER_COL : ""+ncWidth);
View Full Code Here

   * Customization of external program paths.
   */
  public XmpPrefsTab() {
    setLayout(new BorderLayout());

    TableModel tm = new AbstractTableModel() {
      public int getRowCount() {
        return rowCount;
      }

      public int getColumnCount() {
View Full Code Here

            myTreeView = treeView;
        }

        public void optionsChanged() {
            myTreeView.getTable().setRowHeight(myGanttViewModel.setRowHeight());
            AbstractTableModel model = (AbstractTableModel) myTreeView.getTable().getModel();
            model.fireTableStructureChanged();
            myTreeView.updateUI();
        }
View Full Code Here

  private JComponent createTab( final int id )
  {
    final JPanel        tab;
    final LayoutManager      lay;
    final JTable        table;
    final AbstractTableModel  tm;
    final SortedTableModel    stm;
    final JTableHeader      th;
    final TableCellRenderer    tcr;
    final JScrollPane      scroll;
    final JTextArea        lbTextArea;
    final Box          b;
    final AbstractButton    ggPlus, ggMinus;

    tab      = new JPanel();
    lay      = new BorderLayout();
    tab.setLayout( lay );
   
    lbTextArea  = new JTextArea( getResourceString( KEY_INFOTEXT[ id ]));
    lbTextArea.setEditable( false );
    lbTextArea.setBackground( null );
    lbTextArea.setColumns( 32 );
    lbTextArea.setLineWrap( true );
    lbTextArea.setWrapStyleWord( true );
    tab.add( lbTextArea, BorderLayout.NORTH );
    lbTextArea.setBorder( BorderFactory.createEmptyBorder( 8, 2, 8, 2 ));
   
    tm      = new TableModel( id );
    stm      = new SortedTableModel( tm );
    table    = new JTable( stm );
    th      = table.getTableHeader();
    stm.setTableHeader( th );
    th.setReorderingAllowed( false );
    th.setResizingAllowed( true );
    table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
    table.setCellSelectionEnabled( true );
    table.setColumnSelectionAllowed( false );
    table.setDragEnabled( true );
    table.setShowGrid( true );
    table.setGridColor( Color.lightGray );
    table.setSelectionMode( ListSelectionModel.SINGLE_INTERVAL_SELECTION );
    table.setTransferHandler( new MapTransferHandler( id ));
   
    stm.setSortedColumn( 0, SortedTableModel.ASCENDING );

    tcr      = new MappingRenderer();
    setColumnRenderersAndWidths( table, stm, tcr );

    scroll    = new JScrollPane( table, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                        ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS );
   
    tab.add( scroll, BorderLayout.CENTER );
   
    b      = Box.createHorizontalBox();
    ggPlus    = new ModificationButton( ModificationButton.SHAPE_PLUS );
    ggMinus    = new ModificationButton( ModificationButton.SHAPE_MINUS );
    ggMinus.setEnabled( false );
    ggPlus.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
//        int row = table.getSelectedRow() + table.getSelectedRowCount();
//        if( row <= 0 ) row = collConfigs[ ID ].size();
        final int modelIndex = collConfigs[ id ].size();
        final int viewIndex;
        final RoutingConfig cfg = createUniqueConfig( id );
//        collConfigs[ ID ].add( row, cfg );
        collConfigs[ id ].add( cfg );
        setConfigIDs[ id ].add( cfg.id );
        setConfigNames[ id ].add( cfg.name );
        setDirtyConfigs[ id ].add( cfg.id );
        tm.fireTableRowsInserted( modelIndex, modelIndex );
        viewIndex = stm.getViewIndex( modelIndex );
        table.setRowSelectionInterval( viewIndex, viewIndex );
      }
    });
    ggMinus.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final int firstRow  = Math.max( 0, table.getSelectedRow() );
        final int lastRow  = Math.min( table.getRowCount(), firstRow + table.getSelectedRowCount() ) - 1;
        RoutingConfig cfg;
        final int[] modelIndices;
       
        if( firstRow <= lastRow ) {
          modelIndices = new int[ lastRow - firstRow + 1 ];
          for( int i = 0, viewIndex = firstRow; viewIndex <= lastRow; i++, viewIndex++ ) {
            modelIndices[ i ] = stm.getModelIndex( viewIndex );
          }
          Arrays.sort( modelIndices );
       
          for( int i = modelIndices.length - 1; i >= 0; i-- ) {
            cfg = (RoutingConfig) collConfigs[ id ].remove( modelIndices[ i ]);
            setConfigNames[ id ].remove( cfg.name );
            // never remove the id during one editing session,
            // because that will confuse the prefs listeners
            // and the setDirtyConfigs approach
//            setConfigIDs[ id ].remove( cfg.id );
            setDirtyConfigs[ id ].add( cfg.id );
          }
//          tm.fireTableRowsDeleted( firstRow, lastRow );
          tm.fireTableDataChanged();
        }
      }
    });
    b.add( ggPlus );
    b.add( ggMinus );
View Full Code Here

      {ctrl+'+'+leftClick, LangTool.INSTANCE.getString19("ShortcutsFrame.26"), catDraw}, //$NON-NLS-1$
      {shift+'+'+leftClick, LangTool.INSTANCE.getString19("ShortcutsFrame.27"), catDraw}, //$NON-NLS-1$
      {ctrl+'+'+LangTool.INSTANCE.getString19("ShortcutsFrame.29"), LangTool.INSTANCE.getString19("ShortcutsFrame.30"), catDraw} //$NON-NLS-1$ //$NON-NLS-2$
    };

        final TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1L;
      @Override
      public int getColumnCount() { return titles.length; }
            @Override
      public int getRowCount() { return data.length;}
View Full Code Here

            api.getMyeBaySelling();
            ItemType[] tempActiveItems = null;
            if (api.getReturnedActiveList() != null) tempActiveItems = (api.getReturnedActiveList().getItemArray()).getItem();
            final ItemType[] activeItems = tempActiveItems;
            // Display active items in table.
            AbstractTableModel dataModel = new AbstractTableModel() {
                public int getColumnCount() { return 0; }
                public int getRowCount() { return activeItems == null ? 0 : activeItems.length;}
                public Map<String, Object> getValueAt(int row, int col) {
                    ItemType item = activeItems[row];
                    return itemToColumns(item);
                }
            };
            //add To List
            List<Map<Object, Object>> activeList = getDataModelToList(dataModel);
            int activeSize = dataModel.getRowCount();
            ItemType[] tempItems = null;
            if (api.getReturnedScheduledList() != null) tempItems = (api.getReturnedScheduledList().getItemArray()).getItem();
            final ItemType[] scheItems = tempItems;
            // Display Scheduled items in table.
            dataModel = new AbstractTableModel() {
                public int getColumnCount() { return 0; }
                public int getRowCount() { return scheItems == null ? 0 : scheItems.length;}
                public Map<String, Object> getValueAt(int row, int col) {
                    ItemType item = scheItems[row];
                    return schItemToColumns(item);
                }
            };
            // set data
            List<Map<Object, Object>> scheduledList = getDataModelToList(dataModel);
            int scheduledSize = dataModel.getRowCount();
            OrderTransactionType[] tempSoldItems = null;
            if (UtilValidate.isNotEmpty(api.getReturnedSoldList())) tempSoldItems = (api.getReturnedSoldList().getOrderTransactionArray()).getOrderTransaction();
            // add to list
            List<Map<String, Object>> soldList = FastList.newInstance();
            if (UtilValidate.isNotEmpty(tempSoldItems)) {
                soldList =  EbayStore.getOrderTransactions(tempSoldItems);
            }
            int soldSize = tempSoldItems == null ? 0 : tempSoldItems.length;
            ItemType[] tempUnSoldItems = null;
            if (UtilValidate.isNotEmpty(api.getReturnedUnsoldList())) tempUnSoldItems = (api.getReturnedUnsoldList().getItemArray()).getItem();
            final ItemType[] unSoldItems = tempUnSoldItems;
            // Display unsold items in table.
            dataModel = new AbstractTableModel() {
                public int getColumnCount() { return 0; }
                public int getRowCount() { return unSoldItems == null ? 0 : unSoldItems.length;}
                public Map<String, Object> getValueAt(int row, int col) {
                    ItemType item = unSoldItems[row];
                    return unsoldItemToColumns(item);
                }
            };
            // add to list
            List<Map<Object, Object>> unsoldList = getDataModelToList(dataModel);
            int unsoldSize = dataModel.getRowCount();
            //list to result
            result.put("activeItems", activeList);
            result.put("soldItems", soldList);
            result.put("unsoldItems", unsoldList);
            result.put("scheduledItems", scheduledList);
View Full Code Here

     *
     * @param versionsarray ArrayList
     * @return TableModel
     */
    public TableModel getVersionTableModel(final ArrayList<String> versionsarray) {
    return new AbstractTableModel() {

      private static final long serialVersionUID = 5105003782164682777L;

      public int getColumnCount() {
        return 4;
View Full Code Here

TOP

Related Classes of javax.swing.table.AbstractTableModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.