Example usage for javax.swing JTabbedPane JTabbedPane

List of usage examples for javax.swing JTabbedPane JTabbedPane

Introduction

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

Prototype

public JTabbedPane() 

Source Link

Document

Creates an empty TabbedPane with a default tab placement of JTabbedPane.TOP.

Usage

From source file:gtu._work.etc.GoogleContactUI.java

private void initGUI() {
    try {/*  w w w.  j  av a2s .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);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {

                        DefaultTableModel model = JTableUtil.createModel(false, googleColumns);
                        model.addRow(new Object[googleColumns.length]);
                        googleTable = new JTable();
                        jScrollPane1.setViewportView(googleTable);
                        googleTable.setModel(model);

                        googleTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JTableUtil.newInstance(googleTable).defaultToolTipText(evt);
                                googleTableMouseClicked(evt);
                            }
                        });
                        JTableUtil.defaultSetting(googleTable);
                        JTableUtil.newInstance(googleTable).showColumnByHeaderValue(defaultShow_googleColumns);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jPanel2", null, jPanel2, null);
            }
        }
        pack();
        this.setSize(642, 405);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {/*from w  ww .  ja v a  2 s.  c om*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            jTabbedPane1.setPreferredSize(new java.awt.Dimension(436, 153));
            {
                jPanel1 = new JPanel();
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                jPanel1.setPreferredSize(new java.awt.Dimension(431, 125));
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("\u6a94\u6848\u8def\u5f91");
                }
                {
                    filePathText = new JTextField();
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(filePathText, true);
                    jPanel1.add(filePathText);
                    filePathText.setPreferredSize(new java.awt.Dimension(354, 24));
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("\u7db2\u9801\u526f\u6a94\u540d");
                    jLabel2.setPreferredSize(new java.awt.Dimension(81, 17));
                }
                {
                    subNameText = new JTextField();
                    jPanel1.add(subNameText);
                    subNameText.setPreferredSize(new java.awt.Dimension(282, 24));
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("\u8981\u6293\u7684TagPattern");
                    jLabel3.setPreferredSize(new java.awt.Dimension(115, 17));
                }
                {
                    tagPatternText = new JTextField();
                    jPanel1.add(tagPatternText);
                    tagPatternText.setPreferredSize(new java.awt.Dimension(259, 24));
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("");
                    executeBtn.setPreferredSize(new java.awt.Dimension(180, 45));
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(452, 218);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {// w  w w .j  a v  a2  s . c  o  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:gtu._work.ui.DbFieldJavaFieldUI.java

private void initGUI() {
    try {/* ww  w. j  ava2s.  c  o m*/
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        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("", null, jPanel1, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel1.add(jScrollPane3, BorderLayout.CENTER);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(379, 209));
                    {
                        replaceBeforeArea = new JTextArea();
                        jScrollPane3.setViewportView(replaceBeforeArea);
                    }
                }
                {
                    jPanel3 = new JPanel();
                    jPanel1.add(jPanel3, BorderLayout.NORTH);
                    jPanel3.setPreferredSize(new java.awt.Dimension(379, 28));
                    {
                        dbToJavaRadio = new JRadioButton();
                        jPanel3.add(dbToJavaRadio);
                        dbToJavaRadio.setText("DB->Java");
                    }
                    {
                        javaToDbRadio = new JRadioButton();
                        jPanel3.add(javaToDbRadio);
                        javaToDbRadio.setText("Java->DB");
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("??", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(379, 233));
                    {
                        jScrollPane2 = new JScrollPane();
                        jScrollPane1.setViewportView(jScrollPane2);
                        jScrollPane2.setPreferredSize(new java.awt.Dimension(376, 230));
                        {
                            replaceAfterArea = new JTextArea();
                            jScrollPane2.setViewportView(replaceAfterArea);
                        }
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("setter", null, jPanel4, null);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel4.add(jScrollPane4, BorderLayout.CENTER);
                    jScrollPane4.setPreferredSize(new java.awt.Dimension(379, 233));
                    {
                        getSetRelArea = new JTextArea();
                        jScrollPane4.setViewportView(getSetRelArea);
                    }
                }
            }
        }
        buttonGroup1 = new ButtonGroup();
        buttonGroup1.add(dbToJavaRadio);
        dbToJavaRadio.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                System.out.println("dbToJavaRadio.actionPerformed, event=" + evt);
                //TODO add your code for dbToJavaRadio.actionPerformed
                execute(DbJava.DB_TO_JAVA);
            }
        });
        buttonGroup1.add(javaToDbRadio);
        javaToDbRadio.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                System.out.println("javaToDbRadio.actionPerformed, event=" + evt);
                //TODO add your code for javaToDbRadio.actionPerformed
                execute(DbJava.JAVA_TO_DB);
            }
        });
        pack();
        setSize(400, 300);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:org.jfree.chart.demo.DrawStringDemo.java

