Example usage for javax.swing JScrollPane setViewportView

List of usage examples for javax.swing JScrollPane setViewportView

Introduction

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

Prototype

public void setViewportView(Component view) 

Source Link

Document

Creates a viewport if necessary and then sets its view.

Usage

From source file:eu.dety.burp.joseph.attacks.key_confusion.KeyConfusionInfo.java

@Override
public boolean getExtraUI(JPanel extraPanel, GridBagConstraints constraints) {
    // Create combobox and textarea to add public key (in different formats)
    JLabel publicKeyLabel = new JLabel(bundle.getString("PUBKEY_FORMAT"));
    publicKeySelection = new JComboBox<>();
    DefaultComboBoxModel<String> publicKeySelectionListModel = new DefaultComboBoxModel<>();
    publicKey = new JTextArea(10, 50);
    publicKey.setLineWrap(true);/*www.ja va  2s .c  o m*/

    publicKeySelectionListModel.addElement("PEM (String)");
    publicKeySelectionListModel.addElement("JWK (JSON)");

    publicKeySelection.setModel(publicKeySelectionListModel);

    constraints.gridy = 0;
    extraPanel.add(publicKeyLabel, constraints);

    constraints.gridy = 1;
    extraPanel.add(publicKeySelection, constraints);

    constraints.gridy = 2;
    JScrollPane jScrollPane = new javax.swing.JScrollPane();
    jScrollPane.setViewportView(publicKey);
    extraPanel.add(jScrollPane, constraints);

    return true;
}

From source file:regresiones.RegresionSimple.java

