Example usage for javax.swing JTable AUTO_RESIZE_ALL_COLUMNS

List of usage examples for javax.swing JTable AUTO_RESIZE_ALL_COLUMNS

Introduction

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

Prototype

int AUTO_RESIZE_ALL_COLUMNS

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

Click Source Link

Document

During all resize operations, proportionately resize all columns.

Usage

From source file:gtu._work.ui.JSFMakerUI_attrDialog.java

private void initGUI() {
    try {//from   w ww  .j  ava 2  s . co m
        final SwingActionUtil actionUtil = SwingActionUtil.newInstance(this);
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("attribute", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(379, 233));
                    {
                        DefaultTableModel model = JTableUtil.createModel(true, "enable", "attribute", "value");
                        attrTable = new JTable();

                        //XXX defnine attribute
                        model.addRow(transfromAttribute(new Attribute("size", null, "",
                                new String[] { "", "3", "5", "10", "15", "20" })));
                        model.addRow(transfromAttribute(
                                new Attribute("readonly", null, "", new String[] { "", "false", "true" })));
                        model.addRow(transfromAttribute(
                                new Attribute("styleClass", null, "", new String[] { "", "readonly-input" })));
                        //XXX defnine attribute

                        jScrollPane1.setViewportView(attrTable);
                        attrTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                        attrTable.setAutoscrolls(true);
                        attrTable.setAutoCreateRowSorter(false);
                        attrTable.setUpdateSelectionOnSort(false);
                        attrTable.setAutoCreateColumnsFromModel(true);
                        attrTable.setColumnSelectionAllowed(true);
                        attrTable.setModel(model);
                        attrTable.getTableHeader().setAutoscrolls(true);
                        attrTable.getTableHeader().setDebugGraphicsOptions(DebugGraphics.BUFFERED_OPTION);
                        attrTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                actionUtil.invokeAction(evt);
                            }
                        });
                        attrTable.addKeyListener(JTableUtil.newInstance(attrTable).defaultKeyAdapter());
                    }
                }
                {
                    confirmOk = new JButton();
                    jPanel1.add(confirmOk, BorderLayout.SOUTH);
                    confirmOk.setText("OK");
                    confirmOk.setPreferredSize(new java.awt.Dimension(379, 32));
                    confirmOk.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            actionUtil.invokeAction(evt);
                        }
                    });
                }
            }

            actionUtil.addAction(confirmOk, ActionEvent.class, new Action() {
                public void action(EventObject evt) throws Exception {
                    dispose();
                    setVisible(false);
                }
            });

            actionUtil.addAction(attrTable, MouseEvent.class, new Action() {
                public void action(EventObject evt) throws Exception {
                    if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                        return;
                    }

                    int colPos = JTableUtil.newInstance(attrTable).getSelectedColumn();
                    int rowPos = JTableUtil.newInstance(attrTable).getSelectedRow();

                    Function func = Function.valueOf(colPos);
                    if (func == null) {
                        System.err.println("ERROR!!!!!");
                        return;
                    }

                    Attribute realAttr = (Attribute) JTableUtil.newInstance(attrTable).getModel()
                            .getValueAt(rowPos, Function.VALUE.col);

                    switch (func) {
                    case ENABLE:
                        boolean bool = (Boolean) JTableUtil.newInstance(attrTable).getModel().getValueAt(rowPos,
                                Function.ENABLE.col);
                        JTableUtil.newInstance(attrTable).getModel().setValueAt(!bool, rowPos,
                                Function.ENABLE.col);
                        break;
                    case ATTRIBUTE:
                        break;
                    case VALUE:
                        String value = (String) JOptionPaneUtil.newInstance().showInputDialog_drowdown("choice",
                                "", realAttr.dropdown, realAttr.defaultVal);
                        realAttr.value = value;
                        JTableUtil.newInstance(attrTable).getModel().setValueAt(StringUtils.isNotEmpty(value),
                                rowPos, Function.ENABLE.col);
                        break;
                    }
                }
            });

        }
        setSize(400, 300);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.opendoorlogistics.studio.components.geocoder.SearchResultsPanel.java

