Example usage for javax.swing JTable JTable

List of usage examples for javax.swing JTable JTable

Introduction

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

Prototype

public JTable(final Object[][] rowData, final Object[] columnNames) 

Source Link

Document

Constructs a JTable to display the values in the two dimensional array, rowData, with column names, columnNames.

Usage

From source file:Interface.ResultadoJanela.java

public ResultadoJanela(List<Resultado> tar, List<Resultado> jac, List<Resultado> och, List<Resultado> sbi) {
    //  super("Resultado");
    CategoryDataset dataset;/* w  w w .  j a  v a  2  s .  c o m*/

    //---------------------gerando resultados tarantula-------------------------------------
    dataset = gerarDataset(tar, jac, och, sbi);
    JFreeChart chart = gerarGrafico(dataset);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDomainZoomable(true);

    JLabel lAjuda = new JLabel("Ajuda", JLabel.RIGHT);
    lAjuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icone_informacao.gif"))); // NOI18N
    lAjuda.setPreferredSize(new Dimension(50, 50));
    lAjuda.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            lAjudaMouseClicked(evt);
        }
    });

    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());
    panel.add(lAjuda, BorderLayout.BEFORE_FIRST_LINE);
    panel.add(chartPanel, BorderLayout.LINE_START);
    JLabel lTabela = new JLabel("Tabela de Resultados", JLabel.CENTER);
    panel.add(lTabela, BorderLayout.SOUTH);

    JTable table = new JTable(criarValores(tar, jac, och, sbi), criarColunas());

    // Adiciona o JTable dentro do painel
    JScrollPane scrollPane = new JScrollPane(table);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);

    panel.add(scrollPane, BorderLayout.SOUTH);

    JFrame frame = new JFrame();
    frame.setTitle("JLoc - Resultado");
    frame.setVisible(true);
    frame.add(panel);

    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    super(new GridLayout(1, 0));

    final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) },
            { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) },
            { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) },
            { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) },
            { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);/*  www.j a v a2 s .c  o  m*/

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No rows are selected.");
                } else {
                    int selectedRow = lsm.getMinSelectionIndex();
                    System.out.println("Row " + selectedRow + " is now selected.");
                }
            }
        });
    } else {
        table.setRowSelectionAllowed(false);
    }

    if (ALLOW_COLUMN_SELECTION) { // false by default
        if (ALLOW_ROW_SELECTION) {
            // We allow both row and column selection, which
            // implies that we *really* want to allow individual
            // cell selection.
            table.setCellSelectionEnabled(true);
        }
        table.setColumnSelectionAllowed(true);
        ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
        colSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No columns are selected.");
                } else {
                    int selectedCol = lsm.getMinSelectionIndex();
                    System.out.println("Column " + selectedCol + " is now selected.");
                }
            }
        });
    }

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:FocusTraversalDemo.java

public FocusTraversalDemo() {
    super(new BorderLayout());
    newPolicy = new MyOwnFocusTraversalPolicy();

    tf1 = new JTextField("Field 1");
    tf2 = new JTextField("A Bigger Field 2");
    tf3 = new JTextField("Field 3");
    tf4 = new JTextField("A Bigger Field 4");
    tf5 = new JTextField("Field 5");
    tf6 = new JTextField("A Bigger Field 6");
    table = new JTable(4, 3);
    togglePolicy = new JCheckBox("Custom FocusTraversalPolicy");
    togglePolicy.setActionCommand("toggle");
    togglePolicy.addActionListener(this);
    togglePolicy.setFocusable(false); //Remove it from the focus cycle.
    //Note that HTML is allowed and will break this run of text
    //across two lines.
    label = new JLabel(
            "<html>Use Tab (or Shift-Tab) to navigate from component to component.<p>Control-Tab (or Control-Shift-Tab) allows you to break out of the JTable.</html>");

    JPanel leftTextPanel = new JPanel(new GridLayout(3, 2));
    leftTextPanel.add(tf1, BorderLayout.PAGE_START);
    leftTextPanel.add(tf3, BorderLayout.CENTER);
    leftTextPanel.add(tf5, BorderLayout.PAGE_END);
    leftTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel rightTextPanel = new JPanel(new GridLayout(3, 2));
    rightTextPanel.add(tf2, BorderLayout.PAGE_START);
    rightTextPanel.add(tf4, BorderLayout.CENTER);
    rightTextPanel.add(tf6, BorderLayout.PAGE_END);
    rightTextPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 5));
    JPanel tablePanel = new JPanel(new GridLayout(0, 1));
    tablePanel.add(table, BorderLayout.CENTER);
    tablePanel.setBorder(BorderFactory.createEtchedBorder());
    JPanel bottomPanel = new JPanel(new GridLayout(2, 1));
    bottomPanel.add(togglePolicy, BorderLayout.PAGE_START);
    bottomPanel.add(label, BorderLayout.PAGE_END);

    add(leftTextPanel, BorderLayout.LINE_START);
    add(rightTextPanel, BorderLayout.CENTER);
    add(tablePanel, BorderLayout.LINE_END);
    add(bottomPanel, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
}

