Search in sources :

Example 46 with JTableHeader

use of javax.swing.table.JTableHeader in project beast-mcmc by beast-dev.

the class MapperFrameOld method initializeComponents.

public void initializeComponents() {
    setSize(new java.awt.Dimension(1200, 800));
    mapperPanel = new MapperPanel(this);
    mapperPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(12, 6, 12, 12)));
    traceTableModel = new TraceTableModel();
    traceTable = new JTable(traceTableModel);
    TableRenderer renderer = new TableRenderer(SwingConstants.LEFT, new Insets(0, 4, 0, 4));
    traceTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
    traceTable.getColumnModel().getColumn(1).setPreferredWidth(50);
    traceTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
    traceTable.getColumnModel().getColumn(2).setPreferredWidth(50);
    traceTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
    traceTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    traceTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            traceTableSelectionChanged();
        }
    });
    scrollPane1 = new JScrollPane(traceTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    ActionPanel actionPanel1 = new ActionPanel(false);
    actionPanel1.setAddAction(getImportAction());
    actionPanel1.setRemoveAction(getRemoveTraceAction());
    getRemoveTraceAction().setEnabled(false);
    JPanel controlPanel1 = new JPanel(new FlowLayout(FlowLayout.LEFT));
    controlPanel1.add(actionPanel1);
    topPanel = new JPanel(new BorderLayout(0, 0));
    topPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(0, 0, 6, 0)));
    topPanel.add(new JLabel("Trace Files:"), BorderLayout.NORTH);
    topPanel.add(scrollPane1, BorderLayout.CENTER);
    topPanel.add(controlPanel1, BorderLayout.SOUTH);
    layerTableModel = new LayerTableModel();
    layerTable = new JTable(layerTableModel) {

        //Implement table header tool tips.
        protected JTableHeader createDefaultTableHeader() {
            return new JTableHeader(columnModel) {

                public String getToolTipText(MouseEvent e) {
                    java.awt.Point p = e.getPoint();
                    int index = columnModel.getColumnIndexAtX(p.x);
                    int realIndex = columnModel.getColumn(index).getModelIndex();
                    return columnToolTips[realIndex];
                }
            };
        }
    };
    layerTable.getColumnModel().getColumn(0).setPreferredWidth(150);
    layerTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
    layerTable.getColumnModel().getColumn(1).setPreferredWidth(70);
    layerTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
    //        layerTable.getColumnModel().getColumn(2).setPreferredWidth(70);
    //        layerTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
    //        ComboBoxRenderer comboBoxRenderer = new ComboBoxRenderer(TraceFactory.TraceType.values());
    //        comboBoxRenderer.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    //        layerTable.getColumnModel().getColumn(3).setPreferredWidth(20);
    //        layerTable.getColumnModel().getColumn(3).setCellRenderer(renderer);
    layerTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    layerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent evt) {
            layerTableSelectionChanged();
        }
    });
    TableEditorStopper.ensureEditingStopWhenTableLosesFocus(layerTable);
    JScrollPane scrollPane2 = new JScrollPane(layerTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));
    bottomPanel.add(new JLabel("Layers:"), BorderLayout.NORTH);
    bottomPanel.add(scrollPane2, BorderLayout.CENTER);
    JPanel leftPanel = new JPanel(new BorderLayout(0, 0));
    leftPanel.setPreferredSize(new Dimension(400, 300));
    splitPane1 = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, topPanel, bottomPanel);
    splitPane1.setBorder(null);
    JPanel progressPanel = new JPanel(new BorderLayout(0, 0));
    progressLabel = new JLabel("");
    progressBar = new JProgressBar();
    progressPanel.add(progressLabel, BorderLayout.NORTH);
    progressPanel.add(progressBar, BorderLayout.CENTER);
    progressPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(6, 0, 0, 0)));
    leftPanel.add(splitPane1, BorderLayout.CENTER);
    leftPanel.add(progressPanel, BorderLayout.SOUTH);
    leftPanel.setBorder(new BorderUIResource.EmptyBorderUIResource(new java.awt.Insets(12, 12, 12, 6)));
    JSplitPane splitPane2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, leftPanel, mapperPanel);
    splitPane2.setBorder(null);
    splitPane2.setDividerLocation(350);
    Color focusColor = UIManager.getColor("Focus.color");
    Border focusBorder = BorderFactory.createMatteBorder(2, 2, 2, 2, focusColor);
    splitPane1.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    new FileDrop(null, splitPane1, focusBorder, new FileDrop.Listener() {

        public void filesDropped(java.io.File[] files) {
            importFiles(files);
        }
    });
    // end FileDrop.Listener
    getContentPane().setLayout(new java.awt.BorderLayout(0, 0));
    getContentPane().add(splitPane2, BorderLayout.CENTER);
    splitPane1.setDividerLocation(2000);
}
Also used : BorderUIResource(javax.swing.plaf.BorderUIResource) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JTableHeader(javax.swing.table.JTableHeader) FileDrop(dr.app.gui.FileDrop) TableRenderer(jam.table.TableRenderer) MapperPanel(dr.app.mapper.application.mapper.MapperPanel) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionPanel(jam.panels.ActionPanel) Border(javax.swing.border.Border) java.awt(java.awt)

Example 47 with JTableHeader

use of javax.swing.table.JTableHeader in project jgnash by ccavanaugh.

the class AccountRowFooterPanel method layoutMainPanel.

private void layoutMainPanel() {
    FormLayout layout = new FormLayout("d:g", "d");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout, this);
    setLayout(layout);
    table = new SummaryTable(summaryModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setFocusable(false);
    table.setCellSelectionEnabled(false);
    JTableHeader tableHeader = new JTableHeader(table.getColumnModel());
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    tableHeader.setTable(table);
    builder.add(table, CC.xy(1, 1));
    header = buildHeader(tableHeader);
    footer = buildFooter();
    setBorder(ShadowBorder.getCompondShadowBorder());
    JTableUtils.packTables(table, footerTable);
    ToolTipManager.sharedInstance().unregisterComponent(table);
    ToolTipManager.sharedInstance().unregisterComponent(tableHeader);
}
Also used : FormLayout(com.jgoodies.forms.layout.FormLayout) DefaultFormBuilder(com.jgoodies.forms.builder.DefaultFormBuilder) JTableHeader(javax.swing.table.JTableHeader)

Aggregations

JTableHeader (javax.swing.table.JTableHeader)47 JTable (javax.swing.JTable)15 TableCellRenderer (javax.swing.table.TableCellRenderer)13 TableColumn (javax.swing.table.TableColumn)12 TableColumnModel (javax.swing.table.TableColumnModel)12 Component (java.awt.Component)9 JLabel (javax.swing.JLabel)7 JScrollPane (javax.swing.JScrollPane)7 MouseEvent (java.awt.event.MouseEvent)6 BorderLayout (java.awt.BorderLayout)5 MouseAdapter (java.awt.event.MouseAdapter)5 JButton (javax.swing.JButton)5 JPopupMenu (javax.swing.JPopupMenu)5 DefaultTableCellRenderer (javax.swing.table.DefaultTableCellRenderer)5 JCheckBoxMenuItem (javax.swing.JCheckBoxMenuItem)4 JComponent (javax.swing.JComponent)4 JPanel (javax.swing.JPanel)4 DefaultTableColumnModel (javax.swing.table.DefaultTableColumnModel)4 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3