SearchResultsPanel(final NominatimConfig config, final GeocodeModel model) {
    this.model = model;
    this.config = config;

    // server selector at top
    serverBox = Controls.createServerBox(config.getServer());
    serverBox.addValueChangedListener(new ValueChangedListener<String>() {

        @Override//w  w w  .ja v a2s. c o m
        public void comboValueChanged(String newValue) {
            updateAppearance();
        }
    });

    countryCode = Controls.createCountryBox(config.getCountryCode());
    countryCode.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            updateAppearance();
        }
    });

    // refresh button by server selector
    refresh = new JButton(Icons.loadFromStandardPath("view-refresh-6.png"));
    refresh.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            refreshResults();
        }
    });
    refresh.setToolTipText("Re-run the query");

    // add the controls 
    addLine(Controls.createServerLabel(), serverBox);
    addWhitespace(6);
    addLine(Controls.createCountryFilterLabel(), countryCode, Box.createRigidArea(new Dimension(10, 1)),
            refresh);
    addWhitespace();

    // results table in the middle
    table = new JTable();
    table.setColumnSelectionAllowed(false);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            readSelectedIntoModel();
        }
    });
    table.setFillsViewportHeight(true);
    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);
    setTableModel();

    model.addListener(this);

    updateAppearance();
}

From source file:mekhq.gui.FinancesTab.java

