Example usage for javax.swing JTable AUTO_RESIZE_OFF

List of usage examples for javax.swing JTable AUTO_RESIZE_OFF

Introduction

In this page you can find the example usage for javax.swing JTable AUTO_RESIZE_OFF.

Prototype

int AUTO_RESIZE_OFF

To view the source code for javax.swing JTable AUTO_RESIZE_OFF.

Click Source Link

Document

Do not adjust column widths automatically; use a horizontal scrollbar instead.

Usage

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingSecAppFinderJPanel.java

public CFAsteriskSwingSecAppFinderJPanel(ICFAsteriskSwingSchema argSchema) {
    super();//w  w w. j a  v a2 s  .c o m
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingTSecGroupFinderJPanel.java

public CFAsteriskSwingTSecGroupFinderJPanel(ICFAsteriskSwingSchema argSchema) {
    super();/*w w w  .  ja  va  2  s .c  o  m*/
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingAuditActionFinderJPanel.java

public CFAsteriskSwingAuditActionFinderJPanel(ICFAsteriskSwingSchema argSchema) {
    super();//from  ww  w . j  ava 2 s.  c om
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSwing.CFAsteriskSwingServiceTypeFinderJPanel.java

public CFAsteriskSwingServiceTypeFinderJPanel(ICFAsteriskSwingSchema argSchema) {
    super();//www.j  a  v  a  2 s  . c o  m
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:com.qspin.qtaste.ui.xmleditor.TestRequirementEditor.java

private void genUI() {
    getActionMap().put("Save", new SaveAction());
    getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save");
    m_TestRequirementTable = new JTable() {

        @Override//from w  w  w.  j  ava 2s  .  c o m
        public String getToolTipText(MouseEvent e) {
            Point p = e.getPoint();
            int rowIndex = rowAtPoint(p);
            int colIndex = columnAtPoint(p);
            if (colIndex < 0) {
                return null;
            }
            return convertObjectToToolTip(getValueAt(rowIndex, colIndex));
        }

        // overwrite cell content when typing on a selected cell
        @Override
        public Component prepareEditor(TableCellEditor editor, int row, int column) {
            Component c = super.prepareEditor(editor, row, column);

            if (c instanceof JTextComponent) {
                ((JTextField) c).selectAll();
            }

            return c;
        }

        // select entire rows when selecting first column (row id)
        @Override
        public void columnSelectionChanged(ListSelectionEvent e) {
            if (e.getFirstIndex() == 0 && e.getValueIsAdjusting()) {
                setColumnSelectionInterval(1, getColumnCount() - 1);
            } else {
                super.columnSelectionChanged(e);
            }
        }
    };
    m_TestRequirementTable.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    m_TestRequirementModel = new TestRequirementTableModel();

    m_TestRequirementTable.setModel(m_TestRequirementModel);

    m_TableColumnModelListener = new MyTableColumnModelListener();
    m_TestRequirementTable.setSurrendersFocusOnKeystroke(true);
    m_TestRequirementTable.setColumnSelectionAllowed(true);
    m_TestRequirementTable.addMouseListener(new TableMouseListener(m_TestRequirementTable));
    m_TestRequirementTable.getTableHeader().addMouseListener(new TableMouseListener(m_TestRequirementTable));
    m_TestRequirementTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    m_TestRequirementTable.getActionMap().put("Save", new SaveAction());
    m_TestRequirementTable.setDefaultEditor(String.class, new TestDataTableCellEditor());
    m_TestRequirementTable.setDefaultEditor(Integer.class, new TestDataTableCellEditor());
    m_TestRequirementTable.getTableHeader().getInputMap()
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK), "Save");
    m_TestRequirementTable.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK),
            "Save");
    m_TestRequirementTable.setRowHeight(ROW_HEIGHT);

    m_TestRequirementTable.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            //
            if (e.getKeyCode() == KeyEvent.VK_UP) {
                // check if previous line is empty
            }
            if (e.getKeyCode() == KeyEvent.VK_DOWN) {
                // if current row is the last one
                if (m_TestRequirementTable.getSelectedRow() == m_TestRequirementTable.getRowCount() - 1) {
                    addNewRow();
                }
            }
            if ((e.getKeyCode() == KeyEvent.VK_S) && (e.isControlDown())) {
                save();
            }
            if ((e.getKeyCode() == KeyEvent.VK_C) && (e.isControlDown())) {
                copySelectionToClipboard();
            }
            if ((e.getKeyCode() == KeyEvent.VK_V) && (e.isControlDown())) {
                if (m_TestRequirementTable.getSelectedColumn() != 0) {
                    pasteSelectionFromClipboard();
                }
            }
        }
    });

    tableListener = new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            // build the test data
            if (e.getType() == TableModelEvent.UPDATE) {
                if (e.getFirstRow() >= 0) {
                    setModified(true);
                }
            }
        }
    };
    m_TestRequirementModel.addTableModelListener(tableListener);

    JScrollPane sp = new JScrollPane(m_TestRequirementTable);
    sp.addMouseListener(new TableMouseListener(null));
    add(sp);
}