public void Resolver(JTabbedPane resultados) {

    for (int i = 0; i < 9; i++) {
        sumatorias[i] = 0.0;//from   w  w w .j a va2  s . c  o  m
    }
    try {
        System.out.println("TOTAL DE DATOS: " + N);
        for (int i = 0; i < N; i++) {
            xiyi[i] = datos[i][0] * datos[i][1];
            System.out.println("X*Y" + i + ": " + xiyi[i]);
            x2[i] = datos[i][0] * datos[i][0]; //elevamos al cuadrado las x's
            y2[i] = datos[i][1] * datos[i][1]; //elevamos al cuadrado las y's
            sumatorias[0] += datos[i][0]; //sumatoria de x
            sumatorias[1] += datos[i][1]; //sumatoria de y

        }
        //sumatoria de xi*yi
        for (int j = 0; j < N; j++) {
            sumatorias[2] += xiyi[j];
        }

        //sumatoria de x^2
        for (int j = 0; j < N; j++) {
            sumatorias[3] += x2[j];
        }

        //sumatoria de y^2
        for (int j = 0; j < N; j++) {
            sumatorias[4] += y2[j];
        }

        mediax = sumatorias[0] / N;
        mediay = sumatorias[1] / N;

        System.out.println("RAIS 25: " + Math.sqrt(25));

        DecimalFormat df = new DecimalFormat("##.##");
        df.setRoundingMode(RoundingMode.DOWN);
        System.out.println("redondeo x^2-- " + df.format(sumatorias[3]));
        System.out.println("redondeo y^2-- " + df.format(sumatorias[4]));
        redondeoSumatoriax2 = Double.parseDouble(df.format(sumatorias[3]));
        redondeoSumatoriay2 = Double.parseDouble(df.format(sumatorias[4]));
        dxy = ((sumatorias[2]) / N) - mediax * mediay;
        dy = Math.sqrt(((redondeoSumatoriay2 / N) - (mediay * mediay)));
        dx = Math.sqrt(((redondeoSumatoriax2 / N) - (mediax * mediax)));

        b1 = ((sumatorias[2] * N) - sumatorias[0] * sumatorias[1])
                / ((sumatorias[3] * N) - (sumatorias[0] * sumatorias[0]));
        b0 = (sumatorias[1] / N) - ((b1 * sumatorias[0]) / N);

        // Y ESTIMADA
        for (int i = 0; i < N; i++) {
            yEstimada[i] = b0 + (b1 * datos[i][0]);
        }

        Se = Math.sqrt((sumatorias[4] - (b0 * sumatorias[1]) - (b1 * sumatorias[2])) / (N - 2));
        r = dxy / (dx * dy);
        System.out.println("sum x: " + sumatorias[0]);
        System.out.println("sum y: " + sumatorias[1]);
        System.out.println("sum x*y: " + sumatorias[2]);
        System.out.println("sum x^2: " + sumatorias[3]);
        System.out.println("sum y^2: " + sumatorias[4]);
        System.out.println("DX7: " + dxy);
        System.out.println("DY: " + dy);
        System.out.println("DX: " + dx);
        System.out.println("B0: " + b0);
        System.out.println("B1: " + b1);

        // mostramos resultados para la pestaa resultados***********************************************************************
        JPanel panel = new JPanel(new BorderLayout());
        panel.setBackground(Color.white);
        JLabel titulo = new JLabel("Resultados");//creamos el titulo
        panel.add(titulo, BorderLayout.PAGE_START);//lo agregamos al inicio
        jtable = new JTable();//creamos la tabla a mostrar
        jtable.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable.setFont(new java.awt.Font("Arial", 1, 14));
        jtable.setColumnSelectionAllowed(true);
        jtable.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable.setInheritsPopupMenu(true);
        jtable.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos = { "X", "Y", "Xi*Yi", "X2", "Y2", "Y estimada" };//los titulos de la tabla
        arregloFinal = new String[N][6];
        DecimalFormat formato = new DecimalFormat("0.00");
        for (int i = 0; i < N; i++) {//armamos el arreglo
            arregloFinal[i][0] = datos[i][0] + ""; //X
            arregloFinal[i][1] = datos[i][1] + "";//Y
            arregloFinal[i][2] = formato.format(xiyi[i]);
            arregloFinal[i][3] = formato.format(x2[i]);
            arregloFinal[i][4] = formato.format(y2[i]);
            arregloFinal[i][5] = formato.format(yEstimada[i]);
        }
        DefaultTableModel TableModel = new DefaultTableModel(arregloFinal, titulos);
        jtable.setModel(TableModel);
        JScrollPane jScrollPane1 = new JScrollPane();
        jScrollPane1.setViewportView(jtable);
        jtable.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);

        panel.add(jScrollPane1, BorderLayout.CENTER);
        JPanel panel2 = new JPanel(new GridLayout(0, 4));//creo un panel con rejilla de 4 columnas
        JLabel etiquetaN = new JLabel("N");
        JTextField cajaN = new JTextField();
        cajaN.setText(N + "");
        JLabel etiquetab0 = new JLabel("b0");
        JTextField cajab0 = new JTextField();
        cajab0.setText(b0 + "");
        JLabel etiquetab1 = new JLabel("b1");
        JTextField cajab1 = new JTextField();
        cajab1.setText(b1 + "");
        JLabel etiquetadxy = new JLabel("DXy");
        JTextField cajadxy = new JTextField();
        cajadxy.setText(dxy + "");
        JLabel etiquetadx = new JLabel("DX");
        JTextField cajadx = new JTextField();
        cajadx.setText(dx + "");
        JLabel etiquetady = new JLabel("DY");
        JTextField cajady = new JTextField();
        cajady.setText(dy + "");
        JLabel etiquetaR = new JLabel("R");
        JTextField cajaR = new JTextField();
        cajaR.setText(r + "");
        JLabel etiquetaSE = new JLabel("SE");
        JTextField cajaSE = new JTextField();
        cajaSE.setText(Se + "");
        JButton boton = new JButton("Exportar a PDF");
        boton.addActionListener(this);
        panel2.add(etiquetaN);
        panel2.add(cajaN);
        panel2.add(etiquetab0);
        panel2.add(cajab0);
        panel2.add(etiquetab1);
        panel2.add(cajab1);
        panel2.add(etiquetadxy);
        panel2.add(cajadxy);
        panel2.add(etiquetadx);
        panel2.add(cajadx);
        panel2.add(etiquetady);
        panel2.add(cajady);
        panel2.add(etiquetaR);
        panel2.add(cajaR);
        panel2.add(etiquetaSE);
        panel2.add(cajaSE);
        panel2.add(boton);
        panel.add(panel2, BorderLayout.SOUTH);//agrego el panel2 con rejilla en el panel principal al sur
        resultados.addTab("resultado", panel);
        //**************************************************************************************
        //intervalos de confianza
        JPanel intervalos = new JPanel(new BorderLayout());
        JPanel variables = new JPanel(new GridLayout(0, 2));
        JLabel variableX1 = new JLabel("X1");
        cajaVariableX1 = new JTextField();
        boton = new JButton("calcular");
        boton.addActionListener(this);
        JLabel variableEfectividad = new JLabel("Efectividad");
        String[] efectividades = { "80", "85", "90", "95", "99" };
        combo = new JComboBox(efectividades);
        variables.add(variableX1);
        variables.add(cajaVariableX1);
        variables.add(variableEfectividad);
        variables.add(combo);
        variables.add(boton);//comentario
        //cometario2
        intervalos.add(variables, BorderLayout.NORTH);
        jtable2 = new JTable();//creamos la tabla a mostrar
        jtable2.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(255, 0, 0), 2, true));
        jtable2.setFont(new java.awt.Font("Arial", 1, 14));
        jtable2.setColumnSelectionAllowed(true);
        jtable2.setCursor(new java.awt.Cursor(java.awt.Cursor.N_RESIZE_CURSOR));
        jtable2.setInheritsPopupMenu(true);
        jtable2.setMinimumSize(new java.awt.Dimension(80, 80));
        String[] titulos2 = { "Y estimada", "Li", "Ls" };//los titulos de la tabla
        String[][] pruebaIntervalos = { { "", "", "" } };
        DefaultTableModel TableModel2 = new DefaultTableModel(pruebaIntervalos, titulos2);
        jtable2.setModel(TableModel2);
        JScrollPane jScrollPane2 = new JScrollPane();
        jScrollPane2.setViewportView(jtable2);
        jtable2.getColumnModel().getSelectionModel()
                .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        intervalos.add(jScrollPane2, BorderLayout.CENTER);
        resultados.addTab("intervalos", intervalos);
        // ***********************************************************************
        JPanel graficas = new JPanel(new GridLayout(0, 1));
        XYDataset dataset = createSampleDataset();
        JFreeChart chart = ChartFactory.createXYLineChart("Grafica", "X", "Y", dataset,
                PlotOrientation.VERTICAL, true, false, false);
        XYPlot plot = (XYPlot) chart.getPlot();
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(0, true);
        renderer.setSeriesShapesVisible(0, true);
        renderer.setSeriesLinesVisible(1, true);
        renderer.setSeriesShapesVisible(1, true);
        plot.setRenderer(renderer);
        final ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
        graficas.add(chartPanel);//agregamos la primer grafica
        resultados.addTab("Graficas", graficas);
        //IMPRIMIR JTABLE
        /* MessageFormat headerFormat = new MessageFormat("MI CABECERA");
         MessageFormat footerFormat = new MessageFormat("- Pgina {0} -");
         jtable.print(PrintMode.FIT_WIDTH, headerFormat, footerFormat);
         */

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:bazaar4idea.ui.BzrGlobalStatusDialog.java

/** Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 * @noinspection ALL/*  www  .  j a  v  a  2  s .c o m*/
 */
private void $$$setupUI$$$() {
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    final JScrollPane scrollPane1 = new JScrollPane();
    contentPanel.add(scrollPane1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW,
                    new Dimension(300, 350), null, null, 0, false));
    outputTextArea = new JTextArea();
    outputTextArea.setEditable(false);
    scrollPane1.setViewportView(outputTextArea);
}

From source file:Main.java

public Main() {
    JEditorPane editorPane = new JEditorPane();
    JScrollPane scrollPane = new JScrollPane();

    this.setPreferredSize(new Dimension(300, 300));
    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    getContentPane().setLayout(new BorderLayout());
    editorPane.setEditorKit(new PreWrapHTMLEditorKit());
    editorPane.setText("" + "<html>" + "<head></head>" + "<body>"
            + "<pre>long text line long text line long text line long text line (two new lines here!)\n\n"
            + "long text line long text line long text line long text line long text line long text line</pre>"
            + "</body>" + "</html>");
    scrollPane.setViewportView(editorPane);
    getContentPane().add(scrollPane);/*from w w w  .j  a  v  a2s  .  c  o  m*/
    pack();
}

From source file:com.atlassian.theplugin.idea.jira.PerformIssueActionForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/* w ww.j av a  2s.co  m*/
 */