@Override
public void initTab() {
    resourceMap = ResourceBundle.getBundle("mekhq.resources.FinancesTab", new EncodeControl()); //$NON-NLS-1$

    GridBagConstraints gridBagConstraints;

    setLayout(new GridBagLayout());
    ChartPanel financeAmountPanel = (ChartPanel) createGraphPanel(GraphType.BALANCE_AMOUNT);
    ChartPanel financeMonthlyPanel = (ChartPanel) createGraphPanel(GraphType.MONTHLY_FINANCES);

    financeModel = new FinanceTableModel();
    financeTable = new JTable(financeModel);
    financeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    financeTable.addMouseListener(new FinanceTableMouseAdapter(getCampaignGui(), financeTable, financeModel));
    financeTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumn column = null;//from  www.ja va2  s  . co  m
    for (int i = 0; i < FinanceTableModel.N_COL; i++) {
        column = financeTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(financeModel.getColumnWidth(i));
        column.setCellRenderer(financeModel.getRenderer());
    }
    financeTable.setIntercellSpacing(new Dimension(0, 0));
    financeTable.setShowGrid(false);

    loanModel = new LoanTableModel();
    loanTable = new JTable(loanModel);
    loanTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    loanTable.addMouseListener(new LoanTableMouseAdapter(getCampaignGui(), loanTable, loanModel));
    loanTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    column = null;
    for (int i = 0; i < LoanTableModel.N_COL; i++) {
        column = loanTable.getColumnModel().getColumn(i);
        column.setPreferredWidth(loanModel.getColumnWidth(i));
        column.setCellRenderer(loanModel.getRenderer());
    }
    loanTable.setIntercellSpacing(new Dimension(0, 0));
    loanTable.setShowGrid(false);
    JScrollPane scrollLoanTable = new JScrollPane(loanTable);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    JPanel panBalance = new JPanel(new GridBagLayout());
    panBalance.add(new JScrollPane(financeTable), gridBagConstraints);
    panBalance.setMinimumSize(new java.awt.Dimension(350, 100));
    panBalance.setBorder(BorderFactory.createTitledBorder("Balance Sheet"));
    JPanel panLoan = new JPanel(new GridBagLayout());
    panLoan.add(scrollLoanTable, gridBagConstraints);

    JTabbedPane financeTab = new JTabbedPane();
    financeTab.setMinimumSize(new java.awt.Dimension(450, 300));
    financeTab.setPreferredSize(new java.awt.Dimension(450, 300));

    JSplitPane splitFinances = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panBalance, financeTab);
    splitFinances.setOneTouchExpandable(true);
    splitFinances.setContinuousLayout(true);
    splitFinances.setResizeWeight(1.0);
    splitFinances.setName("splitFinances");

    financeTab.addTab(resourceMap.getString("activeLoans.text"), panLoan);
    financeTab.addTab(resourceMap.getString("cbillsBalanceTime.text"), financeAmountPanel);
    financeTab.addTab(resourceMap.getString("monthlyRevenueExpenditures.text"), financeMonthlyPanel);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    add(splitFinances, gridBagConstraints);

    JPanel panelFinanceRight = new JPanel(new BorderLayout());

    JPanel pnlFinanceBtns = new JPanel(new GridLayout(2, 2));
    btnAddFunds = new JButton("Add Funds (GM)");
    btnAddFunds.addActionListener(ev -> addFundsActionPerformed());
    btnAddFunds.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnAddFunds);
    JButton btnGetLoan = new JButton("Get Loan");
    btnGetLoan.addActionListener(e -> showNewLoanDialog());
    pnlFinanceBtns.add(btnGetLoan);

    btnManageAssets = new JButton("Manage Assets (GM)");
    btnManageAssets.addActionListener(e -> manageAssets());
    btnManageAssets.setEnabled(getCampaign().isGM());
    pnlFinanceBtns.add(btnManageAssets);

    panelFinanceRight.add(pnlFinanceBtns, BorderLayout.NORTH);

    areaNetWorth = new JTextArea();
    areaNetWorth.setLineWrap(true);
    areaNetWorth.setWrapStyleWord(true);
    areaNetWorth.setFont(new Font("Courier New", Font.PLAIN, 12));
    areaNetWorth.setText(getCampaign().getFinancialReport());
    areaNetWorth.setEditable(false);

    JScrollPane descriptionScroll = new JScrollPane(areaNetWorth);
    panelFinanceRight.add(descriptionScroll, BorderLayout.CENTER);
    areaNetWorth.setCaretPosition(0);
    descriptionScroll.setMinimumSize(new Dimension(300, 200));

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
    gridBagConstraints.weightx = 0.0;
    gridBagConstraints.weighty = 1.0;
    add(panelFinanceRight, gridBagConstraints);
}

From source file:com.github.lindenb.jvarkit.tools.bamviewgui.BamFileRef.java

