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:edu.ucla.stat.SOCR.motionchart.MotionMouseListener.java

protected JPanel getPanel(final JDialog dialog, DefaultTableModel tModel, ArrayList<String> rowIdentifiers) {
    JPanel panel = new JPanel();
    JButton close = new JButton("Close");
    close.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);/*  w  ww.j  av  a 2s .c  o  m*/
        }
    });
    close.setAlignmentX(Component.CENTER_ALIGNMENT);

    RowHeaderTable table = new RowHeaderTable(tModel);
    table.getDataTable().setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.getDataTable().setDefaultRenderer(Object.class, new ColorRenderer(false));
    table.setCellsEditable(false);
    table.setHeadersEditable(false);

    for (int r = 0; r < tModel.getRowCount() && rowIdentifiers.size() <= tModel.getRowCount(); r++) {
        table.getRowHeaderModel().setValueAt(rowIdentifiers.get(r), r, 0);
    }

    Dimension d = table.getRowHeaderTable().getPreferredScrollableViewportSize();
    d.width = 55;
    table.getRowHeaderTable().setPreferredScrollableViewportSize(d);

    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(table);
    panel.add(Box.createRigidArea(new Dimension(0, 5)));
    panel.add(close);

    return panel;
}

From source file:com.vgi.mafscaling.ClosedLoop.java

private void createLogDataTable(JScrollPane dataScrollPane) {
    JPanel dataRunPanel = new JPanel();
    dataScrollPane.setViewportView(dataRunPanel);
    GridBagLayout gbl_dataRunPanel = new GridBagLayout();
    gbl_dataRunPanel.columnWidths = new int[] { 0 };
    gbl_dataRunPanel.rowHeights = new int[] { 0 };
    gbl_dataRunPanel.columnWeights = new double[] { 0.0 };
    gbl_dataRunPanel.rowWeights = new double[] { 0.0 };
    dataRunPanel.setLayout(gbl_dataRunPanel);

    logDataTable = new JTable();
    logDataTable.getTableHeader().setReorderingAllowed(false);
    logDataTable.setModel(new DefaultTableModel(LogDataRowCount, ColumnCount));
    logDataTable.setColumnSelectionAllowed(true);
    logDataTable.setCellSelectionEnabled(true);
    logDataTable.setBorder(new LineBorder(new Color(0, 0, 0)));
    logDataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    logDataTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    logDataTable.getColumnModel().getColumn(0).setHeaderValue("Time");
    logDataTable.getColumnModel().getColumn(1).setHeaderValue("Load");
    logDataTable.getColumnModel().getColumn(2).setHeaderValue("RPM");
    logDataTable.getColumnModel().getColumn(3).setHeaderValue("MafV");
    logDataTable.getColumnModel().getColumn(4).setHeaderValue("AFR");
    logDataTable.getColumnModel().getColumn(5).setHeaderValue("STFT");
    logDataTable.getColumnModel().getColumn(6).setHeaderValue("LTFT");
    logDataTable.getColumnModel().getColumn(7).setHeaderValue("dV/dt");
    logDataTable.getColumnModel().getColumn(8).setHeaderValue("IAT");
    Utils.initializeTable(logDataTable, ColumnWidth);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(0, 0, 0, 0);
    gbc.anchor = GridBagConstraints.PAGE_START;
    gbc.gridx = 0;//from  ww  w  .  j  a  v a 2 s. co m
    gbc.gridy = 0;

    dataRunPanel.add(logDataTable.getTableHeader(), gbc);
    gbc.gridy = 1;
    dataRunPanel.add(logDataTable, gbc);

    excelAdapter.addTable(logDataTable, true, false);
}

From source file:GeMSE.GS.Analysis.Stats.OneSampleCovariancePanel.java

private void GridView(double[][] matrix) {
    DefaultTableModel spaceTabMod = new DefaultTableModel() {
        @Override//from   w ww .j a  v a2 s .c om
        public boolean isCellEditable(int row, int column) {
            return false;
        }
    };

    String[] columnTitle = new String[matrix[0].length + 1];
    columnTitle[0] = "";
    for (int col = 1; col < columnTitle.length; col++)
        columnTitle[col] = "Column " + String.valueOf(col);
    spaceTabMod.setColumnIdentifiers(columnTitle);

    int col = 0;
    for (int r = 0; r < matrix.length; r++) {
        String[] row = new String[matrix[0].length + 1];
        row[0] = "Row " + Integer.toString(r);

        for (col = 0; col < matrix[0].length; col++)
            row[col + 1] = Double.toString(matrix[r][col]);

        spaceTabMod.addRow(row);
    }

    matrixDG.setModel(spaceTabMod);
    matrixDG.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    matrixDG.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    ResizeColumnWidth(matrixDG);
}