From source file:SimpleTableSelectionDemo.java

public SimpleTableSelectionDemo() {
    super(new GridLayout(1, 0));

    final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) },
            { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) },
            { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) },
            { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) },
            { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);//from w  w  w .j ava 2s. c om

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No rows are selected.");
                } else {
                    int selectedRow = lsm.getMinSelectionIndex();
                    System.out.println("Row " + selectedRow + " is now selected.");
                }
            }
        });
    } else {
        table.setRowSelectionAllowed(false);
    }

    if (ALLOW_COLUMN_SELECTION) { // false by default
        if (ALLOW_ROW_SELECTION) {
            // We allow both row and column selection, which
            // implies that we *really* want to allow individual
            // cell selection.
            table.setCellSelectionEnabled(true);
        }
        table.setColumnSelectionAllowed(true);
        ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
        colSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                // Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No columns are selected.");
                } else {
                    int selectedCol = lsm.getMinSelectionIndex();
                    System.out.println("Column " + selectedCol + " is now selected.");
                }
            }
        });
    }

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:components.SimpleTableSelectionDemo.java

public SimpleTableSelectionDemo() {
    super(new GridLayout(1, 0));

    final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    final Object[][] data = { { "Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false) },
            { "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
            { "Sue", "Black", "Knitting", new Integer(2), new Boolean(false) },
            { "Jane", "White", "Speed reading", new Integer(20), new Boolean(true) },
            { "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);/*ww  w.j a  v  a 2  s  .co  m*/

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No rows are selected.");
                } else {
                    int selectedRow = lsm.getMinSelectionIndex();
                    System.out.println("Row " + selectedRow + " is now selected.");
                }
            }
        });
    } else {
        table.setRowSelectionAllowed(false);
    }

    if (ALLOW_COLUMN_SELECTION) { // false by default
        if (ALLOW_ROW_SELECTION) {
            //We allow both row and column selection, which
            //implies that we *really* want to allow individual
            //cell selection.
            table.setCellSelectionEnabled(true);
        }
        table.setColumnSelectionAllowed(true);
        ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
        colSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No columns are selected.");
                } else {
                    int selectedCol = lsm.getMinSelectionIndex();
                    System.out.println("Column " + selectedCol + " is now selected.");
                }
            }
        });
    }

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:SimpleTableSelectionDemo.java

public SimpleTableSelectionDemo() {
    super(new GridLayout(1, 0));

    final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) },
            { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) },
            { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) },
            { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) },
            { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    if (ALLOW_ROW_SELECTION) { // true by default
        ListSelectionModel rowSM = table.getSelectionModel();
        rowSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No rows are selected.");
                } else {
                    int selectedRow = lsm.getMinSelectionIndex();
                    System.out.println("Row " + selectedRow + " is now selected.");
                }/*  ww w.j  av  a  2  s.  co m*/
            }
        });
    } else {
        table.setRowSelectionAllowed(false);
    }

    if (ALLOW_COLUMN_SELECTION) { // false by default
        if (ALLOW_ROW_SELECTION) {
            //We allow both row and column selection, which
            //implies that we *really* want to allow individual
            //cell selection.
            table.setCellSelectionEnabled(true);
        }
        table.setColumnSelectionAllowed(true);
        ListSelectionModel colSM = table.getColumnModel().getSelectionModel();
        colSM.addListSelectionListener(new ListSelectionListener() {
            public void valueChanged(ListSelectionEvent e) {
                //Ignore extra messages.
                if (e.getValueIsAdjusting())
                    return;

                ListSelectionModel lsm = (ListSelectionModel) e.getSource();
                if (lsm.isSelectionEmpty()) {
                    System.out.println("No columns are selected.");
                } else {
                    int selectedCol = lsm.getMinSelectionIndex();
                    System.out.println("Column " + selectedCol + " is now selected.");
                }
            }
        });
    }

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:integratedprogressdemo.WeatherData.java