BamInternalFrame(BamFileRef ref) {
    super(ref.bamFile.getName(), true, false, true, true);
    this.ref = ref;
    JPanel mainPane = new JPanel(new BorderLayout(5, 5));
    setContentPane(mainPane);/*from w  w w  .  j a  v  a 2 s.  c o  m*/
    JTabbedPane tabbedPane = new JTabbedPane();
    mainPane.add(tabbedPane, BorderLayout.CENTER);

    JPanel pane = new JPanel(new BorderLayout(5, 5));
    tabbedPane.addTab("BAM", pane);

    this.tableModel = new BamTableModel();
    this.jTable = createTable(tableModel);
    this.jTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    this.jTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane scroll1 = new JScrollPane(this.jTable);

    this.infoTableModel = new FlagTableModel();
    JTable tInfo = createTable(this.infoTableModel);

    this.genotypeTableModel = new SAMTagAndValueModel();
    JTable tGen = createTable(this.genotypeTableModel);

    this.groupTableModel = new ReadGroupTableModel();
    JTable tGrp = createTable(this.groupTableModel);

    JPanel splitH = new JPanel(new GridLayout(1, 0, 5, 5));
    splitH.add(new JScrollPane(tInfo));
    splitH.add(new JScrollPane(tGen));
    splitH.add(new JScrollPane(tGrp));

    JSplitPane splitVert = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scroll1, splitH);

    this.jTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            int row = jTable.getSelectedRow();
            SAMRecord ctx;
            if (row == -1 || (ctx = tableModel.getElementAt(row)) == null) {
                infoTableModel.setContext(null);
                genotypeTableModel.setContext(null);
                groupTableModel.setContext(null);
            } else {
                infoTableModel.setContext(ctx);
                genotypeTableModel.setContext(ctx);
                groupTableModel.setContext(ctx);
            }

        }
    });

    pane.add(splitVert);

    //header as text
    pane = new JPanel(new BorderLayout(5, 5));
    tabbedPane.addTab("Header", pane);
    JTextArea area = new JTextArea(String.valueOf(ref.header.getTextHeader()));
    area.setCaretPosition(0);
    area.setEditable(false);
    pane.add(new JScrollPane(area), BorderLayout.CENTER);

    //dict
    pane = new JPanel(new BorderLayout(5, 5));
    tabbedPane.addTab("Reference", pane);
    JTable dictTable = createTable(new SAMSequenceDictionaryTableModel(ref.header.getSequenceDictionary()));
    dictTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    pane.add(new JScrollPane(dictTable), BorderLayout.CENTER);

    this.selList = new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            listSelectionChanged();
        }
    };

    this.addInternalFrameListener(new InternalFrameAdapter() {
        @Override
        public void internalFrameActivated(InternalFrameEvent e) {
            jTable.getSelectionModel().addListSelectionListener(selList);
        }

        @Override
        public void internalFrameDeactivated(InternalFrameEvent e) {
            jTable.getSelectionModel().removeListSelectionListener(selList);
        }
    });
}

From source file:io.heming.accountbook.ui.MainFrame.java

public MainFrame() throws Exception {
    categoryFacade = new CategoryFacade();
    recordFacade = new RecordFacade();
    builder = new Pages.Builder();
    builder.order("id", false);
    pages = builder.make();//from w w w.j a  va  2s .  co  m
    date_chooser_visible = false;
    disable = false;

    // Create widgets
    model = new TableModel();
    table = new JTable(model) {
        /**
         * tip.
         *
         * @param evt
         * @return
         */
        @Override
        public String getToolTipText(MouseEvent evt) {
            String tip = null;
            java.awt.Point point = evt.getPoint();
            int row = rowAtPoint(point);
            int col = columnAtPoint(point);
            Rectangle bounds = getCellRect(row, col, false);
            Component comp = prepareRenderer(getCellRenderer(row, col), row, col);

            try {
                if (comp.getPreferredSize().width > bounds.width) {
                    tip = getValueAt(row, col).toString();
                }
            } catch (RuntimeException e) {
                //catch null pointer exception if mouse is over an empty line
            }
            return tip;
        }
    };
    if (pages.hasNext()) {
        model.setRecords(pages.next());
    }

    // ?
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    TableColumnModel columnModel = table.getColumnModel();
    columnModel.getColumn(0).setPreferredWidth(80);
    columnModel.getColumn(1).setPreferredWidth(160);
    columnModel.getColumn(2).setPreferredWidth(80);
    columnModel.getColumn(3).setPreferredWidth(100);
    columnModel.getColumn(4).setPreferredWidth(100);
    columnModel.getColumn(5).setPreferredWidth(360);

    // Layout
    JScrollPane pane = new JScrollPane(table);
    add(pane, BorderLayout.CENTER);

    table.getTableHeader().setReorderingAllowed(false);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // table header
    table.getTableHeader().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            int col = table.columnAtPoint(e.getPoint());
            String name = table.getColumnName(col);
            // TODO
        }
    });

    // ?
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            quit();
        }
    });

    categories = categoryFacade.listBySale();

    initMenuBar();
    initToolBar();
    initStatusBar();
    initTablePopupMenu();

    searchRecords();
    setIconImage(new ImageIcon(getClass().getResource("64.png")).getImage());
    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    setTitle("");
    setSize(860, 620);
}

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  . java 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:edu.ucla.stat.SOCR.chart.util.MixtureEMExperiment.java

