Example usage for javax.swing.table TableColumn setCellRenderer

List of usage examples for javax.swing.table TableColumn setCellRenderer

Introduction

In this page you can find the example usage for javax.swing.table TableColumn setCellRenderer.

Prototype

@BeanProperty(description = "The renderer to use for cell values.")
public void setCellRenderer(TableCellRenderer cellRenderer) 

Source Link

Document

Sets the TableCellRenderer used by JTable to draw individual values for this column.

Usage

From source file:edu.harvard.mcz.imagecapture.VerbatimClassifyDialog.java

/**
 * This method initializes jTableNumbers   
 *    //from w w  w  .  ja  va 2s  . co  m
 * @return javax.swing.JTable   
 */
private JTable getJTableNumbers() {
    if (jTableNumbers == null) {
        jTableNumbers = new JTable(new NumberTableModel());
        JComboBox<String> jComboNumberTypes = new JComboBox<String>();
        jComboNumberTypes.setModel(new DefaultComboBoxModel<String>(NumberLifeCycle.getDistinctTypes()));
        jComboNumberTypes.setEditable(true);
        TableColumn typeColumn = jTableNumbers.getColumnModel().getColumn(NumberTableModel.COLUMN_TYPE);
        DefaultCellEditor comboBoxEditor = new DefaultCellEditor(jComboNumberTypes);
        //TODO: enable autocomplete for numbertypes picklist.
        //AutoCompleteDecorator.decorate((JComboBox) comboBoxEditor.getComponent());
        typeColumn.setCellEditor(comboBoxEditor);
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        renderer.setToolTipText("Click for pick list of number types.");
        typeColumn.setCellRenderer(renderer);
    }
    return jTableNumbers;
}