From source file:com.sec.ose.osi.ui.frm.main.manage.ManagedProjectTableModel.java

public void setColumnType(JTable table) {
    table.setShowVerticalLines(false);/*from w w w .ja  v  a 2 s  . c om*/
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setColumnSelectionAllowed(false);
    table.setRowSelectionAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    table.setRowHeight(30);

    JTableHeader header = table.getTableHeader();
    header.setPreferredSize(new java.awt.Dimension(table.getTableHeader().getWidth(), 30));
    header.setFont(new Font("Arial", Font.BOLD, 12));
    header.setReorderingAllowed(false);

    TableColumnModel cm = table.getColumnModel();
    TableColumn col = null;

    analyzeHeader = new CheckBoxHeader(new CheckboxHeaderItemListener(table, COL_ANALYZE_TARGET),
            "Analyze Target");
    col = cm.getColumn(COL_ANALYZE_TARGET);
    col.setHeaderRenderer(analyzeHeader);

    JCheckBox chkbox = new JCheckBox();
    chkbox.setBackground(Color.white);
    chkbox.setHorizontalAlignment(JLabel.CENTER);
    col.setCellRenderer(new DefaultTableCellRenderer() {
        private static final long serialVersionUID = 1L;

        public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            ManagedProjectTableModel model = (ManagedProjectTableModel) table.getModel();

            String sPrjName = (String) table.getValueAt(row, ManagedProjectTableModel.COL_PROJECT_NAME);
            OSIProjectInfo item = model.getProjectInfo(sPrjName);

            JCheckBox chkbox = new JCheckBox();
            chkbox.setSelected(((Boolean) value).booleanValue());
            if (item != null) {
                chkbox.setEnabled(item.isLocationValid());
            }
            chkbox.setHorizontalAlignment(JLabel.CENTER);
            chkbox.setBackground(Color.white);

            return (Component) chkbox;
        }
    });
    col.setCellEditor(new DefaultCellEditor(chkbox));

    col = cm.getColumn(COL_ANALYZE_STATUS);
    col.setCellRenderer(new StatusIconCellRenderer());

    col = cm.getColumn(COL_SOURCE_LOCATION);
    col.setCellRenderer(new FileBrowseCellRenderer());
    col.setCellEditor(new FileBrowseCellEditor());
}

From source file:com.diversityarrays.kdxplore.field.FieldViewPanel.java