protected void initResutlsTable() {

    String[] resultsHeading = new String[2];
    resultsHeading[0] = "Kernel";
    resultsHeading[1] = "Resutls";

    Object[][] dataObject = new Object[10][2];

    tModel_results = new DefaultTableModel(dataObject, resultsHeading);

    resultsTable = new CustomJTable(tModel_results);

    /*{/*from   w  ww  . j  a v a  2  s.  com*/
      public Component prepareRenderer(TableCellRenderer renderer,
      int rowIndex, int vColIndex) {
        Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
       // 
        if (rowIndex % 2 == 0) {
     c.setBackground(Color.yellow);
        } else {
        // If not shaded, match the table's background
     c.setBackground(getBackground());
        }
        return c;
     }
    };*/
    resultsTable.setGridColor(Color.gray);
    resultsTable.setShowGrid(true);

    // this is a fix for the BAD SGI Java VM - not up to date as of dec. 22, 2003
    try {
        resultsTable.setDragEnabled(true);
    } catch (Exception e) {
    }
    //columnModel = resultsTable.getColumnModel();
    //resultsTable.setTableHeader(new EditableHeader(columnModel));
    resultsTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    resultsTable.setCellSelectionEnabled(true);
    resultsTable.setColumnSelectionAllowed(true);
    resultsTable.setRowSelectionAllowed(true);
}

From source file:de.main.sessioncreator.DesktopApplication1View.java

private void showReportPanel() {
    sessionWizardMenuItem.setEnabled(true);
    reviewVieMenuItem.setEnabled(true);/*from  w  w  w  .java  2s .  c o  m*/
    sessionReportMenuItem.setEnabled(false);
    viewReviewsPanel.setVisible(false);
    mainPanel.validate();
    wizardPanel.setVisible(false);
    mainPanel.validate();
    reportOverviewTable.setVisible(false);
    reportPanel.setVisible(true);
    mainPanel.validate();
    this.getFrame().setTitle("SessionCreator - Report");
    //Backgroundprozess to fill data to the reportPanel
    class ReportData extends SwingWorker<DefaultTableModel, Void> {

        @Override
        protected DefaultTableModel doInBackground() throws Exception {
            rh.addReport(reportChartPanel);
            reportScrollPOverviewTabel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            reportScrollPOverviewTabel.setToolTipText("Please wait...");
            reportlblSum.setText("Sums of Charters done: <counting>");
            progressBar.setIndeterminate(true);
            progressBar.setVisible(true);
            model = new DefaultTableModel();
            reportOverviewTable.removeAll();
            model = rh.getTableModel();
            reportOverviewTable.setModel(model);
            reportOverviewTable.setVisible(true);

            String count = rh.getAllSessionCount(model);
            reportlblSum.setText("Sums of Charters done: " + count);
            String[] text = rh.getAllBugsAndIssues();
            reportlblBug.setText(text[0]);
            reportlblIssue.setText(text[1]);

            return model;
        }

        @Override
        protected void done() {
            try {
                reportScrollPOverviewTabel.setCursor(Cursor.getDefaultCursor());
                reportScrollPOverviewTabel.setToolTipText("");
                progressBar.setIndeterminate(false);
                progressBar.setVisible(false);
                reportScrollPOverviewTabel.setEnabled(true);
                reportOverviewTable.setFillsViewportHeight(true);
                reportOverviewTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
                TableRowSorter<DefaultTableModel> rowSorter = new TableRowSorter<DefaultTableModel>(model);
                reportOverviewTable.setRowSorter(rowSorter);
                rowSorter.setComparator(1, new Comparator<Integer>() {

                    @Override
                    public int compare(Integer int1, Integer int2) {
                        return int1.intValue() - int2.intValue();
                    }
                });
                TableColumn column = null;

                for (int i = 0; i < 2; i++) {
                    column = reportOverviewTable.getColumnModel().getColumn(i);
                    if (i == 1) {
                        column.setPreferredWidth(10); //third column is bigger
                        DefaultTableCellRenderer myRenderer = new DefaultTableCellRenderer();
                        //Textalignment in second column right
                        myRenderer.setHorizontalAlignment(SwingConstants.RIGHT);
                        column.setCellRenderer(myRenderer);
                    } else {
                        column.setPreferredWidth(490);
                    }
                }

            } catch ( /* InterruptedException, ExecutionException */Exception e) {
            }
        }
    }
    new ReportData().execute();
}

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