From source file:com.view.PortfolioManagerWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w ww . ja va 2  s .com*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    java.awt.GridBagConstraints gridBagConstraints;

    logOutButton = new javax.swing.JButton();
    PMPlatformTabbedPane = new javax.swing.JTabbedPane();
    PendingOrders = new javax.swing.JPanel();
    PendingOrderRequests = new javax.swing.JScrollPane();
    PMPendingOrdersTable = new javax.swing.JTable();
    PMPendingOrderFilter = new javax.swing.JButton();
    FilterOptionsPMPending = new javax.swing.JComboBox<>();
    FilterTextPMPending = new javax.swing.JTextField();
    ClearFilterPMPendingOrder = new javax.swing.JButton();
    PMEOD = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    PMEODBoughtScrollPane = new javax.swing.JScrollPane();
    PMEODBoughtTable = new javax.swing.JTable();
    PMEODSoldScrollPane = new javax.swing.JScrollPane();
    PMEODSoldTable = new javax.swing.JTable();
    jLabel3 = new javax.swing.JLabel();
    FilterTextPMEOD = new javax.swing.JTextField();
    FilterOptionsPMEOD = new javax.swing.JComboBox<>();
    PMEODFilter = new javax.swing.JButton();
    ClearFilterPMEOD = new javax.swing.JButton();
    CreateOrder = new javax.swing.JPanel();
    PMSelectTraderOptions = new javax.swing.JComboBox<>();
    jLabel5 = new javax.swing.JLabel();
    PMSendOrderScrollPane = new javax.swing.JScrollPane();
    PMSendOrderTable = new javax.swing.JTable();
    PMSendOrder = new javax.swing.JButton();
    PMAddOrderRow = new javax.swing.JButton();
    PMOrderHistory = new javax.swing.JPanel();
    PMOrderHistoryScrollPane = new javax.swing.JScrollPane();
    PMOrderHistoryTable = new javax.swing.JTable();
    FilterTextPMOrderHistory = new javax.swing.JTextField();
    FilterOptionsPMOrderHistory = new javax.swing.JComboBox<>();
    PMOrderHistoryFilter = new javax.swing.JButton();
    ClearFilterPMOrderHistory = new javax.swing.JButton();
    ChangePassword = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("MoneyTree Trading Platform: Portfolio Manager");
    setMinimumSize(new java.awt.Dimension(1024, 768));
    getContentPane().setLayout(new java.awt.GridBagLayout());

    logOutButton.setText("Logout");
    logOutButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            logOutButtonActionPerformed(evt);
        }
    });
    getContentPane().add(logOutButton, new java.awt.GridBagConstraints());

    PMPlatformTabbedPane.setMinimumSize(new java.awt.Dimension(150, 65));

    PMPendingOrdersTable.setBackground(new java.awt.Color(102, 102, 102));
    PMPendingOrdersTable
            .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    String[] CurrencyValues = { "USD", "GBP" };
    PMPendingOrdersTable.setForeground(new java.awt.Color(255, 255, 255));
    PMPendingOrdersTable.setModel(com.controller.CPMOrderMANIAC.getPRTableModel());
    PMPendingOrdersTable.setGridColor(new java.awt.Color(255, 255, 255));
    PMPendingOrdersTable.getTableHeader().setReorderingAllowed(false);
    PendingOrderRequests.setViewportView(PMPendingOrdersTable);

    PMPendingOrderFilter.setText("Filter");
    PMPendingOrderFilter.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMPendingOrderFilterActionPerformed(evt);
        }
    });

    FilterOptionsPMPending.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { "Order ID", "Portfolio ID", "Symbol", "Quantity", "Action", "Stop Price",
                    "Limit Price", "Account Type", "Order Type", "Assigned To" }));

    FilterTextPMPending.setText("Filter Text");

    ClearFilterPMPendingOrder.setText("Clear Filter");
    ClearFilterPMPendingOrder.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ClearFilterPMPendingOrderActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout PendingOrdersLayout = new javax.swing.GroupLayout(PendingOrders);
    PendingOrders.setLayout(PendingOrdersLayout);
    PendingOrdersLayout.setHorizontalGroup(
            PendingOrdersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            PendingOrdersLayout.createSequentialGroup()
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(PendingOrderRequests, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            801, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap())
                    .addGroup(PendingOrdersLayout.createSequentialGroup().addContainerGap()
                            .addComponent(FilterTextPMPending, javax.swing.GroupLayout.PREFERRED_SIZE, 281,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(FilterOptionsPMPending, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18).addComponent(PMPendingOrderFilter).addGap(18, 18, 18)
                            .addComponent(ClearFilterPMPendingOrder)
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    PendingOrdersLayout.setVerticalGroup(PendingOrdersLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PendingOrdersLayout.createSequentialGroup().addContainerGap()
                    .addComponent(PendingOrderRequests, javax.swing.GroupLayout.PREFERRED_SIZE, 183,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(PendingOrdersLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(FilterTextPMPending, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(FilterOptionsPMPending, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(PMPendingOrderFilter).addComponent(ClearFilterPMPendingOrder))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    PMPlatformTabbedPane.addTab("Pending Order Requests", PendingOrders);

    jLabel2.setText("Bought");

    PMEODBoughtTable.setModel(CPMEndOfDay.getBuyTableModel());
    PMEODBoughtScrollPane.setViewportView(PMEODBoughtTable);

    PMEODSoldTable.setModel(CPMEndOfDay.getSellTableModel());
    PMEODSoldScrollPane.setViewportView(PMEODSoldTable);

    jLabel3.setText("Sold");

    FilterTextPMEOD.setText("Filter By");

    FilterOptionsPMEOD.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { "Portfolio ID", "Symbol", "Quantity", "Price" }));

    PMEODFilter.setText("Filter");
    PMEODFilter.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMEODFilterActionPerformed(evt);
        }
    });

    ClearFilterPMEOD.setText("Clear Filter");
    ClearFilterPMEOD.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ClearFilterPMEODActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout PMEODLayout = new javax.swing.GroupLayout(PMEOD);
    PMEOD.setLayout(PMEODLayout);
    PMEODLayout.setHorizontalGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PMEODLayout.createSequentialGroup()
                    .addGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(PMEODLayout.createSequentialGroup().addGap(124, 124, 124)
                                    .addComponent(FilterTextPMEOD, javax.swing.GroupLayout.PREFERRED_SIZE, 350,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(FilterOptionsPMEOD, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(18, 18, 18).addComponent(PMEODFilter))
                            .addGroup(PMEODLayout.createSequentialGroup().addGroup(PMEODLayout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(PMEODLayout.createSequentialGroup().addGap(234, 234, 234)
                                            .addComponent(jLabel2)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                            PMEODLayout.createSequentialGroup()
                                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
                                                            Short.MAX_VALUE)
                                                    .addComponent(PMEODBoughtScrollPane,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 273,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18, 18, 18)))
                                    .addGroup(PMEODLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(PMEODSoldScrollPane,
                                                    javax.swing.GroupLayout.Alignment.TRAILING,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 280,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    PMEODLayout.createSequentialGroup().addComponent(jLabel3)
                                                            .addGap(132, 132, 132)))))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(ClearFilterPMEOD).addGap(55, 55, 55)));
    PMEODLayout.setVerticalGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PMEODLayout.createSequentialGroup().addContainerGap()
                    .addGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3).addComponent(jLabel2))
                    .addGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PMEODLayout.createSequentialGroup().addGap(15, 15, 15).addComponent(
                                    PMEODSoldScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 271,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(PMEODLayout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(PMEODBoughtScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            268, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGap(21, 21, 21)
                    .addGroup(PMEODLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(PMEODFilter)
                            .addComponent(FilterOptionsPMEOD, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(FilterTextPMEOD, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ClearFilterPMEOD))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    PMPlatformTabbedPane.addTab("EOD", PMEOD);

    PMSelectTraderOptions.setModel(new javax.swing.DefaultComboBoxModel<>(TraderNames));
    PMSelectTraderOptions.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMSelectTraderOptionsActionPerformed(evt);
        }
    });

    jLabel5.setText("Select Trader to Assign To:");

    PMSendOrderTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object[][] { { null, null, null, null, null, null, null, null, null } },
            new String[] { "Portfolio ID", "Stock Exchange", "Symbol", "Quantity", "Action", "Order Type",
                    "Stop Price", "Limit Price", "Account Type" }) {
        Class[] types = new Class[] { java.lang.Long.class, java.lang.String.class, java.lang.String.class,
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class,
                java.lang.Double.class, java.lang.String.class };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }
    });
    TableColumn col2 = PMSendOrderTable.getColumnModel().getColumn(1);
    col2.setCellEditor(new myComboBoxEditor(StockExchange));
    col2.setCellRenderer(new MyComboBoxRenderer(StockExchange));
    TableColumn col1 = PMSendOrderTable.getColumnModel().getColumn(4);
    col1.setCellEditor(new myComboBoxEditor(ActionItems));
    col1.setCellRenderer(new MyComboBoxRenderer(ActionItems));
    TableColumn col5 = PMSendOrderTable.getColumnModel().getColumn(5);
    col5.setCellEditor(new myComboBoxEditor(OrderType));
    col5.setCellRenderer(new MyComboBoxRenderer(OrderType));
    TableColumn col3 = PMSendOrderTable.getColumnModel().getColumn(8);
    col3.setCellEditor(new myComboBoxEditor(AccountType));
    col3.setCellRenderer(new MyComboBoxRenderer(AccountType));
    /////////////////////////////////////GG
    TableColumn col4 = PMSendOrderTable.getColumnModel().getColumn(2);

    CSVReader csv = new CSVReader();
    ArrayList<String> symbolList = csv.loadSymbol();

    Java2sAutoComboBox comboBox = new Java2sAutoComboBox(symbolList);
    comboBox.setDataList(symbolList);
    comboBox.setMaximumRowCount(5);
    col4.setCellEditor(new DefaultCellEditor(comboBox));
    //Set up tool tips for the sport cells.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for combo box");
    col4.setCellRenderer(renderer);

    /////////////////////////////////////gg
    PMSendOrderScrollPane.setViewportView(PMSendOrderTable);

    PMSendOrder.setText("Send Order");
    PMSendOrder.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMSendOrderActionPerformed(evt);
        }
    });

    PMAddOrderRow.setText("Add Row");
    PMAddOrderRow.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMAddOrderRowActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout CreateOrderLayout = new javax.swing.GroupLayout(CreateOrder);
    CreateOrder.setLayout(CreateOrderLayout);
    CreateOrderLayout.setHorizontalGroup(CreateOrderLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PMSendOrderScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CreateOrderLayout.createSequentialGroup()
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(CreateOrderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, CreateOrderLayout
                                    .createSequentialGroup().addComponent(jLabel5).addGap(18, 18, 18)
                                    .addComponent(PMSelectTraderOptions, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            137, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(213, 213, 213).addComponent(PMSendOrder).addContainerGap())
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                    CreateOrderLayout.createSequentialGroup().addComponent(PMAddOrderRow)
                                            .addGap(109, 109, 109)))));
    CreateOrderLayout.setVerticalGroup(CreateOrderLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(CreateOrderLayout.createSequentialGroup().addGap(5, 5, 5).addGroup(CreateOrderLayout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(CreateOrderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5).addComponent(PMSelectTraderOptions,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(PMSendOrder)).addGap(28, 28, 28)
                    .addComponent(PMSendOrderScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 233,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(PMAddOrderRow)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    PMPlatformTabbedPane.addTab("Create Order", CreateOrder);

    PMOrderHistoryTable.setBackground(new java.awt.Color(102, 102, 102));
    PMOrderHistoryTable
            .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
    PMOrderHistoryTable.setForeground(new java.awt.Color(255, 255, 255));
    PMOrderHistoryTable.setModel(com.controller.CPMOrderMANIAC.getOHTableModel());
    PMOrderHistoryTable.setGridColor(new java.awt.Color(255, 255, 255));
    PMOrderHistoryTable.getTableHeader().setReorderingAllowed(false);
    PMOrderHistoryScrollPane.setViewportView(PMOrderHistoryTable);

    FilterTextPMOrderHistory.setText("Filter By");

    FilterOptionsPMOrderHistory.setModel(new javax.swing.DefaultComboBoxModel<>(
            new String[] { "Order ID", "Portfolio ID", "Symbol", "Quantity", "Action", "Stop Price",
                    "Limit Price", "Account Type", "Order Type", "Assigned To" }));

    PMOrderHistoryFilter.setText("Filter");
    PMOrderHistoryFilter.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            PMOrderHistoryFilterActionPerformed(evt);
        }
    });

    ClearFilterPMOrderHistory.setText("Clear Filter");
    ClearFilterPMOrderHistory.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ClearFilterPMOrderHistoryActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout PMOrderHistoryLayout = new javax.swing.GroupLayout(PMOrderHistory);
    PMOrderHistory.setLayout(PMOrderHistoryLayout);
    PMOrderHistoryLayout
            .setHorizontalGroup(
                    PMOrderHistoryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(PMOrderHistoryLayout.createSequentialGroup().addContainerGap()
                                    .addGroup(PMOrderHistoryLayout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(PMOrderHistoryScrollPane)
                                            .addGroup(PMOrderHistoryLayout.createSequentialGroup()
                                                    .addComponent(FilterTextPMOrderHistory,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 281,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18, 18, 18)
                                                    .addComponent(FilterOptionsPMOrderHistory,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 126,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(18, 18, 18).addComponent(PMOrderHistoryFilter)
                                                    .addGap(18, 18, 18).addComponent(ClearFilterPMOrderHistory)
                                                    .addGap(0, 0, Short.MAX_VALUE)))
                                    .addContainerGap()));
    PMOrderHistoryLayout.setVerticalGroup(PMOrderHistoryLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PMOrderHistoryLayout.createSequentialGroup()
                    .addComponent(PMOrderHistoryScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 187,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(PMOrderHistoryLayout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(FilterTextPMOrderHistory, javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(FilterOptionsPMOrderHistory, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    23, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(PMOrderHistoryFilter).addComponent(ClearFilterPMOrderHistory))
                    .addGap(0, 0, Short.MAX_VALUE)));

    PMPlatformTabbedPane.addTab("Executed Order History", PMOrderHistory);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.ipady = 127;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 85);
    getContentPane().add(PMPlatformTabbedPane, gridBagConstraints);

    ChangePassword.setText("Change Password");
    ChangePassword.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            ChangePasswordActionPerformed(evt);
        }
    });
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.insets = new java.awt.Insets(11, 610, 0, 85);
    getContentPane().add(ChangePassword, gridBagConstraints);

    pack();
}