private JPanel createContentPane() {
    JPanel jpanel = new JPanel(new BorderLayout());
    JTabbedPane jtabbedpane = new JTabbedPane();
    jtabbedpane.add("Alignment", createTab1Content());
    jtabbedpane.add("Rotation", createTab2Content());
    jpanel.add(jtabbedpane);/* ww w . j  a va 2s  .  com*/
    return jpanel;
}

From source file:gtu._work.etc.HotnoteMakerUI.java

private void initGUI() {
    try {//from w  w w  .  ja  va2s . c  o m
        ToolTipManager.sharedInstance().setInitialDelay(0);
        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("hott notes - checklist", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(612, 348));
                    {
                        checkListArea = new JTextArea();
                        jScrollPane1.setViewportView(checkListArea);
                        checkListArea.addMouseListener(new MouseAdapter() {

                            String randomColor() {
                                StringBuilder sb = new StringBuilder().append("#");
                                for (int ii = 0; ii < 6; ii++) {
                                    sb.append(RandomUtil.randomChar('a', 'b', 'c', 'd', 'f', '0', '1', '2', '3',
                                            '4', '5', '6', '7', '8', '9'));
                                }
                                return sb.toString();
                            }

                            void saveXml(Document document, File file) {
                                OutputFormat format = OutputFormat.createPrettyPrint();
                                format.setEncoding("utf-16");
                                XMLWriter writer = null;
                                try {
                                    writer = new XMLWriter(new FileWriter(file), format);
                                    writer.write(document);
                                } catch (IOException e) {
                                    JCommonUtil.handleException(e);
                                } finally {
                                    if (writer != null) {
                                        try {
                                            writer.close();
                                        } catch (IOException e) {
                                            JCommonUtil.handleException(e);
                                        }
                                    }
                                }
                            }

                            public void mouseClicked(MouseEvent evt) {
                                if (!JMouseEventUtil.buttonLeftClick(2, evt)) {
                                    return;
                                }

                                if (StringUtils.isEmpty(checkListArea.getText())) {
                                    JCommonUtil
                                            ._jOptionPane_showMessageDialog_error("checklist area is empty!");
                                    return;
                                }

                                File file = JCommonUtil._jFileChooser_selectFileOnly_saveFile();
                                if (file == null) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("file is not correct!");
                                    return;
                                }

                                //XXX
                                StringTokenizer tok = new StringTokenizer(checkListArea.getText(), "\t\n\r\f");
                                List<String> list = new ArrayList<String>();
                                String tmp = null;
                                for (; tok.hasMoreElements();) {
                                    tmp = ((String) tok.nextElement()).trim();
                                    System.out.println(tmp);
                                    list.add(tmp);
                                }
                                //XXX

                                Document document = DocumentHelper.createDocument();
                                Element rootHot = document.addElement("hottnote");
                                rootHot.addAttribute("creationtime",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("lastmodified",
                                        new Timestamp(System.currentTimeMillis()).toString());
                                rootHot.addAttribute("type", "checklist");
                                //appearence
                                Element appearenceE = rootHot.addElement("appearence");
                                appearenceE.addAttribute("alpha", "204");
                                Element fontE = appearenceE.addElement("font");
                                fontE.addAttribute("face", "Default");
                                fontE.addAttribute("size", "0");
                                Element styleE = appearenceE.addElement("style");
                                styleE.addElement("bg2color").addAttribute("color", randomColor());
                                styleE.addElement("bgcolor").addAttribute("color", randomColor());
                                styleE.addElement("textcolor").addAttribute("color", randomColor());
                                styleE.addElement("titlecolor").addAttribute("color", randomColor());
                                //behavior
                                rootHot.addElement("behavior");
                                //content
                                Element contentE = rootHot.addElement("content");
                                Element checklistE = contentE.addElement("checklist");
                                for (String val : list) {
                                    checklistE.addElement("item").addCDATA(val);
                                }
                                //desktop
                                Element desktopE = rootHot.addElement("desktop");
                                desktopE.addElement("position").addAttribute("x", RandomUtil.numberStr(3))
                                        .addAttribute("y", RandomUtil.numberStr(3));
                                desktopE.addElement("size").addAttribute("height", "200").addAttribute("width",
                                        "200");
                                //title
                                Element titleE = rootHot.addElement("title");
                                titleE.addCDATA(StringUtils.defaultIfEmpty(checkListTitle.getText(),
                                        DateFormatUtils.format(System.currentTimeMillis(), "dd/MM/yyyy")));

                                if (!file.getName().toLowerCase().endsWith(".hottnote")) {
                                    file = new File(file.getParentFile(), file.getName() + ".hottnote");
                                }

                                saveXml(document, file);
                                JCommonUtil._jOptionPane_showMessageDialog_info("completed!\n" + file);
                            }
                        });
                    }
                }
                {
                    checkListTitle = new JTextField();
                    checkListTitle.setToolTipText("title");
                    jPanel1.add(checkListTitle, BorderLayout.NORTH);
                }
            }
        }
        pack();
        this.setSize(633, 415);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:moller.javapeg.program.gui.frames.ImageRepositoryStatisticsViewer.java