public FieldViewPanel(PlotVisitList plotVisitList, Map<Integer, Trait> traitMap,
        SeparatorVisibilityOption visible, SimplePlotCellRenderer plotRenderer, Component... extras) {
    super(new BorderLayout());

    this.plotVisitList = plotVisitList;
    this.traitMap = traitMap;

    trial = plotVisitList.getTrial();//from  w w  w  .  j  a  va  2 s.c  o  m

    fieldLayoutTableModel.setTrial(trial);

    int rowHeight = fieldLayoutTable.getRowHeight();
    fieldLayoutTable.setRowHeight(4 * rowHeight);

    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    // IMPORTANT: DO NOT SORT THE FIELD LAYOUT TABLE
    fieldLayoutTable.setAutoCreateRowSorter(false);

    Map<Integer, Plot> plotById = new HashMap<>();
    FieldLayout<Integer> plotIdLayout = FieldLayoutUtil.createPlotIdLayout(trial.getTrialLayout(),
            trial.getPlotIdentSummary(), plotVisitList.getPlots(), plotById);

    KdxploreFieldLayout<Plot> kdxFieldLayout = new KdxploreFieldLayout<Plot>(Plot.class, plotIdLayout.imageId,
            plotIdLayout.xsize, plotIdLayout.ysize);
    kdxFieldLayout.warning = plotIdLayout.warning;

    String displayName = null;
    for (VisitOrder2D vo : VisitOrder2D.values()) {
        if (vo.imageId == plotIdLayout.imageId) {
            displayName = vo.displayName;
            break;
        }
    }
    //      VisitOrder2D vo = plotVisitList.getVisitOrder();
    KDClientUtils.initAction(plotIdLayout.imageId, changeCollectionOrder, displayName);

    hasUserPlotId = lookForUserPlotIdPresent(plotById, plotIdLayout, kdxFieldLayout);

    this.plotCellRenderer = plotRenderer;
    plotCellRenderer.setShowUserPlotId(hasUserPlotId);

    plotCellRenderer.setPlotXYprovider(getXYprovider());

    plotCellRenderer.setPlotVisitList(plotVisitList);

    fieldLayoutTable.setDefaultRenderer(Plot.class, plotCellRenderer);
    fieldLayoutTable.setCellSelectionEnabled(true);

    fieldLayoutTableModel.setFieldLayout(kdxFieldLayout);

    if (kdxFieldLayout.warning != null && !kdxFieldLayout.warning.isEmpty()) {
        warningMessage.setText(kdxFieldLayout.warning);
    } else {
        warningMessage.setText("");
    }

    fieldLayoutTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    fieldLayoutTable.getTableHeader().setReorderingAllowed(false);
    fieldLayoutTable.setCellSelectionEnabled(true);

    StringBuilder naming = new StringBuilder();
    String nameForRow = plotVisitList.getTrial().getNameForRow();
    if (!Check.isEmpty(nameForRow)) {
        naming.append(nameForRow);
    }
    String nameForCol = plotVisitList.getTrial().getNameForColumn();
    if (!Check.isEmpty(nameForCol)) {
        if (naming.length() > 0) {
            naming.append('/');
        }
        naming.append(nameForCol);
    }
    fieldTableScrollPane = new JScrollPane(fieldLayoutTable);
    if (naming.length() > 0) {
        JLabel cornerLabel = new JLabel(naming.toString());
        fieldTableScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, cornerLabel);
    }
    fieldTableScrollPane.setRowHeaderView(rowHeaderTable);

    //      fieldLayoutTable.setRowHeaderTable(rowHeaderTable);

    //      Box extra = Box.createHorizontalBox();
    //      extra.add(new JButton(changeCollectionOrder));
    //      if (extras != null && extras.length > 0) {
    //         extra.add(Box.createHorizontalStrut(8));
    //         for (Component c : extras) {
    //            extra.add(c);
    //         }
    //      }
    //      extra.add(Box.createHorizontalGlue());

    switch (visible) {
    case NOTVISIBLE:
        break;

    case VISIBLE:
    default:
        Box top = Box.createHorizontalBox();
        top.setOpaque(true);
        top.setBackground(Color.LIGHT_GRAY);
        top.setBorder(new MatteBorder(0, 0, 1, 0, Color.GRAY));
        JLabel label = new JLabel("Field");
        label.setForeground(Color.DARK_GRAY);
        label.setFont(label.getFont().deriveFont(Font.BOLD));
        top.add(label);
        top.add(new JButton(changeCollectionOrder));

        if (extras != null && extras.length > 0) {
            top.add(Box.createHorizontalStrut(8));
            for (Component c : extras) {
                top.add(c);
            }
        }
        add(top, BorderLayout.NORTH);
        break;
    }

    add(fieldTableScrollPane, BorderLayout.CENTER);
    add(warningMessage, BorderLayout.SOUTH);
}

From source file:Visuals.RingChart.java