From source file:net.kamhon.ieagle.swing.table.KTable.java

private void initComponents(List<KTableColumn> columns) {
    tableModel = new KTableModel<T>(this, columns);
    setModel(tableModel);/*from w  w w .  j av  a  2 s  .co  m*/

    // final KTable<T> table = this;

    for (int i = 0; i < columns.size(); i++) {
        KTableColumn column = columns.get(i);
        TableColumn tc = columnModel.getColumn(i);
        tc.setHeaderValue(column.getColumnLabel());

        if (column instanceof KTableCheckBoxColumn) {
            BooleanEditor cellEditor = new BooleanEditor();

            if (column instanceof KTableRowCheckBoxColumn) {
                /*final JCheckBox component = (JCheckBox) cellEditor.getComponent();
                component.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                  int[] selectedRows = table.getSelectedRows();
                  int selectedRow = table.getSelectedRow();
                          
                  log.debug("selectedRows = " + selectedRows);
                  log.debug("selectedRow = " + selectedRow);
                  if (component.isSelected()) {
                        
                  }
                   }
                });*/
                // log.debug("component = " + component);
            }

            tc.setCellEditor(cellEditor);
            tc.setCellRenderer(this.getDefaultRenderer(Boolean.class));
            tc.setHeaderRenderer(new KTableHeaderCheckBox(this));
        } else if (column instanceof KTableTextColumn) {
            KTextField textField = new KTextField();
            textField.setEditable(false);

            tc.setCellEditor(new GenericEditor(textField));
        }
    }

    setColumnControlVisible(true);
    setShowGrid(false, false);
}

