Search in sources :

Example 71 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project cayenne by apache.

the class MergerTokenSelectorController method initController.

// ------ other stuff ------
protected void initController() {
    final BindingBuilder builder = new BindingBuilder(getApplication().getBindingFactory(), this);
    builder.bindToAction(view.getCheckAll(), "checkAllAction()");
    builder.bindToAction(view.getReverseAll(), "reverseAllAction()");
    final TableModel model = new MergerTokenTableModel(this);
    final MergeDirection[] dirs = new MergeDirection[] { MergeDirection.TO_DB, MergeDirection.TO_MODEL };
    view.getTokens().setModel(model);
    final TableColumnModel columnModel = view.getTokens().getColumnModel();
    // dropdown for direction column
    final JComboBox directionCombo = Application.getWidgetFactory().createComboBox(dirs, false);
    directionCombo.setEditable(false);
    final TableColumn directionColumn = columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION);
    directionColumn.setCellRenderer(new DefaultTableCellRenderer() {

        @Override
        public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) {
            super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            setHorizontalTextPosition(SwingConstants.LEFT);
            setIcon(ModelerUtil.buildIcon("icon-arrow-open.png"));
            return this;
        }
    });
    directionColumn.setCellEditor(new DefaultCellEditor(directionCombo));
    columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setPreferredWidth(50);
    columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setPreferredWidth(100);
    columnModel.getColumn(MergerTokenTableModel.COL_SELECT).setMaxWidth(50);
    columnModel.getColumn(MergerTokenTableModel.COL_DIRECTION).setMaxWidth(100);
}
Also used : JComboBox(javax.swing.JComboBox) BindingBuilder(org.apache.cayenne.swing.BindingBuilder) TableColumnModel(javax.swing.table.TableColumnModel) TableColumn(javax.swing.table.TableColumn) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) DefaultCellEditor(javax.swing.DefaultCellEditor) MergeDirection(org.apache.cayenne.dbsync.merge.context.MergeDirection) JTable(javax.swing.JTable) Component(java.awt.Component) AbstractTableModel(javax.swing.table.AbstractTableModel) TableModel(javax.swing.table.TableModel)

Example 72 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project megameklab by MegaMek.

the class TransportTab method initUI.