/** This method is called from within the constructor to
 * initialize the form.//  w w w. j  av  a2 s . co m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    jScrollPane1 = new javax.swing.JScrollPane();
    keyTable = new javax.swing.JTable();

    setTitle("Key");
    keyTable.setModel(new MyTableModel());
    keyTable.setAutoCreateColumnsFromModel(false);
    keyTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
    jScrollPane1.setViewportView(keyTable);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 552, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
                    .addContainerGap()));
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 572) / 2, (screenSize.height - 506) / 2, 572, 506);
}

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

/** This method is called from within the constructor to
 * initialize the form./* w  w w  .  j a  v a 2 s.  c  o m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    systemScrollpane = new javax.swing.JScrollPane();
    jPanel1 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    overviewTable = new javax.swing.JTable();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    saveMenuItem = new javax.swing.JMenuItem();
    printMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    closeMenuItem = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    detailsMenuItem = new javax.swing.JMenuItem();
    jMenu3 = new javax.swing.JMenu();
    keyMenuItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Generated Solar System");
    systemScrollpane.setBackground(new java.awt.Color(0, 0, 0));

    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Planetary Overview"));
    overviewTable.setModel(new javax.swing.table.DefaultTableModel(new Object[][] {

    }, new String[] { "#", "Type", "Distance", "Mass", "Radius", "Action" }) {
        Class[] types = new Class[] { java.lang.Integer.class, java.lang.Object.class, java.lang.String.class,
                java.lang.String.class, java.lang.String.class, java.lang.Object.class };
        boolean[] canEdit = new boolean[] { false, false, false, false, false, false };

        public Class getColumnClass(int columnIndex) {
            return types[columnIndex];
        }

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    overviewTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);
    jScrollPane1.setViewportView(overviewTable);

    org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 679, Short.MAX_VALUE));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE));

    jMenu1.setText("File");
    saveMenuItem.setText("Save Image ...");
    saveMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveMenuItemActionPerformed(evt);
        }
    });

    jMenu1.add(saveMenuItem);

    printMenuItem.setText("Print Image ...");
    printMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            printMenuItemActionPerformed(evt);
        }
    });

    jMenu1.add(printMenuItem);

    jMenu1.add(jSeparator1);

    closeMenuItem.setText("Close");
    closeMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            closeMenuItemActionPerformed(evt);
        }
    });

    jMenu1.add(closeMenuItem);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("View");
    detailsMenuItem.setText("Solar System Details ...");
    detailsMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            detailsMenuItemActionPerformed(evt);
        }
    });

    jMenu2.add(detailsMenuItem);

    jMenuBar1.add(jMenu2);

    jMenu3.setText("Help");
    keyMenuItem.setText("Show Key ...");
    keyMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            keyMenuItemActionPerformed(evt);
        }
    });

    jMenu3.add(keyMenuItem);

    jMenuBar1.add(jMenu3);

    setJMenuBar(jMenuBar1);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(
            org.jdesktop.layout.GroupLayout.TRAILING,
            layout.createSequentialGroup().addContainerGap()
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.LEADING, systemScrollpane,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 691, Short.MAX_VALUE))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap()
                    .add(systemScrollpane, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 719) / 2, (screenSize.height - 499) / 2, 719, 499);
}