From source file:edu.ku.brc.specify.ui.treetables.TreeDefinitionEditor.java

/**
 * @param treeDef/*w  ww .  jav a 2  s  .  c o m*/
 */
protected void initTreeDefEditorComponent(final D treeDef) {
    Set<I> defItems = treeDef.getTreeDefItems();
    tableModel = new TreeDefEditorTableModel<T, D, I>(defItems);
    defItemsTable = new JTable(tableModel);
    defItemsTable.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));

    defItemsTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                SwingUtilities.invokeLater(new Runnable() {

                    /* (non-Javadoc)
                     * @see java.lang.Runnable#run()
                     */
                    @Override
                    public void run() {
                        editTreeDefItem(defItemsTable.getSelectedRow());
                    }

                });
            }
        }
    });
    defItemsTable.setRowHeight(24);

    // Center the boolean Columns
    BiColorTableCellRenderer centeredRenderer = new BiColorTableCellRenderer();

    TableColumn tc = defItemsTable.getColumnModel().getColumn(2);
    tc.setCellRenderer(centeredRenderer);
    tc = defItemsTable.getColumnModel().getColumn(3);
    tc.setCellRenderer(centeredRenderer);

    if (isEditMode) {
        defItemsTable.setRowSelectionAllowed(true);
        defItemsTable.setColumnSelectionAllowed(false);
        defItemsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        defItemsTable.setRowSelectionAllowed(false);
    }

    UIHelper.makeTableHeadersCentered(defItemsTable, false);

    defNameLabel.setText(treeDef.getName());
    Font f = defNameLabel.getFont();
    Font boldF = f.deriveFont(Font.BOLD);
    defNameLabel.setFont(boldF);

    // put everything in the main panel
    this.add(UIHelper.createScrollPane(defItemsTable), BorderLayout.CENTER);
    this.add(titlePanel, BorderLayout.NORTH);

    // Only add selection listener if the botton panel is there for editing
    if (edaPanel != null) {
        PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,10px", "p")); //$NON-NLS-1$ //$NON-NLS-2$
        pb.add(edaPanel, new CellConstraints().xy(2, 1));
        add(pb.getPanel(), BorderLayout.SOUTH);
        addSelectionListener();
    }

    repaint();
}