public JPanel addDefenceCharts() {
    lowValue = "Low (" + low + ")";
    ChartPanel ringPanel = drawRingChart();
    ringPanel.setDomainZoomable(true);/*  www . ja  va2s  .c  o m*/
    JPanel thisRingPanel = new JPanel();
    thisRingPanel.setLayout(new BorderLayout());
    String[][] finalRisks = new String[riskCount][4];
    for (int i = 0; i < riskCount; i++) {
        finalRisks[i][0] = risks[i][0];
        finalRisks[i][1] = risks[i][1];
        finalRisks[i][2] = risks[i][2];
        finalRisks[i][3] = risks[i][3];
    }

    JTable table = new JTable(finalRisks, networkDefenceColumns);
    TableColumn tcol = table.getColumnModel().getColumn(2);
    table.removeColumn(tcol);
    table.setEnabled(false);

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    int width = 0;
    for (int row = 0; row < table.getRowCount(); row++) {
        TableCellRenderer renderer = table.getCellRenderer(row, 1);
        Component comp = table.prepareRenderer(renderer, row, 1);
        width = Math.max(comp.getPreferredSize().width, width);
    }

    table.getColumnModel().getColumn(1).setPreferredWidth(width);

    width = 0;
    for (int row = 0; row < table.getRowCount(); row++) {
        TableCellRenderer renderer = table.getCellRenderer(row, 2);
        Component comp = table.prepareRenderer(renderer, row, 2);
        width = Math.max(comp.getPreferredSize().width, width);
    }

    table.getColumnModel().getColumn(2).setPreferredWidth(width);
    table.setShowHorizontalLines(true);
    table.setRowHeight(40);

    JScrollPane tableScrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    Dimension d = table.getPreferredSize();
    tableScrollPane
            .setPreferredSize(new Dimension((d.width - 400), (table.getRowHeight() + 1) * (riskCount + 1)));

    JLabel right = new JLabel(
            "                                                                                                    ");
    thisRingPanel.add(right, BorderLayout.EAST);
    thisRingPanel.add(ringPanel, BorderLayout.CENTER);
    thisRingPanel.add(tableScrollPane, BorderLayout.SOUTH);
    return thisRingPanel;
}

From source file:ru.develgame.jflickrorganizer.MainForm.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./* ww  w  .ja  va  2 s.  co  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jLabelBackupFolder = new javax.swing.JLabel();
    jTextFieldBackupFolder = new javax.swing.JTextField();
    jButtonChooseBackupFolder = new javax.swing.JButton();
    jButtonBackup = new javax.swing.JButton();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTreeAlbums = new javax.swing.JTree();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTablePhotos = new JTable() {
        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
            Component component = super.prepareRenderer(renderer, row, column);
            int rendererWidth = component.getPreferredSize().width + 5;
            TableColumn tableColumn = getColumnModel().getColumn(column);
            tableColumn.setPreferredWidth(
                    Math.max(rendererWidth + getIntercellSpacing().width, tableColumn.getPreferredWidth()));
            return component;
        }
    };
    jComboBoxVisibility = new javax.swing.JComboBox<>();
    jPanel1 = new javax.swing.JPanel();
    jLabelAll = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItemSetPassword = new javax.swing.JMenuItem();
    jMenuItemExit = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("MainForm"); // NOI18N
    setTitle(bundle.getString("MainForm.title")); // NOI18N
    setMinimumSize(new java.awt.Dimension(1024, 717));
    setName("Form"); // NOI18N

    jLabelBackupFolder.setText(bundle.getString("MainForm.jLabelBackupFolder.text")); // NOI18N
    jLabelBackupFolder.setName("jLabelBackupFolder"); // NOI18N

    jTextFieldBackupFolder.setName("jTextFieldBackupFolder"); // NOI18N

    jButtonChooseBackupFolder.setText(bundle.getString("MainForm.jButtonChooseBackupFolder.text")); // NOI18N
    jButtonChooseBackupFolder.setName("jButtonChooseBackupFolder"); // NOI18N
    jButtonChooseBackupFolder.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonChooseBackupFolderActionPerformed(evt);
        }
    });

    jButtonBackup.setText(bundle.getString("MainForm.jButtonBackup.text")); // NOI18N
    jButtonBackup.setName("jButtonBackup"); // NOI18N
    jButtonBackup.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButtonBackupActionPerformed(evt);
        }
    });

    jScrollPane1.setName("jScrollPane1"); // NOI18N

    jTreeAlbums.setName("jTreeAlbums"); // NOI18N
    jScrollPane1.setViewportView(jTreeAlbums);

    jScrollPane2.setName("jScrollPane2"); // NOI18N

    jTablePhotos.setAutoCreateRowSorter(true);
    jTablePhotos.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] {

    }));
    jTablePhotos.setToolTipText(bundle.getString("MainForm.jTablePhotos.toolTipText")); // NOI18N
    jTablePhotos.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
    jTablePhotos.setName("jTablePhotos"); // NOI18N
    jTablePhotos.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    jScrollPane2.setViewportView(jTablePhotos);

    jComboBoxVisibility.setName("jComboBoxVisibility"); // NOI18N

    jPanel1.setName("jPanel1"); // NOI18N

    jLabelAll.setText(bundle.getString("MainForm.jLabelAll.text")); // NOI18N
    jLabelAll.setName("jLabelAll"); // NOI18N

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            jPanel1Layout.createSequentialGroup()
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabelAll).addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE).addComponent(jLabelAll)));

    jMenuBar1.setName("jMenuBar1"); // NOI18N

    jMenu1.setText(bundle.getString("MainForm.jMenu1.text")); // NOI18N
    jMenu1.setName("jMenu1"); // NOI18N

    jMenuItemSetPassword.setText(bundle.getString("MainForm.jMenuItemSetPassword.text")); // NOI18N
    jMenuItemSetPassword.setName("jMenuItemSetPassword"); // NOI18N
    jMenuItemSetPassword.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemSetPasswordActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItemSetPassword);

    jMenuItemExit.setText(bundle.getString("MainForm.jMenuItemExit.text")); // NOI18N
    jMenuItemExit.setName("jMenuItemExit"); // NOI18N
    jMenuItemExit.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItemExitActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItemExit);

    jMenuBar1.add(jMenu1);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(jLabelBackupFolder)
                                    .addGap(68, 68, 68).addComponent(jTextFieldBackupFolder)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButtonChooseBackupFolder)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButtonBackup))
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 213,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    784, Short.MAX_VALUE)
                                            .addGroup(layout.createSequentialGroup()
                                                    .addComponent(jComboBoxVisibility,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 271,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(0, 0, Short.MAX_VALUE)))))
                    .addContainerGap())
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                    Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
            javax.swing.GroupLayout.Alignment.TRAILING,
            layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextFieldBackupFolder, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButtonBackup).addComponent(jButtonChooseBackupFolder)
                    .addComponent(jLabelBackupFolder))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(jComboBoxVisibility, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 590,
                                            Short.MAX_VALUE))
                            .addComponent(jScrollPane1))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jPanel1,
                            javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            javax.swing.GroupLayout.PREFERRED_SIZE)));

    pack();
}

From source file:com.alvermont.terraj.stargen.ui.SystemFrame.java

/**
 * Fill in the details on the overview panel
 *//* w w w  .j  ava  2s  .c om*/