private WeatherData(boolean displayProgress) {
    setBackground(Color.WHITE);/*  w w w .  ja  va 2s .  c  o m*/
    setLayout(new BorderLayout());
    JLabel lbl = new JLabel("World-Wide Weather Data");
    lbl.setFont(new Font("Serif", Font.PLAIN, 18));

    add(lbl, BorderLayout.PAGE_START);
    lbl = new JLabel("Weather information from over 50 cities");
    add(lbl, BorderLayout.LINE_START);

    if (displayProgress) {
        progressPanel = new JPanel();
        progressPanel.setBackground(Color.WHITE);
        progressPanel.setLayout(new BorderLayout(20, 20));

        String lblText = "<html>Stuck in the mud? Make progress with...<br /><font color=red><em>JDK Documentation</em></font><br/></html>";
        lbl = new JLabel(lblText);
        progressPanel.add(lbl, BorderLayout.NORTH);

        progressBar = new JProgressBar(0, 100);
        progressBar.setValue(0);
        progressBar.setStringPainted(true);
        progressPanel.add(progressBar, BorderLayout.SOUTH);

        add(progressPanel, BorderLayout.LINE_END);
    }

    String[] columnNames = { "City", "Temperature" };
    JTable table = new JTable(getData(), columnNames);

    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setBackground(Color.WHITE);

    //Add the scroll pane to this panel.
    add(scrollPane, BorderLayout.PAGE_END);
}

From source file:view.ResultsPanel.java

public ResultsPanel(final MainControler controler, String[] command, String resultsName) {

    this.resultsName = resultsName;

    this.controler = controler;
    this.command = command;
    modeTable = new JTable(0, 2);

    DefaultTableModel model = new MyTableModel();

    model.addColumn("Stoichiometry");
    model.addColumn("Enzyme name");
    model.addColumn("Equation");
    modeTable.setModel(model);//from w  w  w  .j  av a  2s  .  c o m

    JPanel logPanel = new JPanel(new BorderLayout());
    log = new JTextArea();
    log.setEditable(false);
    log.setBackground(new Color(0, 0, 0));
    log.setForeground(new Color(255, 255, 255));

    logPanel.add(new JLabel("Genereted log", JLabel.CENTER), BorderLayout.PAGE_START);
    logPanel.add(new JScrollPane(log), BorderLayout.CENTER);

    addToProject.setName("add");
    addToProject.setToolTipText("Attach this result to the project");
    removeFromProject.setName("remove");
    removeFromProject.setToolTipText("Remove this result from the project");

    removeFromProject.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            removeFromProject();
            updateToolbar();
        }
    });

    addToProject.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            addToProject();
            updateToolbar();
        }
    });

    if (!resultsName.startsWith("saved/")) {
        isAttached = false;
    } else {
        isAttached = true;
    }

    filterButton.setToolTipText("Filter the results");

    filterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            FilterFrame ff = new FilterFrame(GeneralFrame.getInstance(controler), allModes, filter, controler);
            if (ff.okPressed()) {

                displayFrame(ff.getNewModes(), ff.getIndices());
            }
        }
    });

    scriptButton.setToolTipText("Download the command as a script");
    scriptButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            String scriptString = makeScript();
            new Download(scriptString, "Download the command as a script", "");

        }
    });

    download = new JButton(new ImageIcon("src/icons/download.png"));
    download.setToolTipText("Download results");

    histoButton.setToolTipText("Statistics");

    searchField.setMaximumSize(new Dimension(20, 30));

    readLog();
    allModes = readResultsFile();

    List<Integer> indices = new ArrayList<Integer>();
    for (int i = 0; i < allModes.size(); i++) {
        indices.add((i + 1));
    }

    displayFrame(allModes, indices);

}

From source file:teambootje.A1.java