private void $$$setupUI$$$() {
    root = new JPanel();
    root.setLayout(new BorderLayout(0, 0));
    final JScrollPane scrollPane1 = new JScrollPane();
    scrollPane1.setHorizontalScrollBarPolicy(31);
    root.add(scrollPane1, BorderLayout.CENTER);
    contentPanel = new JPanel();
    contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
    scrollPane1.setViewportView(contentPanel);
}

From source file:com.atlassian.theplugin.idea.jira.PerformIssueActionForm.java

private void setupUI() {
    root = new JPanel();
    root.setOpaque(false);/*from   w  w  w . j  ava 2  s.  c  o  m*/
    root.setLayout(new BorderLayout(0, 0));
    final JScrollPane scroll = new JScrollPane();
    scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scroll.setOpaque(false);
    scroll.getViewport().setOpaque(false);
    root.add(scroll, BorderLayout.CENTER);
    contentPanel = new ScrollablePanel();
    scroll.setViewportView(contentPanel);
}

From source file:com.titan.storagepanel.DownloadImageDialog.java

public DownloadImageDialog(final Frame frame) {
    super(frame, true);
    setTitle("Openstack vm os image");
    setBounds(100, 100, 947, 706);/*from  w w  w  . j a  v  a2 s  .c  o m*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));
    {
        JPanel panel = new JPanel();
        contentPanel.add(panel, BorderLayout.NORTH);
        panel.setLayout(new MigLayout("", "[41px][107.00px][27px][95.00px][24px][95.00px][]", "[27px]"));
        {
            JLabel lblSearch = new JLabel("Search");
            panel.add(lblSearch, "cell 0 0,alignx left,aligny center");
        }
        {
            searchTextField = new JSearchTextField();
            searchTextField.setPreferredSize(new Dimension(150, 40));
            panel.add(searchTextField, "cell 1 0,growx,aligny center");
        }
        {
            JLabel lblType = new JLabel("Type");
            panel.add(lblType, "cell 2 0,alignx left,aligny center");
        }
        {
            typeComboBox = new JComboBox(
                    new String[] { "All", "Ubuntu", "Fedora", "Redhat", "CentOS", "Gentoo", "Windows" });
            panel.add(typeComboBox, "cell 3 0,growx,aligny top");
        }
        {
            JLabel lblSize = new JLabel("Size");
            panel.add(lblSize, "cell 4 0,alignx left,aligny center");
        }
        {
            sizeComboBox = new JComboBox(new String[] { "0-700MB", ">700MB" });
            panel.add(sizeComboBox, "cell 5 0,growx,aligny top");
        }
        {
            JButton btnSearch = new JButton("Search");
            btnSearch.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    d.setVisible(true);
                }
            });
            panel.add(btnSearch, "cell 6 0");
        }
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        contentPanel.add(scrollPane, BorderLayout.CENTER);
        {
            table = new JTable();
            table.setModel(tableModel);
            table.addMouseListener(new JTableButtonMouseListener(table));
            table.addMouseMotionListener(new JTableButtonMouseListener(table));
            scrollPane.setViewportView(table);
        }
    }
    {
        JPanel panel = new JPanel();
        getContentPane().add(panel, BorderLayout.SOUTH);
        {
            JButton downloadButton = new JButton("Download");
            downloadButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if (table.getSelectedRowCount() == 1) {
                        JFileChooser jf = new JFileChooser();
                        int x = jf.showSaveDialog(frame);
                        if (x == JFileChooser.APPROVE_OPTION) {
                            DownloadImage p = (DownloadImage) table.getValueAt(table.getSelectedRow(), 0);
                            DownloadFileDialog d = new DownloadFileDialog(frame, "Downloading image", true,
                                    p.file, jf.getSelectedFile());
                            CommonLib.centerDialog(d);
                            d.setVisible(true);
                        }
                    }
                }
            });
            panel.add(downloadButton);
        }
    }

    d = new JProgressBarDialog(frame, true);
    d.progressBar.setIndeterminate(true);
    d.progressBar.setStringPainted(true);
    d.thread = new Thread() {
        public void run() {
            InputStream in = null;
            tableModel.columnNames.clear();
            tableModel.columnNames.add("image");
            tableModel.editables.clear();
            tableModel.editables.put(0, true);
            Vector<Object> col1 = new Vector<Object>();
            try {
                d.progressBar.setString("connecting to titan image site");
                in = new URL("http://titan-image.kingofcoders.com/titan-image.xml").openStream();
                String xml = IOUtils.toString(in);
                NodeList list = TitanCommonLib.getXPathNodeList(xml, "/images/image");
                for (int x = 0; x < list.getLength(); x++) {
                    DownloadImage downloadImage = new DownloadImage();
                    downloadImage.author = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/author/text()");
                    downloadImage.authorEmail = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/authorEmail/text()");
                    downloadImage.License = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/License/text()");
                    downloadImage.description = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/description/text()");
                    downloadImage.file = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/file/text()");
                    downloadImage.os = TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/os/text()");
                    downloadImage.osType = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/osType/text()");
                    downloadImage.uploadDate = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss").parse(
                            TitanCommonLib.getXPath(xml, "/images/image[" + (x + 1) + "]/uploadDate/text()"));
                    downloadImage.size = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/size/text()");
                    downloadImage.architecture = TitanCommonLib.getXPath(xml,
                            "/images/image[" + (x + 1) + "]/architecture/text()");
                    col1.add(downloadImage);
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                JOptionPane.showMessageDialog(frame, "Unable to connect titan image site !", "Error",
                        JOptionPane.ERROR_MESSAGE);
            } finally {
                IOUtils.closeQuietly(in);
            }
            tableModel.values.clear();
            tableModel.values.add(col1);
            tableModel.fireTableStructureChanged();
            table.getColumnModel().getColumn(0).setCellRenderer(new DownloadImageTableCellRenderer());
            //            table.getColumnModel().getColumn(0).setCellEditor(new DownloadImageTableCellEditor());
            for (int x = 0; x < table.getRowCount(); x++) {
                table.setRowHeight(x, 150);
            }
        }
    };
    d.setVisible(true);
}

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

private void initGUI() {
    try {/*from   w w  w. j ava 2 s . co m*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jPanel2 = new JPanel();
                    jPanel1.add(jPanel2, BorderLayout.NORTH);
                    jPanel2.setPreferredSize(new java.awt.Dimension(582, 112));
                    {
                        jLabel1 = new JLabel();
                        jPanel2.add(jLabel1);
                        jLabel1.setText("SQL");
                    }
                    {
                        JScrollPane jScrollPane2 = new JScrollPane();
                        jPanel2.add(jScrollPane2);
                        jScrollPane2.setPreferredSize(new java.awt.Dimension(524, 57));
                        {
                            sqlArea = new JTextArea();
                            jScrollPane2.setViewportView(sqlArea);
                        }
                    }
                    {
                        jLabel2 = new JLabel();
                        jPanel2.add(jLabel2);
                        jLabel2.setText("\u4f86\u6e90\u6a94\u8def\u5f91");
                    }
                    {
                        excelFilePathText = new JTextField();
                        JCommonUtil.jTextFieldSetFilePathMouseEvent(excelFilePathText, false);
                        jPanel2.add(excelFilePathText);
                        excelFilePathText.setPreferredSize(new java.awt.Dimension(455, 22));
                    }
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn, BorderLayout.SOUTH);
                    executeBtn.setText("\u7522\u751f");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnPreformed();
                        }
                    });
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(582, 221));
                    {
                        JScrollPane jScrollPane3 = new JScrollPane();
                        jScrollPane1.setViewportView(jScrollPane3);
                        {
                            logArea = new JTextArea();
                            jScrollPane3.setViewportView(logArea);
                        }
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                FlowLayout jPanel3Layout = new FlowLayout();
                jTabbedPane1.addTab("jPanel3", null, jPanel3, null);
                jPanel3.setLayout(jPanel3Layout);
                {
                    jLabel4 = new JLabel();
                    jPanel3.add(jLabel4);
                    jLabel4.setText("Table\u540d\u7a31");
                }
                {
                    tableNameText = new JTextField();
                    jPanel3.add(tableNameText);
                    tableNameText.setPreferredSize(new java.awt.Dimension(463, 23));
                }
                {
                    jLabel3 = new JLabel();
                    jPanel3.add(jLabel3);
                    jLabel3.setText("\u4f86\u6e90\u6a94\u8def\u5f91");
                }
                {
                    excelFilePathText2 = new JTextField();
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(excelFilePathText2, false);
                    jPanel3.add(excelFilePathText2);
                    excelFilePathText2.setPreferredSize(new java.awt.Dimension(455, 22));
                }
                {
                    firstRowMakeInsertSqlBtn = new JButton();
                    jPanel3.add(firstRowMakeInsertSqlBtn);
                    firstRowMakeInsertSqlBtn.setText(
                            "\u4ee5\u7b2c\u4e00\u5217\u70ba\u6b04\u4f4d\u540d\u7a31\u7522\u751fInsert SQL");
                    firstRowMakeInsertSqlBtn.setPreferredSize(new java.awt.Dimension(251, 22));
                    firstRowMakeInsertSqlBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            firstRowMakeInsertSqlBtn(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(595, 409);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:caarray.client.test.gui.GuiMain.java

public GuiMain() throws Exception {
    JFrame frame = new JFrame("API Test Suite");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.getContentPane().setLayout(new BorderLayout(6, 6));

    JPanel topPanel = new JPanel();

    /* ###### Text fields for modifiable parameters ##### */

    final JTextField javaHostText = new JTextField(TestProperties.getJavaServerHostname(), 20);
    JLabel javaHostLabel = new JLabel("Java Service Host");
    JButton save = new JButton("Save");
    save.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setJavaServerHostname(javaHostText.getText());
        }//  ww w .j  a  va2 s  .  co  m

    });

    JLabel javaPortLabel = new JLabel("Java Port");
    final JTextField javaPortText = new JTextField(Integer.toString(TestProperties.getJavaServerJndiPort()), 5);
    JButton save2 = new JButton("Save");
    save2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(javaPortText.getText());
                TestProperties.setJavaServerJndiPort(port);
            } catch (NumberFormatException e) {
                System.out.println(javaPortText.getText() + " is not a valid port number.");
            }
        }

    });

    JLabel gridHostLabel = new JLabel("Grid Service Host");
    final JTextField gridHostText = new JTextField(TestProperties.getGridServerHostname(), 20);
    JButton save3 = new JButton("Save");
    save3.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            TestProperties.setGridServerHostname(gridHostText.getText());
        }

    });

    JLabel gridPortLabel = new JLabel("Grid Service Port");
    final JTextField gridPortText = new JTextField(Integer.toString(TestProperties.getGridServerPort()), 5);
    JButton save4 = new JButton("Save");
    save4.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int port = Integer.parseInt(gridPortText.getText());
                TestProperties.setGridServerPort(port);
            } catch (NumberFormatException e) {
                System.out.println(gridPortText.getText() + " is not a valid port number.");
            }

        }

    });

    JLabel excludeLabel = new JLabel("Exclude test cases (comma-separated list):");
    final JTextField excludeText = new JTextField("", 30);
    JButton save5 = new JButton("Save");
    save5.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = excludeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setExcludedTests(tests);
                }

            }

        }

    });

    JLabel includeLabel = new JLabel("Include only (comma-separated list):");
    final JTextField includeText = new JTextField("", 30);
    JButton save6 = new JButton("Save");
    save6.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            String testString = includeText.getText();
            if (testString != null) {
                String[] testCases = testString.split(",");
                if (testCases != null && testCases.length > 0) {
                    List<Float> tests = new ArrayList<Float>();
                    for (String test : testCases) {
                        try {
                            tests.add(Float.parseFloat(test));
                        } catch (NumberFormatException e) {
                            System.out.println(test + " is not a valid test case.");
                        }
                    }
                    TestProperties.setIncludeOnlyTests(tests);
                }

            }

        }

    });

    JLabel threadLabel = new JLabel("Number of threads:");
    final JTextField threadText = new JTextField(Integer.toString(TestProperties.getNumThreads()), 5);
    JButton save7 = new JButton("Save");
    save7.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {
                int threads = Integer.parseInt(threadText.getText());
                TestProperties.setNumThreads(threads);
            } catch (NumberFormatException e) {
                System.out.println(threadText.getText() + " is not a valid thread number.");
            }

        }

    });
    GridBagLayout topLayout = new GridBagLayout();
    topPanel.setLayout(topLayout);

    JLabel[] labels = new JLabel[] { javaHostLabel, javaPortLabel, gridHostLabel, gridPortLabel, excludeLabel,
            includeLabel, threadLabel };
    JTextField[] textFields = new JTextField[] { javaHostText, javaPortText, gridHostText, gridPortText,
            excludeText, includeText, threadText };
    JButton[] buttons = new JButton[] { save, save2, save3, save4, save5, save6, save7 };
    for (int i = 0; i < labels.length; i++) {
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.NONE;
        c.gridx = 0;
        c.gridy = i;
        topPanel.add(labels[i], c);
        c.gridx = 1;
        topPanel.add(textFields[i], c);
        c.gridx = 2;
        topPanel.add(buttons[i], c);
    }

    frame.getContentPane().add(topPanel, BorderLayout.PAGE_START);

    GridLayout bottomLayout = new GridLayout(0, 4);
    selectionPanel.setLayout(bottomLayout);
    JCheckBox selectAll = new JCheckBox("Select/Deselect All");
    selectAll.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            selectAll(box.isSelected());
        }
    });
    selectionPanel.add(selectAll);
    JCheckBox excludeLongTests = new JCheckBox("Exclude Long Tests");
    excludeLongTests.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JCheckBox box = (JCheckBox) e.getSource();
            if (box.isSelected()) {
                TestProperties.excludeLongTests();
            } else {
                TestProperties.removeExcludedLongTests();
            }
        }
    });
    TestProperties.excludeLongTests();
    excludeLongTests.setSelected(true);
    selectionPanel.add(excludeLongTests);

    //Initialize check boxes corresponding to test categories
    initializeTests();

    centerPanel.setLayout(new GridLayout(0, 1));
    centerPanel.add(selectionPanel);

    //Redirect System messages to gui     
    JScrollPane textScroll = new JScrollPane();
    textScroll.setViewportView(textDisplay);
    System.setOut(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    System.setErr(new PrintStream(new JTextAreaOutputStream(textDisplay)));
    centerPanel.add(textScroll);
    JScrollPane scroll = new JScrollPane(centerPanel);

    frame.getContentPane().add(scroll, BorderLayout.CENTER);

    JButton runButton = new JButton("Run Tests");
    runButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent arg0) {
            try {

                runTests();

            } catch (Exception e) {
                System.out.println("An error occured executing the tests: " + e.getClass()
                        + ". Check error log for details.");
                log.error("Exception encountered:", e);
            }
        }

    });

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(runButton);
    frame.getContentPane().add(bottomPanel, BorderLayout.PAGE_END);

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