private void initUI() {
    ResourceBundle resourceMap = ResourceBundle.getBundle("megameklab.resources.Tabs", new EncodeControl());
    setLayout(new BorderLayout());
    if (getEntity().hasETypeFlag(Entity.ETYPE_JUMPSHIP)) {
        JPanel panHardpoints = new JPanel();
        // $NON-NLS-1$
        lblDockingHardpoints.setText(resourceMap.getString("TransportTab.spnDockingHardpoints.text"));
        panHardpoints.add(lblDockingHardpoints);
        panHardpoints.add(spnDockingHardpoints);
        Dimension size = new Dimension(60, 25);
        spnDockingHardpoints.setPreferredSize(size);
        add(panHardpoints, BorderLayout.NORTH);
        spnDockingHardpoints.addChangeListener(this);
        // $NON-NLS-1$
        spnDockingHardpoints.setToolTipText(resourceMap.getString("TransportTab.spnDockingHardpoints.tooltip"));
        // $NON-NLS-1$
        panHardpoints.add(new JLabel(resourceMap.getString("TransportTab.spnMaxHardpoints.text")));
        panHardpoints.add(lblMaxHardpoints);
        // $NON-NLS-1$
        lblMaxHardpoints.setToolTipText(resourceMap.getString("TransportTab.spnMaxHardpoints.tooltip"));
    } else {
        Dimension size = new Dimension(60, 25);
        spnTroopSpace.setPreferredSize(size);
        spnPodTroopSpace.setPreferredSize(size);
        panTroopspace.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        // $NON-NLS-1$
        panTroopspace.add(new JLabel(resourceMap.getString("TransportTab.spnTroopspace.text")), gbc);
        // $NON-NLS-1$
        spnTroopSpace.setToolTipText(resourceMap.getString("TransportTab.spnTroopspace.tooltip"));
        spnTroopSpace.addChangeListener(this);
        gbc.gridx = 1;
        panTroopspace.add(spnTroopSpace, gbc);
        if (getEntity().isSupportVehicle()) {
            gbc.gridx = 0;
            gbc.gridy = 1;
            // $NON-NLS-1$
            panTroopspace.add(new JLabel(resourceMap.getString("TransportTab.spnPodTroopspace.text")), gbc);
            // $NON-NLS-1$
            spnTroopSpace.setToolTipText(resourceMap.getString("TransportTab.spnPodTroopspace.tooltip"));
            gbc.gridx = 1;
            panTroopspace.add(spnPodTroopSpace, gbc);
            spnPodTroopSpace.addChangeListener(this);
        }
        add(panTroopspace, BorderLayout.NORTH);
    }
    JPanel bayPanel = new JPanel(new GridBagLayout());
    add(bayPanel, BorderLayout.CENTER);
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    // $NON-NLS-1$
    bayPanel.add(new JLabel(resourceMap.getString("TransportTab.lblCurrentBays.text")), gbc);
    gbc.gridy++;
    if (getEntity().isAero()) {
        gbc.gridwidth = 1;
        // $NON-NLS-1$
        bayPanel.add(new JLabel(resourceMap.getString("TransportTab.lblMaxDoors.text")), gbc);
        gbc.gridx = 1;
        bayPanel.add(lblMaxDoors, gbc);
    }
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 1;
    // $NON-NLS-1$
    btnRemoveBay.setText(resourceMap.getString("TransportTab.btnRemoveBay.text"));
    // $NON-NLS-1$
    btnRemoveBay.setToolTipText(resourceMap.getString("TransportTab.btnRemoveBay.tooltip"));
    bayPanel.add(btnRemoveBay, gbc);
    btnRemoveBay.addActionListener(this);
    gbc.gridx = 1;
    // $NON-NLS-1$
    btnAddToCargo.setText(resourceMap.getString("TransportTab.btnAddToCargo.text"));
    // $NON-NLS-1$
    btnAddToCargo.setToolTipText(resourceMap.getString("TransportTab.btnAddToCargo.tooltip"));
    bayPanel.add(btnAddToCargo, gbc);
    btnAddToCargo.addActionListener(this);
    gbc.gridx = 0;
    gbc.gridy++;
    gbc.gridwidth = 3;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    bayPanel.add(new JScrollPane(tblInstalled), gbc);
    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.gridheight = 1;
    // $NON-NLS-1$
    bayPanel.add(new JLabel(resourceMap.getString("TransportTab.lblAvailableBays.text")), gbc);
    gbc.gridy = 2;
    // $NON-NLS-1$
    btnAddBay.setText(resourceMap.getString("TransportTab.btnAddBay.text"));
    // $NON-NLS-1$
    btnAddBay.setToolTipText(resourceMap.getString("TransportTab.btnAddBay.tooltip"));
    bayPanel.add(btnAddBay, gbc);
    btnAddBay.addActionListener(this);
    gbc.gridy++;
    gbc.gridwidth = 2;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    bayPanel.add(new JScrollPane(tblAvailable), gbc);
    tblInstalled.setRowHeight(24);
    TableColumn col = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_SIZE);
    col.setCellEditor(new SpinnerCellEditor(InstalledBaysModel.COL_SIZE));
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    // $NON-NLS-1$
    renderer.setToolTipText(resourceMap.getString("TransportTab.colSize.tooltip"));
    col.setCellRenderer(renderer);
    col = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_DOORS);
    col.setCellEditor(new SpinnerCellEditor(InstalledBaysModel.COL_DOORS));
    renderer = new DefaultTableCellRenderer();
    // $NON-NLS-1$
    renderer.setToolTipText(resourceMap.getString("TransportTab.colDoors.tooltip"));
    col.setCellRenderer(renderer);
    col = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_TONNAGE);
    col.setCellEditor(new SpinnerCellEditor(InstalledBaysModel.COL_TONNAGE));
    renderer = new DefaultTableCellRenderer();
    // $NON-NLS-1$
    renderer.setToolTipText(resourceMap.getString("TransportTab.colTonnage.tooltip"));
    col.setCellRenderer(renderer);
    col = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_PERSONNEL);
    renderer = new DefaultTableCellRenderer();
    // $NON-NLS-1$
    renderer.setToolTipText(resourceMap.getString("TransportTab.colPersonnel.tooltip"));
    col.setCellRenderer(renderer);
    col = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_FACING);
    podColumn = tblInstalled.getColumnModel().getColumn(InstalledBaysModel.COL_POD);
    if (getEntity().hasETypeFlag(Entity.ETYPE_JUMPSHIP)) {
        JComboBox<Integer> cb = new JComboBox<>(new Integer[] { Jumpship.LOC_NOSE, Jumpship.LOC_FLS, Jumpship.LOC_FRS, Jumpship.LOC_ALS, Jumpship.LOC_ARS, Jumpship.LOC_AFT });
        col.setCellEditor(new DefaultCellEditor(cb));
        cb.setRenderer(new DefaultListCellRenderer() {

            @Override
            public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                int loc = Entity.LOC_NONE;
                if (null != value) {
                    loc = (Integer) value;
                }
                setText(getEntity().getLocationName(loc));
                return this;
            }
        });
        renderer = new DefaultTableCellRenderer();
        renderer.setToolTipText(resourceMap.getString("TransportTab.colFacing.tooltip"));
        col.setCellRenderer(renderer);
    } else {
        tblInstalled.getColumnModel().removeColumn(col);
    }
    if (!getEntity().isSupportVehicle()) {
        tblInstalled.getColumnModel().removeColumn(podColumn);
    }
    tblInstalled.setShowGrid(false);
    tblInstalled.setIntercellSpacing(new Dimension(0, 0));
    tblAvailable.setShowGrid(false);
    tblAvailable.setIntercellSpacing(new Dimension(0, 0));
    tblInstalled.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblInstalled.getSelectionModel().addListSelectionListener(e -> checkButtons());
    tblAvailable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tblAvailable.getSelectionModel().addListSelectionListener(e -> checkButtons());
    tblInstalled.setDragEnabled(true);
    tblInstalled.setDropMode(DropMode.INSERT_ROWS);
    tblInstalled.setTransferHandler(new BayReorderTransferHandler());
    refresh();
}
Also used : DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer) TableColumn(javax.swing.table.TableColumn) EncodeControl(megamek.common.util.EncodeControl)