public void populateOverview() {
    DefaultTableModel dtm = (DefaultTableModel) overviewTable.getModel();

    for (Planet p : this.planets) {
        Object[] row = new Object[6];

        row[0] = new Integer(p.getNumber());
        row[1] = p.getType().getPrintText(p.getType());
        row[2] = String.format("%.3f AU", p.getA());
        row[3] = String.format("%.3f EM", p.getMass() * Constants.SUN_MASS_IN_EARTH_MASSES);
        row[4] = String.format("%.3f ER", p.getRadius() / Constants.KM_EARTH_RADIUS);
        row[5] = new JButton("Details ...");

        dtm.addRow(row);
    }

    // Disable auto resizing
    overviewTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    // Set the first visible column to 100 pixels wide
    TableColumn col = overviewTable.getColumnModel().getColumn(0);
    int width = 50;
    col.setPreferredWidth(width);
    overviewTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
}

From source file:gdt.jgui.entity.query.JQueryPanel.java

/**
 * The default constructor./*from  w w w . j  a va 2s  .c om*/
 */
public JQueryPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 100, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0 };
    setLayout(gridBagLayout);
    JLabel lblElement = new JLabel("Element");

    GridBagConstraints gbc_lblElement = new GridBagConstraints();
    gbc_lblElement.insets = new Insets(5, 5, 5, 5);
    gbc_lblElement.gridx = 0;
    gbc_lblElement.gridy = 0;
    gbc_lblElement.anchor = GridBagConstraints.FIRST_LINE_START;
    add(lblElement, gbc_lblElement);

    elementComboBox = new JComboBox<String>();
    GridBagConstraints gbc_elementComboBox = new GridBagConstraints();
    gbc_elementComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_elementComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_elementComboBox.gridx = 1;
    gbc_elementComboBox.gridy = 0;
    gbc_elementComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(elementComboBox, gbc_elementComboBox);
    elementComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemNameSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });
    JLabel lblItemNameField = new JLabel("Item field");
    GridBagConstraints gbc_lblItemField = new GridBagConstraints();
    gbc_lblItemField.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemField.gridx = 0;
    gbc_lblItemField.gridy = 1;
    gbc_lblItemField.anchor = GridBagConstraints.FIRST_LINE_START;

    add(lblItemNameField, gbc_lblItemField);

    itemNameFieldComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemNameFieldComboBox = new GridBagConstraints();
    gbc_itemNameFieldComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemNameFieldComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemNameFieldComboBox.gridx = 1;
    gbc_itemNameFieldComboBox.gridy = 1;
    gbc_itemNameFieldComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemNameFieldComboBox, gbc_itemNameFieldComboBox);
    itemNameFieldComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemNameSelector();
                initItemValueSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });
    JLabel itemTitle = new JLabel("Item title");
    GridBagConstraints gbc_lblItemtitle = new GridBagConstraints();
    gbc_lblItemtitle.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemtitle.gridx = 0;
    gbc_lblItemtitle.gridy = 2;
    gbc_lblItemtitle.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemTitle, gbc_lblItemtitle);

    itemNameComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemComboBox = new GridBagConstraints();
    gbc_itemComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemComboBox.gridx = 1;
    gbc_itemComboBox.gridy = 2;
    gbc_itemComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemNameComboBox, gbc_itemComboBox);
    itemNameComboBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            try {
                initItemValueSelector();
            } catch (Exception ee) {
                LOGGER.severe(ee.toString());
            }
        }
    });

    JLabel itemValue = new JLabel("Item value");
    GridBagConstraints gbc_lblItemValue = new GridBagConstraints();
    gbc_lblItemValue.insets = new Insets(5, 5, 5, 5);
    gbc_lblItemValue.weighty = 0.0;
    gbc_lblItemValue.gridx = 0;
    gbc_lblItemValue.gridy = 3;
    gbc_lblItemValue.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemValue, gbc_lblItemValue);

    itemValueComboBox = new JComboBox<String>();
    GridBagConstraints gbc_itemValueComboBox = new GridBagConstraints();
    gbc_itemValueComboBox.insets = new Insets(0, 0, 5, 0);
    gbc_itemValueComboBox.fill = GridBagConstraints.HORIZONTAL;
    gbc_itemValueComboBox.gridx = 1;
    gbc_itemValueComboBox.gridy = 3;
    gbc_itemValueComboBox.anchor = GridBagConstraints.FIRST_LINE_START;
    add(itemValueComboBox, gbc_itemValueComboBox);
    table = new JTable();
    JScrollPane scrollPane = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    table.addMouseListener(new java.awt.event.MouseAdapter() {
        @Override
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            int row = table.rowAtPoint(evt.getPoint());
            int col = table.columnAtPoint(evt.getPoint());
            System.out.println("JQueryPanel:cell click:row=" + row + " column=" + col);
            if (col == 1) {
                String label$ = (String) table.getValueAt(row, 1);
                System.out.println("JQueryPanel:cell click:label=" + label$);
                Entigrator entigrator = console.getEntigrator(entihome$);
                String entity$ = entigrator.indx_keyAtLabel(label$);
                JEntityFacetPanel efp = new JEntityFacetPanel();
                String efpLocator$ = efp.getLocator();
                efpLocator$ = Locator.append(efpLocator$, Entigrator.ENTIHOME, entihome$);
                efpLocator$ = Locator.append(efpLocator$, EntityHandler.ENTITY_KEY, entity$);
                JConsoleHandler.execute(console, efpLocator$);
            }
        }
    });
    GridBagConstraints gbc_scroll_panel = new GridBagConstraints();
    gbc_scroll_panel.anchor = GridBagConstraints.NORTH;
    gbc_scroll_panel.gridwidth = 2;
    gbc_scroll_panel.weighty = 1.0;
    gbc_scroll_panel.fill = GridBagConstraints.HORIZONTAL;
    gbc_scroll_panel.gridx = 0;
    gbc_scroll_panel.gridy = 4;
    add(scrollPane, gbc_scroll_panel);
    scrollPane.setMinimumSize(scrollPane.getPreferredSize());
}

From source file:com.projity.pm.graphic.spreadsheet.common.CommonSpreadSheet.java

protected void initModel() {

    GraphicConfiguration config = GraphicConfiguration.getInstance();
    setRowHeight(config.getRowHeight());
    setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    setCellSelectionEnabled(true);/* w  w w.  j ava2s .c  o  m*/
    //setRowSelectionAllowed(true);
    //setColumnSelectionAllowed(true);
}