private JTabbedPane createStatiticsPanel() {

    JTabbedPane tabbedPane = new JTabbedPane();

    tabbedPane.add(createCameraModelStatistics(), 0);
    tabbedPane.add(createYearStatistics(), 1);
    tabbedPane.add(createDatesStatistics(), 2);
    tabbedPane.add(createHourStatistics(), 3);
    tabbedPane.add(createMinuteStatistics(), 4);
    tabbedPane.add(createSecondStatistics(), 5);
    tabbedPane.add(createImageSizeStatistics(), 6);
    tabbedPane.add(createISOStatistics(), 7);
    tabbedPane.add(createExposureTimeStatistics(), 8);
    tabbedPane.add(createFNumberStatistics(), 9);
    tabbedPane.add(createWeekDayStatistics(), 10);

    return tabbedPane;
}

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

private void initGUI() {
    try {/* ww w . j a v  a 2  s  .c o  m*/
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setTitle("\u8b80\u53d6Jsp\u8cc7\u8a0a");
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(475, 328));
                    {
                        jTree1 = new JTree();
                        jScrollPane1.setViewportView(jTree1);
                        jTree1.setModel(null);
                        jTree1.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                jTree1MouseClicked(evt);
                            }
                        });
                        jTree1.addTreeSelectionListener(new TreeSelectionListener() {
                            public void valueChanged(TreeSelectionEvent evt) {
                                jTree1ValueChanged(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                jTabbedPane1.addTab("jPanel2", null, jPanel2, null);
                {
                    subFileNameText = new JTextField();
                    jPanel2.add(subFileNameText);
                    subFileNameText.setPreferredSize(new java.awt.Dimension(95, 24));
                    subFileNameText.setText("xhtml");
                }
                {
                    ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(
                            new String[] { "??", "?" });
                    modifyFileBox = new JComboBox();
                    jPanel2.add(modifyFileBox);
                    modifyFileBox.setModel(jComboBox1Model);
                }
                {
                    exportReportToogleBtn = new JToggleButton();
                    jPanel2.add(exportReportToogleBtn);
                    exportReportToogleBtn.setText("\u662f\u5426\u532f\u51fa\u5831\u8868");
                    exportReportToogleBtn.setPreferredSize(new java.awt.Dimension(120, 24));
                    exportReportToogleBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            JCommonUtil.setJToggleButtonText(exportReportToogleBtn,
                                    new String[] { "", "?" });
                        }
                    });
                }
                {
                    projectSrcPathBtn = new JButton();
                    jPanel2.add(projectSrcPathBtn);
                    projectSrcPathBtn.setText("\u8a2d\u5b9a\u5c08\u6848\u76ee\u8def\u4e26\u6383\u63cf");
                    projectSrcPathBtn.setPreferredSize(new java.awt.Dimension(233, 95));
                    projectSrcPathBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            jButton1ActionPerformed(evt);
                        }
                    });
                }
            }
        }
        this.setSize(496, 395);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:hspc.submissionsprogram.AppDisplay.java