Example 73 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project specify by rhebecaabreu.

the class CadastrarInteressadoProjeto method criaJTable.

// método que cria a tabela com suas propriedades visuais
public void criaJTable() {
    table = new JTable();
    table.setShowVerticalLines(true);
    table.setShowHorizontalLines(true);
    table.setModel(tableIP);
    table.setFont(new Font("Lucida Sans Unicode", Font.PLAIN, 12));
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getTableHeader().setResizingAllowed(true);
    table.getTableHeader().setReorderingAllowed(false);
    table.setBorder(new MatteBorder(1, 1, 1, 1, (Color) SystemColor.activeCaption));
    JTableHeader header = table.getTableHeader();
    DefaultTableCellRenderer centralizado = (DefaultTableCellRenderer) header.getDefaultRenderer();
    centralizado.setHorizontalAlignment(SwingConstants.CENTER);
    table.getColumnModel().getColumn(0).setPreferredWidth(25);
    table.getColumnModel().getColumn(1).setPreferredWidth(60);
    table.getColumnModel().getColumn(2).setPreferredWidth(428);
    table.setRowHeight(20);
    table.setBounds(52, 88, 424, 268);
    scrollPane2 = new JScrollPane(table);
    scrollPane2.setBorder(null);
    scrollPane2.setBounds(8, 75, 513, 130);
    // só mostra a barra vertical se necessário
    scrollPane2.setVerticalScrollBarPolicy(scrollPane2.VERTICAL_SCROLLBAR_AS_NEEDED);
    // só mostra a barra horizontal se necessário
    scrollPane2.setHorizontalScrollBarPolicy(scrollPane2.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    contentPane.add(scrollPane2);
}
Also used : JScrollPane(javax.swing.JScrollPane) MatteBorder(javax.swing.border.MatteBorder) JTable(javax.swing.JTable) Color(java.awt.Color) SystemColor(java.awt.SystemColor) JTableHeader(javax.swing.table.JTableHeader) Font(java.awt.Font) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 74 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project specify by rhebecaabreu.

the class MeusProjetos method criaJTableInteressado.

public void criaJTableInteressado() {
    table_2 = new JTable();
    table_2.setGridColor(SystemColor.scrollbar);
    table_2.setShowHorizontalLines(true);
    table_2.setShowVerticalLines(true);
    table_2.setSelectionBackground(SystemColor.textHighlight);
    table_2.setBounds(3, 24, 540, 0);
    table_2.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
    table_2.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table_2.getTableHeader().setResizingAllowed(true);
    table_2.getTableHeader().setReorderingAllowed(false);
    table_2.setBorder(new MatteBorder(1, 1, 1, 1, (Color) UIManager.getColor("Menu[Disabled].textForeground")));
    table_2.setModel(iptable);
    table_2.getColumnModel().getColumn(0).setPreferredWidth(20);
    table_2.getColumnModel().getColumn(1).setPreferredWidth(60);
    table_2.getColumnModel().getColumn(2).setPreferredWidth(184);
    table_2.getColumnModel().getColumn(3).setPreferredWidth(160);
    table_2.getColumnModel().getColumn(4).setPreferredWidth(120);
    table_2.getColumnModel().getColumn(5).setPreferredWidth(185);
    AbtToolTipHeader tooltipHeader = new AbtToolTipHeader(table_2.getColumnModel());
    // Seta a table header de tooltips
    table_2.setTableHeader(tooltipHeader);
    tooltipHeader.addToolTipToColumn(// Coluna 0
    1, "Código do interessado");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    2, "Nome do interessado");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    3, "Papel desempenhado pelo interessado no projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    4, "Data da entrada do interessado no projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    5, "Última modificação/alteração realizada no cadastro do interessado");
    DefaultTableCellRenderer esquerda = new DefaultTableCellRenderer();
    DefaultTableCellRenderer centro = new DefaultTableCellRenderer();
    DefaultTableCellRenderer direita = new DefaultTableCellRenderer();
    esquerda.setHorizontalAlignment(SwingConstants.LEFT);
    centro.setHorizontalAlignment(SwingConstants.CENTER);
    direita.setHorizontalAlignment(SwingConstants.RIGHT);
    table_2.getColumnModel().getColumn(4).setCellRenderer(centro);
    JTableHeader cabecalho = table_2.getTableHeader();
    cabecalho.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
    table_2.setRowHeight(20);
    ((DefaultTableCellRenderer) table_2.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
    panelInteressados.setLayout(null);
    panelInteressados.add(table_2);
    scrollPane2 = new JScrollPane(table_2);
    scrollPane2.setBounds(4, 29, 570, 498);
    // só mostra a barra vertical se necessário
    scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // só mostra a barra horizontal se necessário
    scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    panelInteressados.add(scrollPane2);
}
Also used : JScrollPane(javax.swing.JScrollPane) MatteBorder(javax.swing.border.MatteBorder) JTable(javax.swing.JTable) Color(java.awt.Color) SystemColor(java.awt.SystemColor) JTableHeader(javax.swing.table.JTableHeader) Font(java.awt.Font) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Example 75 with DefaultTableCellRenderer