public A1() {
    initComponents();// www .j  av  a2  s.  c  o m
    setLocationRelativeTo(null);
    setLayout(new BorderLayout());
    setSize(500, 500);

    //Create and set up the window.
    setTitle("SS Rotterdam Analyse || Analyse 1");
    ImageIcon icon = new ImageIcon("img/bootje.jpg");
    setIconImage(icon.getImage());

    // back BTN
    JButton back = new JButton("Back");
    add(back, BorderLayout.NORTH);

    back.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
            //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
        }
    });

    // panel
    JPanel ana = new JPanel();
    add(ana, BorderLayout.CENTER);

    //tabel
    String nvt = "SELECT Geslacht, COUNT(*) AS Aantal FROM persoon GROUP BY geslacht";
    String male = "SELECT Geslacht AS male, COUNT(*) AS Aantal_Male FROM persoon WHERE Geslacht = 'man'";
    String Female = "SELECT Geslacht AS female, COUNT(*) AS Aantal_Female FROM persoon WHERE Geslacht = 'vrouw'";
    List<Object[]> list = new ArrayList<Object[]>();
    ResultSet rs = null;
    try {
        rs = db.runSql(nvt);
        while (rs.next()) {
            String geslacht = rs.getString("Geslacht");
            int aantal = rs.getInt("Aantal");
            String[] row = new String[rs.getMetaData().getColumnCount()];
            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                row[i - 1] = rs.getString(i);
            }
            list.add(row);

            try {
                rs = db.runSql(male);
                while (rs.next()) {
                    String man = rs.getString("male");
                    int am = rs.getInt("Aantal_Male");
                    String[] row1 = new String[rs.getMetaData().getColumnCount()];
                    for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                        row1[i - 1] = rs.getString(i);
                    }

                    try {
                        rs = db.runSql(Female);
                        while (rs.next()) {
                            String vrouw = rs.getString("female");
                            int af = rs.getInt("Aantal_Female");
                            String[] row2 = new String[rs.getMetaData().getColumnCount()];
                            for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
                                row2[i - 1] = rs.getString(i);
                            }
                            Object[][] array = new Object[list.size()][];
                            Object columnNames[] = { "Geslacht", "Aantal" };
                            list.toArray(array);

                            JTable table = new JTable(array, columnNames);
                            JScrollPane scroll = new JScrollPane(table);
                            scroll.setPreferredSize(new Dimension(400, 400));
                            ana.add(scroll);

                            //chart
                            JButton chart = new JButton("Chart");
                            add(chart, BorderLayout.SOUTH);

                            chart.addActionListener(new ActionListener() {
                                String g1 = geslacht;
                                String m = man;
                                String v = vrouw;
                                int a1 = aantal;
                                int a2 = am;
                                int a3 = af;

                                @Override
                                public void actionPerformed(ActionEvent e) {

                                    DefaultPieDataset pieDataset = new DefaultPieDataset();
                                    pieDataset.setValue("Niet vrij gegeven", a1);
                                    pieDataset.setValue("Man", a2);
                                    pieDataset.setValue("vrouw", a3);

                                    JFreeChart chart = ChartFactory.createPieChart3D("Aantal mannen en vrouwen",
                                            pieDataset, true, true, true);
                                    PiePlot3D p = (PiePlot3D) chart.getPlot();
                                    //p.setForegroundAlpha(TOP_ALIGNMENT);
                                    ChartFrame pie = new ChartFrame("Aantal mannen en vrouwen", chart);
                                    pie.setVisible(true);
                                    pie.setSize(500, 500);
                                    pie.setLocationRelativeTo(null);

                                    //throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
                                }
                            });
                        }
                    } catch (SQLException v) {
                        JOptionPane.showMessageDialog(null, v);
                    }
                }
            } catch (SQLException m) {
                JOptionPane.showMessageDialog(null, m);
            }

        }
    } catch (SQLException e) {
        JOptionPane.showMessageDialog(null, e);
    }
}

From source file:net.adamjak.thomas.graph.application.gui.ResultsWidnow.java

private JTable createJtResults() {
    if (this.results.containsKey("resultsData")) {
        GraphTestResult[][] results = (GraphTestResult[][]) this.results.get("resultsData");

        String[] columnNames = { "Graph ID", "Avarage time", "Standard deviation", "Minimum", "Maximum" };
        Object[][] data = new Object[results[0].length][5];

        for (int graph = 0; graph < results[0].length; graph++) {
            SummaryStatistics summaryStatistics = new SummaryStatistics();

            for (int run = 0; run < results.length; run++) {
                summaryStatistics.addValue((double) results[run][graph].getValue("timeInSeconds"));
            }/*from  w ww.  j a va 2  s . c  o m*/

            data[graph][0] = graph;
            data[graph][1] = summaryStatistics.getMean();
            data[graph][2] = summaryStatistics.getStandardDeviation();
            data[graph][3] = summaryStatistics.getMin();
            data[graph][4] = summaryStatistics.getMax();
        }

        return new JTable(data, columnNames);
    } else {
        String[] columnNames = { "Description", "Result" };
        Object[][] data = new Object[this.results.keySet().size()][2];

        int i = 0;
        for (String key : this.results.keySet()) {
            data[i][0] = key;
            data[i][1] = this.results.get(key);
            i++;
        }

        return new JTable(data, columnNames);
    }
}