From source file:org.jdal.swing.ListTableModel.java

/**
 * Create a TableColumnModel for JTable. 
 * Try to use sizes and cell renderers from property descriptors.
 * @return a new TableColumnModel based on PropertyDescriptors
 *///from  www .  j a  va  2s  .  c  om
public TableColumnModel getTableColumnModel() {
    TableColumnModel tcm = new DefaultTableColumnModel();
    int baseIndex = 0;
    if (usingChecks) {
        TableColumn tableColumn = new TableColumn(0);
        tableColumn.setMaxWidth(50);
        tcm.addColumn(tableColumn);
        baseIndex++;
    }
    for (int i = 0; i < columnNames.size(); i++) {
        String name = this.columnNames.get(i);
        TableColumn tableColumn = new TableColumn(baseIndex + i);
        tableColumn.setHeaderValue(displayNames.get(i));

        if (pds != null && pds.size() > 0) {
            PropertyDescriptor descriptor = pds.get(i);
            // property values for TableColumns
            if (descriptor != null) {
                Integer maxWidth = getColumnWidth(name);
                if (maxWidth != null)
                    tableColumn.setMaxWidth(maxWidth.intValue());
                tableColumn.setCellRenderer(getColumnRenderer(name));
                tableColumn.setCellEditor(getColumnEditor(name));
            }
        }

        tcm.addColumn(tableColumn);
    }

    if (usingActions) {
        baseIndex += columnNames.size();
        for (int i = 0; i < actions.size(); i++) {
            TableColumn tableColumn = new TableColumn(baseIndex + i);
            tableColumn.setCellRenderer(new ActionCellRenderer());
            tableColumn.setMaxWidth(50);
            //   tableColumn.setCellEditor(new ActionCellEditor())
            tcm.addColumn(tableColumn);
        }
    }

    return tcm;
}