use of javax.swing.table.DefaultTableCellRenderer in project specify by rhebecaabreu.

the class MeusProjetos method criaJTableProjetos.

public void criaJTableProjetos() {
    tablep = new JTable();
    tablep.setShowHorizontalLines(true);
    tablep.setShowVerticalLines(true);
    tablep.setGridColor(SystemColor.scrollbar);
    tablep.setSelectionBackground(SystemColor.textHighlight);
    tablep.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    tablep.setBounds(3, 24, 540, 0);
    tablep.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
    tablep.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    tablep.getTableHeader().setResizingAllowed(true);
    tablep.getTableHeader().setReorderingAllowed(false);
    tablep.setBorder(new MatteBorder(1, 1, 1, 1, (Color) UIManager.getColor("Menu[Disabled].textForeground")));
    tablep.setModel(tableproj);
    tablep.getColumnModel().getColumn(0).setPreferredWidth(18);
    tablep.getColumnModel().getColumn(1).setPreferredWidth(170);
    tablep.getColumnModel().getColumn(2).setPreferredWidth(150);
    tablep.getColumnModel().getColumn(3).setPreferredWidth(75);
    tablep.getColumnModel().getColumn(4).setPreferredWidth(120);
    tablep.getColumnModel().getColumn(5).setPreferredWidth(94);
    tablep.getColumnModel().getColumn(6).setPreferredWidth(140);
    tablep.setRowHeight(20);
    DefaultTableCellRenderer esquerda = new DefaultTableCellRenderer();
    DefaultTableCellRenderer centro = new DefaultTableCellRenderer();
    DefaultTableCellRenderer direita = new DefaultTableCellRenderer();
    esquerda.setHorizontalAlignment(SwingConstants.LEFT);
    centro.setHorizontalAlignment(SwingConstants.CENTER);
    direita.setHorizontalAlignment(SwingConstants.RIGHT);
    tablep.getColumnModel().getColumn(3).setCellRenderer(centro);
    tablep.getColumnModel().getColumn(4).setCellRenderer(centro);
    tablep.getColumnModel().getColumn(5).setCellRenderer(centro);
    JTableHeader cabecalho = tablep.getTableHeader();
    cabecalho.setFont(new Font("Leelawadee UI", Font.PLAIN, 12));
    AbtToolTipHeader tooltipHeader = new AbtToolTipHeader(tablep.getColumnModel());
    // Seta a table header de tooltips
    tablep.setTableHeader(tooltipHeader);
    tooltipHeader.addToolTipToColumn(// Coluna 0
    1, "Nome do projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    2, "Descrição do projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    3, "Data de início do projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    4, "Data aproximada para término do projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    5, "Data de término do projeto");
    tooltipHeader.addToolTipToColumn(// Coluna 0
    6, "Recursos financeiros para execução do projeto (R$)");
    ((DefaultTableCellRenderer) tablep.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
    panelProjetos.setLayout(null);
    panelProjetos.add(tablep);
    JScrollPane scrollPane4 = new JScrollPane(tablep);
    scrollPane4.setBounds(4, 60, 570, 467);
    // só mostra a barra vertical se necessário
    scrollPane4.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // só mostra a barra horizontal se necessário
    scrollPane4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    panelProjetos.add(scrollPane4);
}
Also used : JScrollPane(javax.swing.JScrollPane) MatteBorder(javax.swing.border.MatteBorder) JTable(javax.swing.JTable) Color(java.awt.Color) SystemColor(java.awt.SystemColor) JTableHeader(javax.swing.table.JTableHeader) Font(java.awt.Font) DefaultTableCellRenderer(javax.swing.table.DefaultTableCellRenderer)

Aggregations

DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)85 JTable (javax.swing.JTable)30 TableColumn (javax.swing.table.TableColumn)27 Component (java.awt.Component)21 JScrollPane (javax.swing.JScrollPane)20 DefaultTableModel (javax.swing.table.DefaultTableModel)17 TableCellRenderer (javax.swing.table.TableCellRenderer)17 JLabel (javax.swing.JLabel)14 MouseEvent (java.awt.event.MouseEvent)12 JComponent (javax.swing.JComponent)12 Dimension (java.awt.Dimension)11 Font (java.awt.Font)11 JTableHeader (javax.swing.table.JTableHeader)11 BorderLayout (java.awt.BorderLayout)9 Color (java.awt.Color)9 GridBagConstraints (java.awt.GridBagConstraints)9 Insets (java.awt.Insets)9 JPanel (javax.swing.JPanel)9 GridBagLayout (java.awt.GridBagLayout)7 Point (java.awt.Point)7