AppDisplay() {
    this.setTitle("Dominion High School Programming Contest");
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.setResizable(false);

    WindowListener exitListener = new WindowAdapter() {
        @Override/*from ww w . jav  a  2 s  .  c o  m*/
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    this.addWindowListener(exitListener);

    JTabbedPane pane = new JTabbedPane();
    this.add(pane);

    JPanel submitPanel = new JPanel(null);
    submitPanel.setPreferredSize(new Dimension(500, 500));

    UIManager.put("FileChooser.readOnly", true);
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setBounds(0, 0, 500, 350);
    fileChooser.setVisible(true);
    FileNameExtensionFilter javaFilter = new FileNameExtensionFilter("Java files (*.java)", "java");
    fileChooser.setFileFilter(javaFilter);
    fileChooser.setAcceptAllFileFilterUsed(false);
    fileChooser.setControlButtonsAreShown(false);
    submitPanel.add(fileChooser);

    JSeparator separator1 = new JSeparator();
    separator1.setBounds(12, 350, 476, 2);
    separator1.setForeground(new Color(122, 138, 152));
    submitPanel.add(separator1);

    JLabel problemChooserLabel = new JLabel("Problem:");
    problemChooserLabel.setBounds(12, 360, 74, 25);
    submitPanel.add(problemChooserLabel);

    String[] listOfProblems = Main.Configuration.get("problem_names")
            .split(Main.Configuration.get("name_delimiter"));
    JComboBox problems = new JComboBox<>(listOfProblems);
    problems.setBounds(96, 360, 393, 25);
    submitPanel.add(problems);

    JButton submit = new JButton("Submit");
    submit.setBounds(170, 458, 160, 30);
    submit.addActionListener(e -> {
        try {
            File file = fileChooser.getSelectedFile();
            try {
                CloseableHttpClient httpClient = HttpClients.createDefault();
                HttpPost uploadFile = new HttpPost(Main.Configuration.get("submit_url"));

                MultipartEntityBuilder builder = MultipartEntityBuilder.create();
                builder.addTextBody("accountID", Main.accountID, ContentType.TEXT_PLAIN);
                builder.addTextBody("problem", String.valueOf(problems.getSelectedItem()),
                        ContentType.TEXT_PLAIN);
                builder.addBinaryBody("submission", file, ContentType.APPLICATION_OCTET_STREAM, file.getName());
                HttpEntity multipart = builder.build();

                uploadFile.setEntity(multipart);

                CloseableHttpResponse response = httpClient.execute(uploadFile);
                HttpEntity responseEntity = response.getEntity();
                String inputLine;
                BufferedReader br = new BufferedReader(new InputStreamReader(responseEntity.getContent()));
                try {
                    if ((inputLine = br.readLine()) != null) {
                        int rowIndex = Integer.parseInt(inputLine);
                        new ResultWatcher(rowIndex);
                    }
                    br.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        } catch (NullPointerException ex) {
            JOptionPane.showMessageDialog(this, "No file selected.\nPlease select a java file.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        }
    });
    submitPanel.add(submit);

    JPanel clarificationsPanel = new JPanel(null);
    clarificationsPanel.setPreferredSize(new Dimension(500, 500));

    cList = new JList<>();
    cList.setBounds(12, 12, 476, 200);
    cList.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    cList.setBackground(new Color(254, 254, 255));
    clarificationsPanel.add(cList);

    JButton viewC = new JButton("View");
    viewC.setBounds(12, 224, 232, 25);
    viewC.addActionListener(e -> {
        if (cList.getSelectedIndex() != -1) {
            int id = Integer.parseInt(cList.getSelectedValue().split("\\.")[0]);
            clarificationDatas.stream().filter(data -> data.getId() == id).forEach(
                    data -> new ClarificationDisplay(data.getProblem(), data.getText(), data.getResponse()));
        }
    });
    clarificationsPanel.add(viewC);

    JButton refreshC = new JButton("Refresh");
    refreshC.setBounds(256, 224, 232, 25);
    refreshC.addActionListener(e -> updateCList(true));
    clarificationsPanel.add(refreshC);

    JSeparator separator2 = new JSeparator();
    separator2.setBounds(12, 261, 476, 2);
    separator2.setForeground(new Color(122, 138, 152));
    clarificationsPanel.add(separator2);

    JLabel problemChooserLabelC = new JLabel("Problem:");
    problemChooserLabelC.setBounds(12, 273, 74, 25);
    clarificationsPanel.add(problemChooserLabelC);

    JComboBox problemsC = new JComboBox<>(listOfProblems);
    problemsC.setBounds(96, 273, 393, 25);
    clarificationsPanel.add(problemsC);

    JTextArea textAreaC = new JTextArea();
    textAreaC.setLineWrap(true);
    textAreaC.setWrapStyleWord(true);
    textAreaC.setBorder(new CompoundBorder(BorderFactory.createLineBorder(new Color(122, 138, 152)),
            BorderFactory.createEmptyBorder(8, 8, 8, 8)));
    textAreaC.setBackground(new Color(254, 254, 255));

    JScrollPane areaScrollPane = new JScrollPane(textAreaC);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setBounds(12, 312, 477, 134);
    clarificationsPanel.add(areaScrollPane);

    JButton submitC = new JButton("Submit Clarification");
    submitC.setBounds(170, 458, 160, 30);
    submitC.addActionListener(e -> {
        if (textAreaC.getText().length() > 2048) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too long.\nMaximum of 2048 characters allowed.", "Error",
                    JOptionPane.WARNING_MESSAGE);
        } else if (textAreaC.getText().length() < 20) {
            JOptionPane.showMessageDialog(this,
                    "Clarification body is too short.\nClarifications must be at least 20 characters, but no more than 2048.",
                    "Error", JOptionPane.WARNING_MESSAGE);
        } else {
            Connection conn = null;
            PreparedStatement stmt = null;
            try {
                Class.forName(JDBC_DRIVER);

                conn = DriverManager.getConnection(Main.Configuration.get("jdbc_mysql_address"),
                        Main.Configuration.get("mysql_user"), Main.Configuration.get("mysql_pass"));

                String sql = "INSERT INTO clarifications (team, problem, text) VALUES (?, ?, ?)";
                stmt = conn.prepareStatement(sql);

                stmt.setInt(1, Integer.parseInt(String.valueOf(Main.accountID)));
                stmt.setString(2, String.valueOf(problemsC.getSelectedItem()));
                stmt.setString(3, String.valueOf(textAreaC.getText()));

                textAreaC.setText("");

                stmt.executeUpdate();

                stmt.close();
                conn.close();

                updateCList(false);
            } catch (Exception ex) {
                ex.printStackTrace();
            } finally {
                try {
                    if (stmt != null) {
                        stmt.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
                try {
                    if (conn != null) {
                        conn.close();
                    }
                } catch (Exception ex2) {
                    ex2.printStackTrace();
                }
            }
        }
    });
    clarificationsPanel.add(submitC);

    pane.addTab("Submit", submitPanel);
    pane.addTab("Clarifications", clarificationsPanel);

    Timer timer = new Timer();
    TimerTask updateTask = new TimerTask() {
        @Override
        public void run() {
            updateCList(false);
        }
    };
    timer.schedule(updateTask, 10000, 10000);

    updateCList(false);

    this.pack();
    this.setLocationRelativeTo(null);
    this.setVisible(true);
}

From source file:org.jtheque.films.stats.view.impl.StatsView.java

/**
 * Build the content pane./*from  ww  w. j av  a  2 s.co  m*/
 *
 * @return The content pane.
 */
private Container buildContentPane() {
    tab = new JTabbedPane();
    tab.setTabPlacement(JTabbedPane.TOP);

    Map<JComponent, String> components = new HashMap<JComponent, String>(3);

    addTab(components, panelFilms, "stats.view.tab.films");
    addTab(components, panelActors, "stats.view.tab.actors");
    addTab(components, panelRealizers, "stats.view.tab.realizers");

    Managers.getManager(ILanguageManager.class).addInternationalizable(new TabTitleUpdater(tab, components));

    return tab;
}