From source file:gov.noaa.ncdc.iosp.avhrr.util.AvhrrLevel1B2Netcdf.java

private void setTableCellRenderer(JTable table, TableCellRenderer renderer) {
    TableColumnModel columnModel = table.getColumnModel();
    int columnCount = columnModel.getColumnCount();

    for (int i = 0; i < columnCount; i++) {
        TableColumn column = columnModel.getColumn(i);

        if (i == 0) {
            column.setMaxWidth(90);// w w w  . ja v  a2  s . c o m
        } else {
            if (i > 1) {
                column.setMaxWidth(90);
            }
            if (i == (columnCount - 1)) {
                column.setMaxWidth(0);
            }
            if (i == (columnCount - 2)) {
                column.setMaxWidth(150);
            }
            column.setCellRenderer(renderer);
        }
    }
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

private void configVDTagsComboBox(JTable table, int columnIndex) {

    TableColumnModel columnModel = table.getColumnModel();
    TableColumn comboColumn = columnModel.getColumn(columnIndex);

    JComboBox<String> comboBox = new JComboBox<>();

    EnumSet<VideoDataTags> allVDTags = EnumSet.allOf(VideoDataTags.class);
    for (VideoDataTags videoDataTag : allVDTags) {
        comboBox.addItem(videoDataTag.toString());
    }/* w w  w  .jav a 2  s .  co  m*/

    comboColumn.setCellEditor(new DefaultCellEditor(comboBox));

    /*
     * allows clearing a problem when cell editor is interrupted, very deep problem. 
     * Only shows if: (A) combobox selection is interupted, (B) dialog is
     * closed , and (C) Wizard is entered from the menu in this exact order
     */
    cellEditor = comboColumn.getCellEditor();

    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText(ResourceBundleHelper.getMessageString("videoTab.tooltip"));
    comboColumn.setCellRenderer(renderer);

}

From source file:com.aw.swing.mvp.binding.component.BndSJTable.java

private void configureEditableCell(TableColumn col, ColumnInfo columnInfo) {
    TableCellRenderer tableCellRenderer = new DefaultEditableCellRenderer(columnInfo);
    ((DefaultTableCellRenderer) tableCellRenderer).setHorizontalAlignment(columnInfo.getAlignment());

    TableCellEditor tableCellEditor = null;
    Font font = ((DefaultEditableCellRenderer) tableCellRenderer).getFont();
    if (columnInfo.getCellEditorValuesProvider() != null) {
        JComponentCellRenderer jComponentCellRenderer = new JComponentCellRenderer();
        JComponentCellEditor jComponentCellEditor = new JComponentCellEditor(columnInfo, font);
        jComponentCellEditor.setCellRenderer(jComponentCellRenderer);
        jComponentCellEditor.setCellEditorProvider(columnInfo.getCellEditorValuesProvider());
        col.setCellRenderer(jComponentCellRenderer);
        col.setCellEditor(jComponentCellEditor);
        columnInfo.setSpecialCellRenderer(jComponentCellRenderer);
        return;//w ww  .j a  v  a 2  s  . c  om
    }
    if (columnInfo.getColumnEditorType() == ColumnInfo.TEXT_BOX) {
        ((DefaultEditableCellRenderer) tableCellRenderer).setCellColorChanger(cellColorChanger);
        tableCellEditor = CellEditorFactory.getJTextFielCellEditor(columnInfo, jTable, font);
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.TEXT_AREA) {
        tableCellEditor = new JTextAreaCellEditor(getJTable(), columnInfo, font);
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.CHECK_BOX) {
        tableCellRenderer = new JCheckBoxCellRenderer(columnInfo, columnInfo.getValueTrue());
        ((JCheckBoxCellRenderer) tableCellRenderer).setBndSJTable(this);
        tableCellEditor = CellEditorFactory.getJCheckBoxEditor(columnInfo, jTable,
                getCellEditableFocusListener());
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.RADIO_BUTTON) {
        tableCellRenderer = new JRadioButtonCellRenderer(columnInfo.getValueTrue());
        tableCellEditor = new JRadioButtonCellEditor(new JCheckBox(), columnInfo.getValueTrue());
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.COMBO_BOX) {

        if (columnInfo.hasParentCmps()) {
            CellDropDownProvider cellDropDownProvider = columnInfo.getCellDropDownProvider(this);
            tableCellRenderer = new JComboBoxDependentCellRenderer(columnInfo,
                    new JComboBoxDependentCellRendererModel(cellDropDownProvider));
            JComboBoxDependentCellEditorModel comboBoxModel = new JComboBoxDependentCellEditorModel(
                    cellDropDownProvider);
            final JComboBox jComboBox = getJComboBox(comboBoxModel);

            JComboBoxDependentCellEditor jComboBoxCellEditor = new JComboBoxDependentCellEditor(jComboBox);
            tableCellEditor = jComboBoxCellEditor;

        } else {
            JComboBoxCellRenderer comboBoxCellRenderer = new JComboBoxCellRenderer(columnInfo,
                    new JComboBoxCellRendererModel(columnInfo.getMetaLoader()));
            comboBoxCellRenderer.setEditingRowPolicy(editingRowPolicy);
            tableCellRenderer = comboBoxCellRenderer;

            JComboBoxCellEditorModel comboBoxModel = new JComboBoxCellEditorModel();
            comboBoxModel.setMetaLoader(columnInfo.getMetaLoader());
            final JComboBox jComboBox = getJComboBox(comboBoxModel);

            JComboBoxCellEditor jComboBoxCellEditor = new JComboBoxCellEditor(jComboBox);
            jComboBoxCellEditor.setCol(columnInfo.getIdx());
            tableCellEditor = jComboBoxCellEditor;
        }
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.FILE_CHOOSER) {
        tableCellEditor = new JFileChooserCellEditor();
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.BUTTON) {
        tableCellEditor = new JButtonCellEditor(columnInfo);
        tableCellRenderer = new JButtonCellRenderer();
    } else if (columnInfo.getColumnEditorType() == ColumnInfo.LINK) {
        tableCellEditor = new JLabelLinkCellEditor(columnInfo);
        //tableCellEditor = new JLabelLinkCellRenderer();
        JLabelLinkCellRenderer linkCellRenderer = new JLabelLinkCellRenderer();
        linkCellRenderer.setColumnInfo(columnInfo);
        linkCellRenderer.setCellColorChanger(cellColorChanger);
        linkCellRenderer.setHorizontalAlignment(columnInfo.getAlignment());
        linkCellRenderer.setTableEditable(isEditable());
        if (isAuditingColumn(columnInfo.getFieldName())) {
            linkCellRenderer.setCustomBackground(AUDITING_COLUMN_COLOR);
        }
        tableCellRenderer = linkCellRenderer;

    }
    col.setCellRenderer(tableCellRenderer);
    col.setCellEditor(tableCellEditor);
}

From source file:edu.harvard.i2b2.patientMapping.ui.PatientMappingJPanel.java

/** Creates new form PatientMappingJPanel */
public PatientMappingJPanel(java.awt.Container oAwtContainer) {
    columns = new ArrayList<SiteColumnData>();

    initComponents();// ww w.j  ava 2  s  . c om
    DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
    //model.addColumn("addedColumn1");
    //model.addColumn("addedColumn2");

    String[] columns = new String[3];
    columns[0] = new String("HIVE");
    columns[1] = new String("");
    columns[2] = new String("");
    //columns[3] = new String("");
    DefaultTableModel model1 = new DefaultTableModel(columns, 100);
    jTable1.setModel(model1);
    jTable1.setCellSelectionEnabled(true);
    TableColumn col = jTable1.getColumnModel().getColumn(0);
    DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer();
    dtcr.setHorizontalAlignment(SwingConstants.CENTER);
    col.setCellRenderer(dtcr);
    //jTable1.setCellSelectionEnabled(false);
    //model.setRowCount(100);
    //model.setValueAt(235600004, 0, 4);
    //model.setValueAt(235600005, 1, 5);
    //model.setValueAt(235600006, 5, 4);
    //model.setValueAt(235600007, 5, 5);
    //model.setValueAt(235600008, 6, 5);

    thisPanel = this;
    parent = oAwtContainer;

    //this.jLeftButton.setEnabled(false);
    this.jRightButton.setEnabled(false);
    this.jStartTextField.setEditable(false);
    this.jIncrementTextField.setEditable(false);
    //jAutoSaveCheckBox.setSelected(true);
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopAbstractTable.java

protected void addGeneratedColumnInternal(String columnId, ColumnGenerator generator,
        Class<? extends com.haulmont.cuba.gui.components.Component> componentClass) {
    Column col = getColumn(columnId);/*  w w  w  . j  a  va2 s  . co m*/
    Column associatedRuntimeColumn = null;
    if (col == null) {
        col = addRuntimeGeneratedColumn(columnId);
        associatedRuntimeColumn = col;
    }

    tableModel.addGeneratedColumn(col);
    TableColumn tableColumn = getColumn(col);
    DesktopTableCellEditor cellEditor = new DesktopTableCellEditor(this, generator, componentClass);
    tableColumn.setCellEditor(cellEditor);
    tableColumn.setCellRenderer(cellEditor);

    cellEditor.setAssociatedRuntimeColumn(associatedRuntimeColumn);

    generatedColumnsCount++;

    packRows();
    repaintImplIfNeeded();
}