From source file:org.onesun.sdi.swing.app.views.DataServicesView.java

private void addControlsToPanel() {
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setAutoscrolls(true);/*from   w w  w . ja va 2s.co m*/

    JPanel panel = null;

    panel = new JPanel(new SpringLayout());
    panel.add(copyDataButton);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    panel.add(containerPanel);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel.add(executeButton);
    panel.add(computeMetricsButton);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    JLabel label = new JLabel("Enriched Data", JLabel.LEADING);
    label.setPreferredSize(new Dimension(150, 24));
    scrollPane.setPreferredSize(new Dimension(250, 900));

    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    panel.add(label);
    label.setLabelFor(scrollPane);
    panel.add(scrollPane);
    SpringLayoutUtils.makeCompactGrid(panel, 2, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(rowCountLabel);
    this.add(panel);
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingTldFinderJPanel.java

public CFAccSwingTldFinderJPanel(ICFAccSwingSchema argSchema) {
    super();/*from  w  ww  .  ja v a  2 s  . c  o m*/
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAstSwing.CFAstSwingTldFinderJPanel.java

public CFAstSwingTldFinderJPanel(ICFAstSwingSchema argSchema) {
    super();/*from   w  w w.ja v  a 2  s . c o m*/
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_2.CFAstSwing.CFAstSwingSysClusterFinderJPanel.java

public CFAstSwingSysClusterFinderJPanel(ICFAstSwingSchema argSchema) {
    super();/* www  .ja  va2  s  .com*/
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}

From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAccSwing.CFAccSwingTenantFinderJPanel.java

public CFAccSwingTenantFinderJPanel(ICFAccSwingSchema argSchema) {
    super();/*from   w ww .  java2s .c  o  m*/
    final String S_ProcName = "construct-schema-focus";
    if (argSchema == null) {
        throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 1,
                "argSchema");
    }
    swingSchema = argSchema;
    dataTable = new JTable(getDataModel(), getDataColumnModel(), getDataListSelectionModel());
    dataTable.addMouseListener(getDataListMouseAdapter());
    dataTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setUpdateSelectionOnSort(true);
    dataTable.setRowHeight(25);
    getDataListSelectionModel().addListSelectionListener(getDataListSelectionListener());
    dataScrollPane = new JScrollPane(dataTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    dataScrollPane.setColumnHeader(new JViewport() {
        @Override
        public Dimension getPreferredSize() {
            Dimension sz = super.getPreferredSize();
            sz.height = 25;
            return (sz);
        }
    });
    dataTable.setFillsViewportHeight(true);
    add(dataScrollPane);
    loadData(true);
    doLayout();
    swingIsInitializing = false;
}