Example usage for javax.swing JList JList

List of usage examples for javax.swing JList JList

Introduction

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

Prototype

public JList() 

Source Link

Document

Constructs a JList with an empty, read-only, model.

Usage

From source file:gtu.log.finder.ExceptionLogFinderUI.java

private void initGUI() {
    try {//w w w.  j av  a2  s.c  om
        JCommonUtil.defaultLookAndFeel();
        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("?log", null, jPanel1, null);
                {
                    jPanel4 = new JPanel();
                    jPanel1.add(jPanel4, BorderLayout.NORTH);
                    jPanel4.setPreferredSize(new java.awt.Dimension(689, 115));
                    {
                        isExceptionLogChkBox = new JCheckBox();
                        jPanel4.add(isExceptionLogChkBox);
                        isExceptionLogChkBox.setText("\u53ea\u627e\u932f\u8aa4");
                    }
                    {
                        jLabel1 = new JLabel();
                        jPanel4.add(jLabel1);
                        jLabel1.setText("\u8cbc\u4e0alog\u6a94\u8def\u5f91");
                    }
                    {
                        srcFilePathText = new JTextField();
                        jPanel4.add(srcFilePathText);
                        srcFilePathText.setPreferredSize(new java.awt.Dimension(292, 22));
                        srcFilePathText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                srcFilePathTextSetFileAction(evt);
                            }
                        });
                    }
                    {
                        jLabel3 = new JLabel();
                        jPanel4.add(jLabel3);
                        jLabel3.setText("\u524d\u7f6e\u884c\u6578");
                    }
                    {
                        preLineText = new JTextField();
                        jPanel4.add(preLineText);
                        preLineText.setText("5");
                        preLineText.setPreferredSize(new java.awt.Dimension(33, 22));
                    }
                    {
                        executeBtn = new JButton();
                        jPanel4.add(executeBtn);
                        executeBtn.setText("\u57f7\u884c\u89e3\u6790");
                        executeBtn.setPreferredSize(new java.awt.Dimension(107, 22));
                        executeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                executeBtnAction();
                            }
                        });
                    }
                    {
                        jLabel4 = new JLabel();
                        jPanel4.add(jLabel4);
                        jLabel4.setText("\u76f4\u63a5\u8a2d\u5b9a\u89e3\u6790\u6a94\u8def\u5f91");
                        jLabel4.setPreferredSize(new java.awt.Dimension(119, 15));
                    }
                    {
                        setParseFileText = new JTextField();
                        jPanel4.add(setParseFileText);
                        setParseFileText.setPreferredSize(new java.awt.Dimension(507, 22));
                        setParseFileText.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                setParseFileBtnAction(evt);
                            }
                        });
                    }
                    {
                        jLabel2 = new JLabel();
                        jPanel4.add(jLabel2);
                        jLabel2.setText("\u641c\u5c0b\u95dc\u9375\u5b57");
                    }
                    {
                        searchText = new JTextField();
                        jPanel4.add(searchText);
                        searchText.setPreferredSize(new java.awt.Dimension(355, 22));
                    }
                    {
                        ignoreCaseCheckBox = new JCheckBox();
                        jPanel4.add(ignoreCaseCheckBox);
                        ignoreCaseCheckBox.setText("\u7121\u8996\u5927\u5c0f\u5beb");
                        ignoreCaseCheckBox.setSelected(true);
                    }
                    {
                        searchTextBtn = new JButton();
                        jPanel4.add(searchTextBtn);
                        searchTextBtn.setText("?");
                        searchTextBtn.setPreferredSize(new java.awt.Dimension(118, 22));
                        searchTextBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                searchTextBtnAction();
                            }
                        });
                    }
                    {
                        jLabel5 = new JLabel();
                        jPanel4.add(jLabel5);
                        jLabel5.setText(
                                "\u4ee5\u958b\u59cb\u7d50\u675f\u95dc\u9375\u5b57\u89e3\u6790\u6587\u4ef6");
                        jLabel5.setPreferredSize(new java.awt.Dimension(155, 15));
                    }
                    {
                        startStrText = new JTextField();
                        jPanel4.add(startStrText);
                        startStrText.setPreferredSize(new java.awt.Dimension(229, 22));
                    }
                    {
                        endStrText = new JTextField();
                        jPanel4.add(endStrText);
                        endStrText.setPreferredSize(new java.awt.Dimension(244, 22));
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(689, 391));
                    {
                        DefaultListModel searchMatchListModel = new DefaultListModel();
                        searchMatchList = new JList();
                        jScrollPane1.setViewportView(searchMatchList);
                        searchMatchList.setModel(searchMatchListModel);
                        searchMatchList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                searchMatchListMouseAction(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("", null, jPanel2, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(689, 484));
                    {
                        logDetailTextArea = new JTextArea();
                        jScrollPane2.setViewportView(logDetailTextArea);
                    }
                }
            }
        }
        pack();
        this.setSize(702, 538);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {//from  ww  w  . j  av a 2 s.  co  m
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            jTabbedPane1.addChangeListener(new ChangeListener() {
                public void stateChanged(ChangeEvent e) {
                    try {
                        if (configHandler != null
                                && jTabbedPane1.getSelectedIndex() == TabIndex.TEMPLATE.ordinal()) {
                            System.out.println("-------ChangeEvent[" + jTabbedPane1.getSelectedIndex() + "]");
                            configHandler.reloadTemplateList();
                        }
                    } catch (Exception ex) {
                        JCommonUtil.handleException(ex);
                    }
                }
            });
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        replaceArea = new JTextArea();
                        jScrollPane1.setViewportView(replaceArea);
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    jPanel2.add(JCommonUtil.createScrollComponent(jPanel3), BorderLayout.CENTER);
                    jPanel3.setLayout(new FormLayout(
                            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
                            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                                    RowSpec.decode("default:grow"), }));
                    {
                        lblNewLabel = new JLabel("key");
                        jPanel3.add(lblNewLabel, "2, 2, right, default");
                    }
                    {
                        configKeyText = new JTextField();
                        jPanel3.add(configKeyText, "4, 2, fill, default");
                        configKeyText.setColumns(10);
                    }
                    {
                        lblNewLabel_1 = new JLabel("from");
                        jPanel3.add(lblNewLabel_1, "2, 4, right, default");
                    }
                    {
                        repFromText = new JTextArea();
                        repFromText.setRows(3);
                        jPanel3.add(JCommonUtil.createScrollComponent(repFromText), "4, 4, fill, default");
                        repFromText.setColumns(10);
                    }
                    {
                        lblNewLabel_2 = new JLabel("to");
                        jPanel3.add(lblNewLabel_2, "2, 6, right, default");
                    }
                    {
                        repToText = new JTextArea();
                        repToText.setRows(3);
                        // repToText.setPreferredSize(new Dimension(0, 50));
                        jPanel3.add(JCommonUtil.createScrollComponent(repToText), "4, 6, fill, default");
                    }
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            configHandler.put(configKeyText.getText(), repFromText.getText(),
                                    repToText.getText(), tradeOffArea.getText());
                            configHandler.reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        jScrollPane3.setViewportView(templateList);
                    }
                    templateList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            if (templateList.getLeadSelectionIndex() == -1) {
                                return;
                            }
                            PropConfigHandler.Config config = (PropConfigHandler.Config) JListUtil
                                    .getLeadSelectionObject(templateList);
                            configKeyText.setText(config.configKeyText);
                            repFromText.setText(config.fromVal);
                            repToText.setText(config.toVal);
                            tradeOffArea.setText(config.tradeOff);

                            templateList.setToolTipText(config.fromVal + " <----> " + config.toVal);

                            if (JMouseEventUtil.buttonLeftClick(2, evt)) {
                                String replaceText = StringUtils.defaultString(replaceArea.getText());
                                replaceText = replacer(config.fromVal, config.toVal, replaceText);
                                resultArea.setText(replaceText);
                                jTabbedPane1.setSelectedIndex(TabIndex.RESULT.ordinal());
                                // 
                                pasteTextToClipboard();
                            }
                        }
                    });
                    templateList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                        }
                    });

                    // ? 
                    JListUtil.newInstance(templateList).setItemColorTextProcess(new ItemColorTextHandler() {
                        public Pair<String, Color> setColorAndText(Object value) {
                            PropConfigHandler.Config config = (PropConfigHandler.Config) value;
                            if (config.tradeOffScore != 0) {
                                return Pair.of(null, Color.GREEN);
                            }
                            return null;
                        }
                    });
                    // ? 
                }
                {
                    scheduleExecute = new JButton();
                    jPanel5.add(scheduleExecute, BorderLayout.SOUTH);
                    scheduleExecute.setText("schedule execute");
                    scheduleExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            scheduleExecuteActionPerformed(evt);
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        resultArea = new JTextArea();
                        jScrollPane2.setViewportView(resultArea);
                    }
                }
            }
        }

        {
            configHandler = new PropConfigHandler(prop, propFile, templateList, replaceArea);
            JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList);
            {
                tradeOffArea = new JTextArea();
                tradeOffArea.setRows(3);
                // tradeOffArea.setPreferredSize(new Dimension(0, 50));
                tradeOffArea.addMouseListener(new MouseAdapter() {
                    @Override
                    public void mouseClicked(MouseEvent e) {
                        try {
                            if (JMouseEventUtil.buttonLeftClick(2, e)) {
                                String tradeOff = StringUtils.trimToEmpty(tradeOffArea.getText());
                                JSONObject json = null;
                                if (StringUtils.isBlank(tradeOff)) {
                                    json = new JSONObject();
                                    json.put(CONTAIN_ARRY_KEY, new JSONArray());
                                    json.put(NOT_CONTAIN_ARRY_KEY, new JSONArray());
                                    tradeOff = json.toString();
                                } else {
                                    json = JSONObject.fromObject(tradeOff);
                                }

                                // 
                                String selectItem = (String) JCommonUtil._JOptionPane_showInputDialog(
                                        "?!", "?",
                                        new Object[] { "NA", "equal", "not_equal", "ftl" }, "NA");
                                if ("NA".equals(selectItem)) {
                                    return;
                                }

                                String string = StringUtils.trimToEmpty(
                                        JCommonUtil._jOptionPane_showInputDialog(":"));
                                string = StringUtils.trimToEmpty(string);

                                if (StringUtils.isBlank(string)) {
                                    tradeOffArea.setText(json.toString());
                                    return;
                                }

                                String arryKey = "";
                                String boolKey = "";
                                String strKey = "";
                                String intKey = "";

                                if (selectItem.equals("equal")) {
                                    arryKey = CONTAIN_ARRY_KEY;
                                } else if (selectItem.equals("not_equal")) {
                                    arryKey = NOT_CONTAIN_ARRY_KEY;
                                } else if (selectItem.equals("ftl")) {
                                    strKey = FREEMARKER_KEY;
                                } else {
                                    throw new RuntimeException(" : " + selectItem);
                                }

                                if (StringUtils.isNotBlank(arryKey)) {
                                    if (!json.containsKey(arryKey)) {
                                        json.put(arryKey, new JSONArray());
                                    }
                                    JSONArray arry = (JSONArray) json.get(arryKey);
                                    boolean findOk = false;
                                    for (int ii = 0; ii < arry.size(); ii++) {
                                        if (StringUtils.equalsIgnoreCase(arry.getString(ii), string)) {
                                            findOk = true;
                                            break;
                                        }
                                    }
                                    if (!findOk) {
                                        arry.add(string);
                                    }
                                } else if (StringUtils.isNotBlank(strKey)) {
                                    json.put(strKey, string);
                                } else if (StringUtils.isNotBlank(intKey)) {
                                    json.put(intKey, Integer.parseInt(string));
                                } else if (StringUtils.isNotBlank(boolKey)) {
                                    json.put(boolKey, Boolean.valueOf(string));
                                }

                                tradeOffArea.setText(json.toString());

                                JCommonUtil._jOptionPane_showMessageDialog_info("?!");
                            }
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
                {
                    panel = new JPanel();
                    jPanel3.add(panel, "4, 8, fill, fill");
                    {
                        multiLineCheckBox = new JCheckBox("");
                        panel.add(multiLineCheckBox);
                    }
                    {
                        autoPasteToClipboardCheckbox = new JCheckBox("");
                        panel.add(autoPasteToClipboardCheckbox);
                    }
                }
                {
                    lblNewLabel_3 = new JLabel("? ");
                    jPanel3.add(lblNewLabel_3, "2, 10");
                }
                jPanel3.add(JCommonUtil.createScrollComponent(tradeOffArea), "4, 10, fill, fill");
            }
            configHandler.reloadTemplateList();
        }

        this.setSize(512, 350);
        JCommonUtil.setJFrameCenter(this);
        JCommonUtil.defaultToolTipDelay();

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:it.cnr.icar.eric.client.ui.swing.RegistryObjectsTable.java

@SuppressWarnings("unchecked")
private void addRenderers() {
    try {//w ww.  ja va  2  s  . co  m
        setDefaultRenderer(Class.forName("java.lang.Object"), new JBDefaultTableCellRenderer());
        setDefaultRenderer(Class.forName("java.util.Collection"), new CollectionRenderer());

        final JList<Object> list = new JList<Object>();
        list.setVisibleRowCount(3);
        list.setOpaque(true);
        list.setCellRenderer(new ListDefaultRenderer());

        list.addListSelectionListener(new ListSelectionListener() {
            @SuppressWarnings({ "static-access", "unused" })
            public void valueChanged(ListSelectionEvent e) {
                if (!e.getValueIsAdjusting()) {
                    Object obj = list.getSelectedValue();
                    obj = RegistryObjectsTable.this.convertValue(obj);

                    if (obj instanceof URL) {
                        HyperLinker.displayURL(obj.toString());
                    } else if (obj instanceof String) {
                        //Check if URL is valid
                        URL _url = null;

                        try {
                            _url = new URL(obj.toString());
                            HyperLinker.displayURL(obj.toString());
                        } catch (MalformedURLException exc) {
                            //No need to do anything. It is normal for text to not be a URL
                            _url = null;
                        }
                    }
                }
            }
        });

        JScrollPane listPane = new JScrollPane(list);
        setDefaultEditor(Class.forName("java.util.Collection"), new JBDefaultCellEditor(listPane));

        HyperLinkLabel hyperLinkLabel = new HyperLinkLabel();
        hyperLinkLabel.setHorizontalAlignment(SwingConstants.TRAILING);
        setDefaultEditor(Class.forName("java.lang.Object"), new JBDefaultCellEditor(hyperLinkLabel));
    } catch (ClassNotFoundException e) {
        return;
    }
}

From source file:zet.gui.assignmentEditor.JAssignmentPanel.java

/**
 * Returns the panel on the left side of the {@code JAssignmentPanel} that
 * contains lists of assignments and assignment types.
 * @return the panel on the left side of the {@code JAssignmentPanel}
 *///ww  w.  ja  v  a2s  .c om
private JPanel getLeftPanel() {
    final int space = 16;
    double size[][] = // Columns
            { { space, TableLayout.FILL, space, TableLayout.FILL, space },
                    //Rows
                    { space, TableLayout.PREFERRED, // Label
                            1, TableLayout.FILL, // Auswahlbox
                            space, TableLayout.PREFERRED, // Label Name
                            1, TableLayout.PREFERRED, // TextFeld
                            1, TableLayout.PREFERRED, 1, TableLayout.PREFERRED, 1, TableLayout.PREFERRED, // Button
                            space, TableLayout.PREFERRED, // Button Neu
                            5, TableLayout.PREFERRED, // Button Lschen
                            space } };

    JPanel leftPanel = new JPanel(new TableLayout(size));
    int row = 1;

    leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Assignments")), "1, " + row++);
    row++;

    assignmentSelector = new AssignmentListModel();
    lstAssignment = new JList<>();
    lstAssignment.setModel(assignmentSelector);
    lstAssignment.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lstAssignment.setCellRenderer(new AssignmentListRenderer());
    lstAssignment.setSelectionModel(new AssignmentListSelectionModel());
    lstAssignment.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            if (e.getClickCount() == 2) {
                setCurrent();
            }
        }
    });

    leftPanel.add(new JScrollPane(lstAssignment), "1, " + row++);
    row++;

    leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Name")), "1, " + row++);
    row++;

    addAssignmentText = new JTextField();
    leftPanel.add(addAssignmentText, "1, " + row++);
    row++;

    JButton assignmentChange = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentSave"),
            aclAssignmentSaveChanges);
    assignmentChange.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip"));
    leftPanel.add(assignmentChange, "1, " + row++);
    row++;

    row += 4;

    JButton assignmentAdd = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentAdd"),
            aclAssignmentAdd);
    assignmentAdd.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip"));
    leftPanel.add(assignmentAdd, "1, " + row++);
    row++;

    JButton assignmentDelete = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentDelete"),
            aclAssignmentDelete);
    assignmentDelete.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentSave.ToolTip"));
    leftPanel.add(assignmentDelete, "1, " + row++);
    row++;

    // Rechter Teil
    row = 1;
    leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.AssignmentTypes")), "3, " + row++);
    row++;

    assignmentTypeSelector = new AssignmentTypeListModel();
    lstAssignmentType = new JList<>();
    lstAssignmentType.setModel(assignmentTypeSelector);
    lstAssignmentType.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lstAssignmentType.setCellRenderer(new AssignmentTypeListRenderer());
    lstAssignmentType.setSelectionModel(new AssignmentTypeListSelectionModel());

    leftPanel.add(new JScrollPane(lstAssignmentType), "3, " + row++);
    row++;

    leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.Name")), "3, " + row++);
    row++;

    addAssignmentTypeText = new JTextField();
    leftPanel.add(addAssignmentTypeText, "3, " + row++);
    row++;

    leftPanel.add(new JLabel(loc.getString("gui.AssignmentEditor.label.DefaultEvacuees")), "3, " + row++);
    row++;
    txtDefaultEvacuees = new JTextField();
    txtDefaultEvacuees.addKeyListener(kylEvacuees);
    leftPanel.add(txtDefaultEvacuees, "3, " + row++);
    row++;

    JButton assignmentTypeChange = Button.newButton(
            loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave"), aclAssignmentTypeSaveChanges);
    assignmentTypeChange
            .setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave.ToolTip"));
    leftPanel.add(assignmentTypeChange, "3, " + row++);
    row++;

    JButton assignmentTypeAdd = Button.newButton(loc.getString("gui.AssignmentEditor.button.AssignmentTypeAdd"),
            aclAssignmentTypeAdd);
    assignmentTypeAdd.setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeAdd.ToolTip"));
    leftPanel.add(assignmentTypeAdd, "3, " + row++);
    row++;

    JButton assignmentTypeDelete = Button.newButton(
            loc.getString("gui.AssignmentEditor.button.AssignmentTypeDelete"), aclAssignmentTypeDelete);
    assignmentTypeDelete
            .setToolTipText(loc.getString("gui.AssignmentEditor.button.AssignmentTypeSave.ToolTip"));
    leftPanel.add(assignmentTypeDelete, "3, " + row++);
    row++;

    return leftPanel;
}

From source file:ca.phon.app.project.ProjectWindow.java

private void init() {
    /* Layout *//*from   w w  w  .j  a va 2  s .  com*/
    setLayout(new BorderLayout());

    final ProjectDataTransferHandler transferHandler = new ProjectDataTransferHandler(this);

    /* Create components */
    newCorpusButton = createNewCorpusButton();
    createCorpusButton = createCorpusButton();

    corpusList = new JList<String>();
    corpusModel = new CorpusListModel(getProject());
    corpusList.setModel(corpusModel);
    corpusList.setCellRenderer(new CorpusListCellRenderer());
    corpusList.setVisibleRowCount(20);
    corpusList.addListSelectionListener(e -> {
        if (getSelectedCorpus() != null) {
            String corpus = getSelectedCorpus();
            sessionModel.setCorpus(corpus);
            sessionList.clearSelection();
            corpusDetails.setCorpus(corpus);

            if (getProject().getCorpusSessions(corpus).size() == 0) {
                onSwapNewAndCreateSession(newSessionButton);
            } else {
                onSwapNewAndCreateSession(createSessionButton);
            }
        }
    });
    corpusList.addMouseListener(new MouseInputAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = corpusList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(corpusList.getSelectedIndices(), clickedIdx) < 0) {
                    corpusList.setSelectedIndex(clickedIdx);
                }
                showCorpusListContextMenu(e.getPoint());
            }
        }
    });

    final DragSource corpusDragSource = new DragSource();
    corpusDragSource.createDefaultDragGestureRecognizer(corpusList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        for (String corpus : getSelectedCorpora()) {
            final ProjectPath corpusPath = new ProjectPath(getProject(), corpus, null);
            paths.add(corpusPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    corpusList.setDragEnabled(true);
    corpusList.setTransferHandler(transferHandler);

    corpusDetails = new CorpusDetailsPane(getProject());
    corpusDetails.setWrapStyleWord(true);
    corpusDetails.setRows(6);
    corpusDetails.setLineWrap(true);
    corpusDetails.setBackground(Color.white);
    corpusDetails.setOpaque(true);
    JScrollPane corpusDetailsScroller = new JScrollPane(corpusDetails);

    sessionList = new JList<String>();
    newSessionButton = createNewSessionButton();
    createSessionButton = createSessionButton();
    sessionModel = new SessionListModel(getProject());
    sessionList.setModel(sessionModel);
    sessionList.setCellRenderer(new SessionListCellRenderer());
    sessionList.setVisibleRowCount(20);
    sessionList.addListSelectionListener(e -> {
        if (sessionList.getSelectedValue() != null && !e.getValueIsAdjusting()) {
            String corpus = getSelectedCorpus();
            String session = getSelectedSessionName();

            sessionDetails.setSession(corpus, session);
        }
    });
    sessionList.addMouseListener(new MouseInputAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == 1) {
                // get the clicked item
                int clickedItem = sessionList.locationToIndex(e.getPoint());
                if (sessionList.getModel().getElementAt(clickedItem) == null)
                    return;

                final String session = sessionList.getModel().getElementAt(clickedItem).toString();
                final String corpus = ((SessionListModel) sessionList.getModel()).getCorpus();

                msgPanel.reset();
                msgPanel.setMessageLabel("Opening '" + corpus + "." + session + "'");
                msgPanel.setIndeterminate(true);
                msgPanel.repaint();

                SwingUtilities.invokeLater(() -> {
                    final ActionEvent ae = new ActionEvent(sessionList, -1, "openSession");
                    (new OpenSessionAction(ProjectWindow.this, corpus, session)).actionPerformed(ae);

                    msgPanel.setIndeterminate(false);
                });
            }
        }

        @Override
        public void mousePressed(MouseEvent e) {
            doPopup(e);
        }

        @Override
        public void mouseReleased(MouseEvent e) {
            doPopup(e);
        }

        public void doPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                int clickedIdx = sessionList.locationToIndex(e.getPoint());
                if (clickedIdx >= 0 && Arrays.binarySearch(sessionList.getSelectedIndices(), clickedIdx) < 0) {
                    sessionList.setSelectedIndex(clickedIdx);
                }
                showSessionListContextMenu(e.getPoint());
            }
        }
    });

    sessionList.setDragEnabled(true);
    sessionList.setTransferHandler(transferHandler);

    final DragSource sessionDragSource = new DragSource();
    sessionDragSource.createDefaultDragGestureRecognizer(sessionList, DnDConstants.ACTION_COPY, (event) -> {
        final List<ProjectPath> paths = new ArrayList<>();
        final String corpus = getSelectedCorpus();
        if (corpus == null)
            return;
        for (String session : getSelectedSessionNames()) {
            final ProjectPath sessionPath = new ProjectPath(getProject(), corpus, session);
            paths.add(sessionPath);
        }
        final ProjectPathTransferable transferable = new ProjectPathTransferable(paths);
        event.startDrag(DragSource.DefaultCopyDrop, transferable);
    });

    sessionDetails = new SessionDetailsPane(getProject());
    sessionDetails.setLineWrap(true);
    sessionDetails.setRows(6);
    sessionDetails.setWrapStyleWord(true);
    sessionDetails.setBackground(Color.white);
    sessionDetails.setOpaque(true);
    JScrollPane sessionDetailsScroller = new JScrollPane(sessionDetails);

    JScrollPane corpusScroller = new JScrollPane(corpusList);
    JScrollPane sessionScroller = new JScrollPane(sessionList);

    blindModeBox = new JCheckBox("Blind transcription");
    blindModeBox.setSelected(false);

    msgPanel = new StatusPanel();

    corpusPanel = new JPanel(new BorderLayout());
    corpusPanel.add(newCorpusButton, BorderLayout.NORTH);
    corpusPanel.add(corpusScroller, BorderLayout.CENTER);
    corpusPanel.add(corpusDetailsScroller, BorderLayout.SOUTH);

    sessionPanel = new JPanel(new BorderLayout());
    sessionPanel.add(newSessionButton, BorderLayout.NORTH);
    sessionPanel.add(sessionScroller, BorderLayout.CENTER);
    sessionPanel.add(sessionDetailsScroller, BorderLayout.SOUTH);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(corpusPanel);
    splitPane.setRightComponent(sessionPanel);
    splitPane.setResizeWeight(0.5);

    // invoke later
    SwingUtilities.invokeLater(() -> {
        splitPane.setDividerLocation(0.5);
    });

    // the frame layout
    String projectName = null;
    projectName = getProject().getName();

    DialogHeader header = new DialogHeader(projectName, StringUtils.abbreviate(projectLoadPath, 80));

    add(header, BorderLayout.NORTH);

    CellConstraints cc = new CellConstraints();
    final JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref"));
    topPanel.add(msgPanel, cc.xy(1, 1));
    topPanel.add(blindModeBox, cc.xy(3, 1));

    add(splitPane, BorderLayout.CENTER);
    add(topPanel, BorderLayout.SOUTH);

    // if no corpora are currently available, 'prompt' the user to create a new one
    if (getProject().getCorpora().size() == 0) {
        SwingUtilities.invokeLater(() -> {
            onSwapNewAndCreateCorpus(newCorpusButton);
        });
    } else {
        SwingUtilities.invokeLater(() -> {
            corpusList.setSelectedIndex(0);
        });
    }
}

From source file:com.raddle.tools.MergeMain.java

private void initGUI() {
    try {//w  w  w .j a  va 2  s .com
        {
            this.setBounds(0, 0, 1050, 600);
            getContentPane().setLayout(null);
            this.setTitle("\u5c5e\u6027\u6587\u4ef6\u6bd4\u8f83");
            {
                sourceTxt = new JTextField();
                getContentPane().add(sourceTxt);
                sourceTxt.setBounds(12, 12, 373, 22);
            }
            {
                sourceBtn = new JButton();
                getContentPane().add(sourceBtn);
                sourceBtn.setText("\u6253\u5f00");
                sourceBtn.setBounds(406, 12, 74, 22);
                sourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(sourceTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            source = new PropertyHolder(selected, "utf-8");
                            sourceTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("left.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                targetTxt = new JTextField();
                getContentPane().add(targetTxt);
                targetTxt.setBounds(496, 12, 419, 22);
            }
            {
                targetBtn = new JButton();
                getContentPane().add(targetBtn);
                targetBtn.setText("\u6253\u5f00");
                targetBtn.setBounds(935, 12, 81, 22);
                targetBtn.setSize(74, 22);
                targetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        JFileChooser fileChooser = new JFileChooser(); // 
                        fileChooser.addChoosableFileFilter(
                                new FileNameExtensionFilter("", "properties"));
                        File curFile = new File(targetTxt.getText());
                        if (curFile.exists()) {
                            fileChooser.setCurrentDirectory(curFile.getParentFile());
                        }
                        int result = fileChooser.showOpenDialog(MergeMain.this);
                        if (result == JFileChooser.APPROVE_OPTION) {
                            File selected = fileChooser.getSelectedFile();
                            target = new PropertyHolder(selected, "utf-8");
                            targetTxt.setText(selected.getAbsolutePath());
                            properties.setProperty("right.file", selected.getAbsolutePath());
                            savePropMergeFile();
                            compare();
                        }
                    }
                });
            }
            {
                jScrollPane1 = new JScrollPane();
                getContentPane().add(jScrollPane1);
                jScrollPane1.setBounds(12, 127, 373, 413);
                {
                    ListModel sourceListModel = new DefaultComboBoxModel(new String[] {});
                    sourceList = new JList();
                    jScrollPane1.setViewportView(sourceList);
                    sourceList.setAutoscrolls(true);
                    sourceList.setModel(sourceListModel);
                    sourceList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) sourceList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        sourceList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    sourceList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = sourceList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                sourceList.setSelectedValue(v, true);
                            }
                        }
                    });
                    sourceList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (sourceList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) sourceList.getSelectedValue();
                                if (target != null) {
                                    PropertyLine p = target.getLine(pl.getKey());
                                    if (p != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(p.toString(),
                                                pl.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(targetList, p);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult("", pl.toString());
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());

                            }
                        }
                    });
                }
            }
            {
                jScrollPane2 = new JScrollPane();
                getContentPane().add(jScrollPane2);
                jScrollPane2.setBounds(496, 127, 419, 413);
                {
                    ListModel targetListModel = new DefaultComboBoxModel(new String[] {});
                    targetList = new JList();
                    jScrollPane2.setViewportView(targetList);
                    targetList.setAutoscrolls(true);
                    targetList.setModel(targetListModel);
                    targetList.addKeyListener(new KeyAdapter() {
                        @Override
                        public void keyPressed(KeyEvent evt) {
                            if (evt.getKeyCode() == KeyEvent.VK_DELETE) {
                                PropertyLine v = (PropertyLine) targetList.getSelectedValue();
                                if (v != null) {
                                    int ret = JOptionPane.showConfirmDialog(MergeMain.this,
                                            "?" + v.getKey() + "?");
                                    if (ret == JOptionPane.YES_OPTION) {
                                        v.setState(LineState.deleted);
                                        compare();
                                        targetList.setSelectedValue(v, true);
                                    }
                                }
                            }
                        }
                    });
                    targetList.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseClicked(MouseEvent evt) {
                            if (evt.getClickCount() == 2) {
                                Object v = targetList.getSelectedValue();
                                updatePropertyLine((PropertyLine) v);
                                targetList.setSelectedValue(v, true);
                            }
                        }
                    });
                    targetList.addListSelectionListener(new ListSelectionListener() {

                        @Override
                        public void valueChanged(ListSelectionEvent evt) {
                            if (targetList.getSelectedValue() != null) {
                                PropertyLine pl = (PropertyLine) targetList.getSelectedValue();
                                if (source != null) {
                                    PropertyLine s = source.getLine(pl.getKey());
                                    if (s != null) {
                                        TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(),
                                                s.toString());
                                        diffResultPane.setText("" + rt.getTargetHtml() + "<br/>?"
                                                + rt.getSrcHtml());
                                        selectLine(sourceList, s);
                                        return;
                                    }
                                }
                                TextDiffResult rt = TextdiffUtil.getDifferResult(pl.toString(), "");
                                diffResultPane.setText(
                                        "" + rt.getTargetHtml() + "<br/>?" + rt.getSrcHtml());
                            }
                        }
                    });
                }
            }
            {
                sourceSaveBtn = new JButton();
                getContentPane().add(sourceSaveBtn);
                sourceSaveBtn.setText("\u4fdd\u5b58");
                sourceSaveBtn.setBounds(406, 45, 74, 22);
                sourceSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "???\n"
                                        + source.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            source.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(source);
                            compare();
                        }
                    }
                });
            }
            {
                targetSaveBtn = new JButton();
                getContentPane().add(targetSaveBtn);
                targetSaveBtn.setText("\u4fdd\u5b58");
                targetSaveBtn.setBounds(935, 45, 81, 22);
                targetSaveBtn.setSize(74, 22);
                targetSaveBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        int result = JOptionPane.showConfirmDialog(MergeMain.this,
                                "????\n"
                                        + target.getPropertyFile().getAbsolutePath());
                        if (result == JOptionPane.YES_OPTION) {
                            target.saveFile();
                            JOptionPane.showMessageDialog(MergeMain.this, "??");
                            clearState(target);
                            compare();
                        }
                    }
                });
            }
            {
                toTargetBtn = new JButton();
                getContentPane().add(toTargetBtn);
                toTargetBtn.setText("->");
                toTargetBtn.setBounds(406, 221, 74, 22);
                toTargetBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = sourceList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine s = (PropertyLine) selected;
                            if (s != null && target != null) {
                                PropertyLine t = target.getLine(s.getKey());
                                if (t == null) {
                                    PropertyLine n = s.clone();
                                    n.setState(LineState.added);
                                    target.addPropertyLineAtSuitedPosition(n);
                                } else if (!t.getValue().equals(s.getValue())) {
                                    t.setState(LineState.updated);
                                    t.setValue(s.getValue());
                                } else if (t.getState() == LineState.deleted) {
                                    if (t.getValue().equals(t.getOriginalValue())) {
                                        t.setState(LineState.original);
                                    } else {
                                        t.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                toSourceBtn = new JButton();
                getContentPane().add(toSourceBtn);
                toSourceBtn.setText("<-");
                toSourceBtn.setBounds(406, 255, 74, 22);
                toSourceBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        Object[] oo = targetList.getSelectedValues();
                        for (Object selected : oo) {
                            PropertyLine t = (PropertyLine) selected;
                            if (t != null && source != null) {
                                PropertyLine s = source.getLine(t.getKey());
                                if (s == null) {
                                    PropertyLine n = t.clone();
                                    n.setState(LineState.added);
                                    source.addPropertyLineAtSuitedPosition(n);
                                } else if (!s.getValue().equals(t.getValue())) {
                                    s.setState(LineState.updated);
                                    s.setValue(t.getValue());
                                } else if (s.getState() == LineState.deleted) {
                                    if (s.getValue().equals(s.getOriginalValue())) {
                                        s.setState(LineState.original);
                                    } else {
                                        s.setState(LineState.updated);
                                    }
                                }
                                compare();
                            }
                        }
                    }
                });
            }
            {
                jScrollPane3 = new JScrollPane();
                getContentPane().add(jScrollPane3);
                jScrollPane3.setBounds(12, 73, 903, 42);
                {
                    diffResultPane = new JTextPane();
                    jScrollPane3.setViewportView(diffResultPane);
                    diffResultPane.setBounds(12, 439, 903, 63);
                    diffResultPane.setContentType("text/html");
                    diffResultPane.setPreferredSize(new java.awt.Dimension(901, 42));
                }
            }
            {
                compareBtn = new JButton();
                getContentPane().add(compareBtn);
                compareBtn.setText("\u6bd4\u8f83");
                compareBtn.setBounds(406, 139, 74, 22);
                compareBtn.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        compare();
                    }
                });
            }
            {
                sourceReloadBtn = new JButton();
                getContentPane().add(sourceReloadBtn);
                sourceReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                sourceReloadBtn.setBounds(12, 40, 64, 29);
                sourceReloadBtn.setSize(90, 22);
                sourceReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText().trim());
                            if (curFile.exists()) {
                                source = new PropertyHolder(curFile, "utf-8");
                                sourceTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("left.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                targetReloadBtn = new JButton();
                getContentPane().add(targetReloadBtn);
                targetReloadBtn.setText("\u91cd\u65b0\u8f7d\u5165");
                targetReloadBtn.setBounds(839, 45, 90, 22);
                targetReloadBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText().trim());
                            if (curFile.exists()) {
                                target = new PropertyHolder(curFile, "utf-8");
                                targetTxt.setText(curFile.getAbsolutePath());
                                properties.setProperty("right.file", curFile.getAbsolutePath());
                                savePropMergeFile();
                                compare();
                            } else {
                                JOptionPane.showMessageDialog(MergeMain.this,
                                        "" + curFile.getAbsolutePath() + "?");
                            }
                        }
                    }
                });
            }
            {
                helpBtn = new JButton();
                getContentPane().add(helpBtn);
                helpBtn.setText("\u5e2e\u52a9");
                helpBtn.setBounds(405, 338, 38, 29);
                helpBtn.setSize(74, 22);
                helpBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        StringBuilder sb = new StringBuilder();
                        sb.append("?").append("\n");
                        sb.append("del").append("\n");
                        sb.append("??").append("\n");
                        sb.append(": /.prop-merge/prop-merge.properties").append("\n");
                        JOptionPane.showMessageDialog(MergeMain.this, sb.toString());
                    }
                });
            }
            {
                sourceEditBtn = new JButton();
                getContentPane().add(sourceEditBtn);
                sourceEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                sourceEditBtn.setBounds(108, 40, 90, 22);
                sourceEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (sourceTxt.getText().length() > 0) {
                            File curFile = new File(sourceTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
            {
                targetEditBtn = new JButton();
                getContentPane().add(targetEditBtn);
                targetEditBtn.setText("\u7f16\u8f91\u6587\u4ef6");
                targetEditBtn.setBounds(743, 45, 90, 22);
                targetEditBtn.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent evt) {
                        if (targetTxt.getText().length() > 0) {
                            File curFile = new File(targetTxt.getText());
                            editFile(curFile);
                        }
                    }
                });
            }
        }
        pack();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.pf.midea.MainUI.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    menuMain = new JMenuBar();
    menuFile = new JMenu();
    menuItemQuit = new JMenuItem();
    menuTools = new JMenu();
    menuConstellations = new JMenu();
    menuItemASK = new JMenuItem();
    menuItemFSK = new JMenuItem();
    menuItemBPSK = new JMenuItem();
    menuItemQPSK = new JMenuItem();
    menuItem8PSK = new JMenuItem();
    menuItem16PSK = new JMenuItem();
    menuItem32PSK = new JMenuItem();
    menuItem16QAM = new JMenuItem();
    menuItem32QAM = new JMenuItem();
    menuItem64QAM = new JMenuItem();
    menuItem256QAM = new JMenuItem();
    menuHelp = new JMenu();
    menuItemAbout = new JMenuItem();
    labelSource = new JLabel();
    SourceCell[] sourceCells = { new SourceCell(PlanStates.SourceType.ST_TEST),
            new SourceCell(PlanStates.SourceType.ST_RANDOM) };
    chooserSource = new JComboBox(sourceCells);
    chooserSource.setRenderer(new SourceCellRenderer());
    buttonAddToPlan = new JButton();
    panelPlan = new JPanel();
    scrollPane1 = new JScrollPane();
    listPlan = new JList();
    labelCode = new JLabel();
    CodeCell[] codeCells = { new CodeCell(PlanStates.CodeType.CT_NONE),
            new CodeCell(PlanStates.CodeType.CT_HAMMING74), new CodeCell(PlanStates.CodeType.CT_CYCLIC),
            new CodeCell(PlanStates.CodeType.CT_BCH155) };
    chooserCode = new JComboBox(codeCells);
    chooserCode.setRenderer(new CodeCellRenderer());
    labelModulation = new JLabel();
    ModulationCell[] modulationCells = { new ModulationCell(PlanStates.ModulationType.MT_ASK),
            new ModulationCell(PlanStates.ModulationType.MT_FSK),
            new ModulationCell(PlanStates.ModulationType.MT_BPSK),
            new ModulationCell(PlanStates.ModulationType.MT_QPSK),
            new ModulationCell(PlanStates.ModulationType.MT_8PSK),
            new ModulationCell(PlanStates.ModulationType.MT_16PSK),
            new ModulationCell(PlanStates.ModulationType.MT_32PSK),
            new ModulationCell(PlanStates.ModulationType.MT_16QAM),
            new ModulationCell(PlanStates.ModulationType.MT_32QAM),
            new ModulationCell(PlanStates.ModulationType.MT_64QAM),
            new ModulationCell(PlanStates.ModulationType.MT_256QAM) };
    chooserModulation = new JComboBox(modulationCells);
    chooserModulation.setRenderer(new ModulationCellRenderer());
    labelChannel = new JLabel();
    ChannelCell[] channelCells = { new ChannelCell(PlanStates.ChannelType.CHT_AWGN),
            new ChannelCell(PlanStates.ChannelType.CHT_RAYLEIGH) };
    chooserChannel = new JComboBox(channelCells);
    chooserChannel.setRenderer(new ChannelCellRenderer());
    buttonClearPlan = new JButton();
    labelErrors = new JLabel();
    ErrorsCell[] errorCells = { new ErrorsCell(PlanStates.ErrorsType.ET_SER),
            new ErrorsCell(PlanStates.ErrorsType.ET_BER) };
    chooserErrors = new JComboBox(errorCells);
    chooserErrors.setRenderer(new ErrorsCellRenderer());
    labelLineWidth = new JLabel();
    spinnerLineWidth = new JSpinner();
    buttonRemoveFromPlan = new JButton();
    labelLineColor = new JLabel();
    ColorCell[] colorCells = { new ColorCell(null), new ColorCell(Color.black), new ColorCell(Color.red),
            new ColorCell(Color.green), new ColorCell(Color.blue) };
    chooserLineColor = new JComboBox(colorCells);
    chooserLineColor.setRenderer(new ColorCellRenderer());
    labelHSquare = new JLabel();
    spinnerHSquareLow = new JSpinner();
    labelEllipsis = new JLabel();
    spinnerHSquareHigh = new JSpinner();
    panelInner1 = new JPanel();
    labelHSquareStep = new JLabel();
    spinnerHSquareStep = new JSpinner();
    labelMeasurementUnit = new JLabel();
    radioButtonMeasurementUnitTimes = new JRadioButton();
    radioButtonMeasurementUnitdB = new JRadioButton();
    buttonRunSimulation = new JButton();
    labelIterations = new JLabel();
    spinnerIterations = new JSpinner();
    checkBoxShowLineNumbers = new JCheckBox();
    tabbedPaneResults = new JTabbedPane();
    panelChart = new JPanel();
    panelNumeric = new JPanel();
    scrollPane2 = new JScrollPane();
    textAreaNumeric = new JTextArea();
    progressBar = new JProgressBar();

    //======== this ========
    setLayout(new FormLayout("3*(default, $lcgap), 36dlu, $lcgap, 122dlu:grow",
            "[21px,default], 9*($lgap, default), $lgap, default:grow, $lgap, default"));

    //======== menuMain ========
    {/*  w ww.java2s. co m*/

        //======== menuFile ========
        {
            menuFile.setText("\u0424\u0430\u0439\u043b");

            //---- menuItemQuit ----
            menuItemQuit.setText("\u0412\u0438\u0439\u0442\u0438");
            menuItemQuit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, KeyEvent.CTRL_MASK));
            menuItemQuit.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItemQuitActionPerformed(e);
                }
            });
            menuFile.add(menuItemQuit);
        }
        menuMain.add(menuFile);

        //======== menuTools ========
        {
            menuTools.setText("\u0406\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0438");

            //======== menuConstellations ========
            {
                menuConstellations.setText(
                        "\u0421\u0438\u0433\u043d\u0430\u043b\u044c\u043d\u0456 \u0441\u0443\u0437\u0456\u0440\u2019\u044f");

                //---- menuItemASK ----
                menuItemASK.setText("\u0410\u041c\u043d\u2026");
                menuItemASK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItemASKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItemASK);

                //---- menuItemFSK ----
                menuItemFSK.setText("\u0427\u041c\u043d\u2026");
                menuItemFSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItemFSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItemFSK);

                //---- menuItemBPSK ----
                menuItemBPSK.setText("\u0424\u041c\u043d\u2026");
                menuItemBPSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItemBPSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItemBPSK);

                //---- menuItemQPSK ----
                menuItemQPSK.setText("\u0424\u041c-4\u2026");
                menuItemQPSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItemQPSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItemQPSK);

                //---- menuItem8PSK ----
                menuItem8PSK.setText("\u0424\u041c-8\u2026");
                menuItem8PSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem8PSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem8PSK);

                //---- menuItem16PSK ----
                menuItem16PSK.setText("\u0424\u041c-16\u2026");
                menuItem16PSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem16PSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem16PSK);

                //---- menuItem32PSK ----
                menuItem32PSK.setText("\u0424\u041c-32\u2026");
                menuItem32PSK.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem32PSKActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem32PSK);

                //---- menuItem16QAM ----
                menuItem16QAM.setText("\u041a\u0410\u041c-16\u2026");
                menuItem16QAM.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem16QAMActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem16QAM);

                //---- menuItem32QAM ----
                menuItem32QAM.setText("\u041a\u0410\u041c-32\u2026");
                menuItem32QAM.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem32QAMActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem32QAM);

                //---- menuItem64QAM ----
                menuItem64QAM.setText("\u041a\u0410\u041c-64\u2026");
                menuItem64QAM.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem64QAMActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem64QAM);

                //---- menuItem256QAM ----
                menuItem256QAM.setText("\u041a\u0410\u041c-256\u2026");
                menuItem256QAM.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        menuItem256QAMActionPerformed(e);
                    }
                });
                menuConstellations.add(menuItem256QAM);
            }
            menuTools.add(menuConstellations);
        }
        menuMain.add(menuTools);

        //======== menuHelp ========
        {
            menuHelp.setText("\u0414\u043e\u0432\u0456\u0434\u043a\u0430");

            //---- menuItemAbout ----
            menuItemAbout.setText("\u041f\u0440\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u0443\u2026");
            menuItemAbout.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItemAboutActionPerformed(e);
                }
            });
            menuHelp.add(menuItemAbout);
        }
        menuMain.add(menuHelp);
    }
    add(menuMain, CC.xywh(1, 1, 9, 1, CC.FILL, CC.FILL));

    //---- labelSource ----
    labelSource.setText("\u0414\u0436\u0435\u0440\u0435\u043b\u043e:");
    add(labelSource, CC.xy(1, 3));
    add(chooserSource, CC.xy(3, 3));

    //---- buttonAddToPlan ----
    buttonAddToPlan.setText("\u2192");
    buttonAddToPlan.setToolTipText(
            "\u0414\u043e\u0434\u0430\u0442\u0438 \u0434\u043e \u043f\u043b\u0430\u043d\u0443 \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443");
    buttonAddToPlan.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            buttonAddToPlanActionPerformed(e);
        }
    });
    add(buttonAddToPlan, CC.xywh(5, 3, 1, 5));

    //======== panelPlan ========
    {
        panelPlan.setLayout(new GridLayout());

        //======== scrollPane1 ========
        {
            scrollPane1.setViewportView(listPlan);
        }
        panelPlan.add(scrollPane1);
    }
    add(panelPlan, CC.xywh(7, 3, 3, 13));

    //---- labelCode ----
    labelCode.setText("\u041a\u043e\u0434:");
    add(labelCode, CC.xy(1, 5));
    add(chooserCode, CC.xy(3, 5));

    //---- labelModulation ----
    labelModulation.setText("\u041c\u043e\u0434\u0443\u043b\u044f\u0446\u0456\u044f:");
    add(labelModulation, CC.xy(1, 7));
    add(chooserModulation, CC.xy(3, 7));

    //---- labelChannel ----
    labelChannel.setText("\u041a\u0430\u043d\u0430\u043b:");
    add(labelChannel, CC.xy(1, 9));
    add(chooserChannel, CC.xy(3, 9));

    //---- buttonClearPlan ----
    buttonClearPlan.setText("X");
    buttonClearPlan.setToolTipText(
            "\u041e\u0447\u0438\u0441\u0442\u0438\u0442\u0438 \u043f\u043b\u0430\u043d \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443");
    buttonClearPlan.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            buttonClearPlanActionPerformed(e);
        }
    });
    add(buttonClearPlan, CC.xy(5, 9));

    //---- labelErrors ----
    labelErrors.setText("\u041f\u043e\u043c\u0438\u043b\u043a\u0438:");
    add(labelErrors, CC.xy(1, 11));
    add(chooserErrors, CC.xy(3, 11));

    //---- labelLineWidth ----
    labelLineWidth.setText("\u0422\u043e\u0432\u0449\u0438\u043d\u0430 \u043b\u0456\u043d\u0456\u0457:");
    add(labelLineWidth, CC.xy(1, 13));

    //---- spinnerLineWidth ----
    spinnerLineWidth.setModel(new SpinnerNumberModel(2, 1, 5, 1));
    add(spinnerLineWidth, CC.xy(3, 13));

    //---- buttonRemoveFromPlan ----
    buttonRemoveFromPlan.setText("\u2190");
    buttonRemoveFromPlan.setToolTipText(
            "\u0412\u0438\u0434\u0430\u043b\u0438\u0442\u0438 \u0437 \u043f\u043b\u0430\u043d\u0443 \u0435\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0443");
    buttonRemoveFromPlan.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            buttonRemoveFromPlanActionPerformed(e);
        }
    });
    add(buttonRemoveFromPlan, CC.xywh(5, 11, 1, 5));

    //---- labelLineColor ----
    labelLineColor.setText("\u041a\u043e\u043b\u0456\u0440 \u043b\u0456\u043d\u0456\u0457:");
    add(labelLineColor, CC.xy(1, 15));
    add(chooserLineColor, CC.xy(3, 15));

    //---- labelHSquare ----
    labelHSquare.setText("h\u00b2=");
    add(labelHSquare, CC.xy(1, 17));

    //---- spinnerHSquareLow ----
    spinnerHSquareLow.setModel(new SpinnerNumberModel(0.0, null, null, 1.0));
    add(spinnerHSquareLow, CC.xy(3, 17));

    //---- labelEllipsis ----
    labelEllipsis.setText("\u2026");
    add(labelEllipsis, CC.xy(5, 17, CC.CENTER, CC.DEFAULT));

    //---- spinnerHSquareHigh ----
    spinnerHSquareHigh.setModel(new SpinnerNumberModel(15.0, null, null, 1.0));
    add(spinnerHSquareHigh, CC.xy(7, 17));

    //======== panelInner1 ========
    {
        panelInner1.setLayout(new FormLayout("5*(default, $lcgap), default:grow", "default"));

        //---- labelHSquareStep ----
        labelHSquareStep.setText(", \u043a\u0440\u043e\u043a:");
        panelInner1.add(labelHSquareStep, CC.xy(1, 1));

        //---- spinnerHSquareStep ----
        spinnerHSquareStep.setModel(new SpinnerNumberModel(0.5, 0.001, null, 0.1));
        panelInner1.add(spinnerHSquareStep, CC.xy(3, 1));

        //---- labelMeasurementUnit ----
        labelMeasurementUnit.setText(", \u043e\u0434\u0438\u043d\u0438\u0446\u0456:");
        panelInner1.add(labelMeasurementUnit, CC.xy(5, 1));

        //---- radioButtonMeasurementUnitTimes ----
        radioButtonMeasurementUnitTimes.setText("\u0440\u0430\u0437\u0438");
        radioButtonMeasurementUnitTimes.setSelected(true);
        panelInner1.add(radioButtonMeasurementUnitTimes, CC.xy(7, 1, CC.LEFT, CC.DEFAULT));

        //---- radioButtonMeasurementUnitdB ----
        radioButtonMeasurementUnitdB.setText("\u0434\u0411");
        panelInner1.add(radioButtonMeasurementUnitdB, CC.xy(9, 1, CC.LEFT, CC.DEFAULT));

        //---- buttonRunSimulation ----
        buttonRunSimulation.setText("\u0412\u0438\u043a\u043e\u043d\u0430\u0442\u0438");
        buttonRunSimulation.setToolTipText(
                "\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0438 \u043c\u043e\u0434\u0435\u043b\u044e\u0432\u0430\u043d\u043d\u044f");
        buttonRunSimulation.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                buttonRunSimulationActionPerformed(e);
            }
        });
        panelInner1.add(buttonRunSimulation, CC.xy(11, 1, CC.RIGHT, CC.DEFAULT));
    }
    add(panelInner1, CC.xy(9, 17));

    //---- labelIterations ----
    labelIterations.setText("\u0406\u0442\u0435\u0440\u0430\u0446\u0456\u0439:");
    add(labelIterations, CC.xy(1, 19));

    //---- spinnerIterations ----
    spinnerIterations.setModel(new SpinnerNumberModel(200000, 1, null, 50000));
    add(spinnerIterations, CC.xy(3, 19));

    //---- checkBoxShowLineNumbers ----
    checkBoxShowLineNumbers.setText(
            "\u041d\u0443\u043c\u0435\u0440\u0443\u0432\u0430\u0442\u0438 \u0433\u0440\u0430\u0444\u0456\u043a\u0438");
    add(checkBoxShowLineNumbers, CC.xywh(7, 19, 3, 1));

    //======== tabbedPaneResults ========
    {

        //======== panelChart ========
        {
            panelChart.setLayout(new BoxLayout(panelChart, BoxLayout.X_AXIS));
        }
        tabbedPaneResults.addTab("\u0413\u0440\u0430\u0444\u0456\u043a\u0438", panelChart);

        //======== panelNumeric ========
        {
            panelNumeric.setLayout(new FormLayout("default:grow", "default:grow"));

            //======== scrollPane2 ========
            {

                //---- textAreaNumeric ----
                textAreaNumeric.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
                textAreaNumeric.setEditable(false);
                scrollPane2.setViewportView(textAreaNumeric);
            }
            panelNumeric.add(scrollPane2, CC.xy(1, 1, CC.DEFAULT, CC.FILL));
        }
        tabbedPaneResults.addTab("\u0427\u0438\u0441\u043b\u043e\u0432\u0456 \u0434\u0430\u043d\u0456",
                panelNumeric);

    }
    add(tabbedPaneResults, CC.xywh(1, 21, 9, 1, CC.DEFAULT, CC.FILL));
    add(progressBar, CC.xywh(1, 23, 9, 1));

    //---- buttonGroupMeasurementUnit ----
    ButtonGroup buttonGroupMeasurementUnit = new ButtonGroup();
    buttonGroupMeasurementUnit.add(radioButtonMeasurementUnitTimes);
    buttonGroupMeasurementUnit.add(radioButtonMeasurementUnitdB);
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

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

private void initGUI() {
    try {//from  w  ww . j  av  a  2s. c  o m
        JCommonUtil.defaultToolTipDelay();
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                jTabbedPane1.addTab("?schema", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("tableName");
                }
                {
                    tableNameText = new JTextField();
                    jPanel1.add(tableNameText);
                    tableNameText.setPreferredSize(new java.awt.Dimension(155, 22));
                }
                {
                    useDomainJarDefineChkBox = new JCheckBox();
                    jPanel1.add(useDomainJarDefineChkBox);
                    useDomainJarDefineChkBox.setText("\u4ee5dominJar\u70ba\u6e96");
                }
                {
                    dominJarFileText = new JTextField();
                    File currentFile = new File(PropertiesUtil.getJarCurrentPath(getClass()),
                            "sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar");
                    if (currentFile.exists()) {
                        dominJarFileText.setText(currentFile.getAbsolutePath());
                    } else {
                        File cUserFile = new File("C:\\Users");
                        if (cUserFile.exists()) {
                            String domainJarPath = "C:/Users/%s/.m2/repository/tw/gov/sris-db-domain/2.5.0-SRIS-SNAPSHOT/sris-db-domain-2.5.0-SRIS-SNAPSHOT.jar";
                            for (File f : cUserFile.listFiles()) {
                                File jf = new File(String.format(domainJarPath, f.getName()));
                                if (jf.exists()) {
                                    dominJarFileText.setText(jf.getAbsolutePath());
                                    break;
                                }
                            }
                        }
                    }
                    jPanel1.add(dominJarFileText);
                    dominJarFileText.setPreferredSize(new java.awt.Dimension(219, 22));
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(dominJarFileText, false);
                }
                {
                    jLabel5 = new JLabel();
                    jPanel1.add(jLabel5);
                    jLabel5.setText("obnfString");
                    jLabel5.setPreferredSize(new java.awt.Dimension(83, 15));
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel1.add(jScrollPane2);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(544, 76));
                    {
                        obnfArea = new JTextArea();
                        jScrollPane2.setViewportView(obnfArea);
                    }
                }
                {
                    jLabel6 = new JLabel();
                    jPanel1.add(jLabel6);
                    jLabel6.setText("sql");
                    jLabel6.setPreferredSize(new java.awt.Dimension(58, 15));
                }
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel1.add(jScrollPane3);
                    jScrollPane3.setPreferredSize(new java.awt.Dimension(543, 116));
                    {
                        insertSqlArea = new JTextArea();
                        jScrollPane3.setViewportView(insertSqlArea);
                    }
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u8b80\u53d6ObnfString");
                    executeBtn.setPreferredSize(new java.awt.Dimension(146, 29));
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnAction();
                        }
                    });
                }
                {
                    processSqlBtn = new JButton();
                    jPanel1.add(processSqlBtn);
                    processSqlBtn.setText("\u7522\u751fSQL");
                    processSqlBtn.setPreferredSize(new java.awt.Dimension(135, 29));
                    processSqlBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            processSqlBtnAction();
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("?", null, jPanel2, null);
                {
                    jPanel3 = new JPanel();
                    jPanel2.add(jPanel3, BorderLayout.NORTH);
                    jPanel3.setPreferredSize(new java.awt.Dimension(585, 61));
                    {
                        jLabel4 = new JLabel();
                        jPanel3.add(jLabel4);
                        jLabel4.setText("dbField");
                    }
                    {
                        dbFieldText = new JTextField();
                        jPanel3.add(dbFieldText);
                        dbFieldText.setPreferredSize(new java.awt.Dimension(216, 22));
                    }
                    {
                        jLabel3 = new JLabel();
                        jPanel3.add(jLabel3);
                        jLabel3.setText("value");
                    }
                    {
                        dbValue = new JTextField();
                        jPanel3.add(dbValue);
                        dbValue.setPreferredSize(new java.awt.Dimension(244, 22));
                    }
                    {
                        pkCheckBox = new JCheckBox();
                        jPanel3.add(pkCheckBox);
                        pkCheckBox.setText("\u662fPK");
                    }
                    {
                        addFieldBtn = new JButton();
                        jPanel3.add(addFieldBtn);
                        addFieldBtn.setText("saveOrUpdate");
                        addFieldBtn.setPreferredSize(new java.awt.Dimension(116, 22));
                        addFieldBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                addFieldBtnAction();
                            }
                        });
                    }
                    {
                        deleteFieldBtn = new JButton();
                        jPanel3.add(deleteFieldBtn);
                        deleteFieldBtn.setText("delete");
                        deleteFieldBtn.setPreferredSize(new java.awt.Dimension(88, 22));
                        deleteFieldBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                deleteFieldBtnAction();
                            }
                        });
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(585, 258));
                    {
                        DefaultListModel dbFieldListModel = new DefaultListModel();
                        dbFieldList = new JList();
                        jScrollPane1.setViewportView(dbFieldList);
                        dbFieldList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                dbFieldListMousePreformd(evt);
                            }
                        });
                        dbFieldList.setModel(dbFieldListModel);
                        dbFieldList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(dbFieldList).defaultJListKeyPressed(evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                GridLayout jPanel4Layout = new GridLayout(1, 1);
                jPanel4Layout.setColumns(1);
                jPanel4Layout.setHgap(5);
                jPanel4Layout.setVgap(5);
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("?", null, jPanel4, null);
                {
                    manualDefineArea = new JTextArea();
                    jPanel4.add(manualDefineArea);
                    manualDefineArea.setText("");
                    manualDefineArea.setToolTipText("?");
                }
                {
                    manualDefinePkArea = new JTextArea();
                    jPanel4.add(manualDefinePkArea);
                    manualDefinePkArea.setText("");
                    manualDefinePkArea.setToolTipText("PK?");
                }
                {
                    manualDefineDbFieldBtn = new JButton();
                    jPanel4.add(manualDefineDbFieldBtn);
                    manualDefineDbFieldBtn
                            .setText("\u4ee5\u8cbc\u5165\u6b04\u4f4d\u5b9a\u7fa9\u6c7a\u5b9a\u6b04\u4f4d");
                    manualDefineDbFieldBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            manualDefineDbFieldBtnAction();
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(598, 366);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

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

private void initGUI() {
    try {//from ww  w .ja va 2 s . c  o m
        {
        }
        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("source", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        replaceArea = new JTextArea();
                        jScrollPane1.setViewportView(replaceArea);
                        replaceArea.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JPopupMenuUtil.newInstance(replaceArea).applyEvent(evt)
                                        .addJMenuItem("load from file", true, new ActionListener() {

                                            Thread newThread;

                                            public void actionPerformed(ActionEvent arg0) {
                                                if (newThread != null
                                                        && newThread.getState() != Thread.State.TERMINATED) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is loading!");
                                                    return;
                                                }

                                                final File file = JCommonUtil._jFileChooser_selectFileOnly();
                                                if (file == null) {
                                                    JCommonUtil._jOptionPane_showMessageDialog_error(
                                                            "file is not correct!");
                                                    return;
                                                }
                                                String defaultCharset = Charset.defaultCharset().displayName();
                                                String chst = (String) JCommonUtil._jOptionPane_showInputDialog(
                                                        "input your charset!", defaultCharset);
                                                final Charset charset2 = Charset.forName(
                                                        StringUtils.defaultIfEmpty(chst, defaultCharset));

                                                newThread = new Thread(Thread.currentThread().getThreadGroup(),
                                                        new Runnable() {
                                                            public void run() {
                                                                try {
                                                                    loadFromFileSb = new StringBuilder();
                                                                    BufferedReader reader = new BufferedReader(
                                                                            new InputStreamReader(
                                                                                    new FileInputStream(file),
                                                                                    charset2));
                                                                    for (String line = null; (line = reader
                                                                            .readLine()) != null;) {
                                                                        loadFromFileSb.append(line + "\n");
                                                                    }
                                                                    reader.close();
                                                                    replaceArea
                                                                            .setText(loadFromFileSb.toString());
                                                                    JCommonUtil
                                                                            ._jOptionPane_showMessageDialog_info(
                                                                                    "load completed!");
                                                                } catch (Exception e) {
                                                                    JCommonUtil.handleException(e);
                                                                }
                                                            }
                                                        }, "" + System.currentTimeMillis());
                                                newThread.setDaemon(true);
                                                newThread.start();
                                            }
                                        }).show();
                            }
                        });
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("param", null, jPanel2, null);
                {
                    exeucte = new JButton();
                    jPanel2.add(exeucte, BorderLayout.SOUTH);
                    exeucte.setText("exeucte");
                    exeucte.setPreferredSize(new java.awt.Dimension(491, 125));
                    exeucte.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            exeucteActionPerformed(evt);
                        }
                    });
                }
                {
                    jPanel3 = new JPanel();
                    GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                    jPanel3.setLayout(jPanel3Layout);
                    jPanel2.add(jPanel3, BorderLayout.CENTER);
                    {
                        repFromText = new JTextField();
                    }
                    {
                        repToText = new JTextField();
                    }
                    jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup()
                            .addContainerGap(25, 25)
                            .addGroup(jPanel3Layout.createParallelGroup()
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText,
                                            GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)))
                            .addContainerGap(20, Short.MAX_VALUE));
                    jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap()
                            .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
                }
                {
                    addToTemplate = new JButton();
                    jPanel2.add(addToTemplate, BorderLayout.NORTH);
                    addToTemplate.setText("add to template");
                    addToTemplate.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            prop.put(repFromText.getText(), repToText.getText());
                            reloadTemplateList();
                        }
                    });
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("result", null, jPanel4, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel4.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(491, 283));
                    {
                        DefaultTableModel resultAreaModel = JTableUtil.createModel(true, "match", "count");
                        resultArea = new JTable();
                        jScrollPane2.setViewportView(resultArea);
                        JTableUtil.defaultSetting(resultArea);
                        resultArea.setModel(resultAreaModel);
                    }
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jPanel5.setLayout(jPanel5Layout);
                jTabbedPane1.addTab("template", null, jPanel5, null);
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel5.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        templateList = new JList();
                        jScrollPane3.setViewportView(templateList);
                        reloadTemplateList();
                    }
                    templateList.addMouseListener(new MouseAdapter() {
                        public void mouseClicked(MouseEvent evt) {
                            if (templateList.getLeadSelectionIndex() == -1) {
                                return;
                            }
                            Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil
                                    .getLeadSelectionObject(templateList);
                            repFromText.setText((String) entry.getKey());
                            repToText.setText((String) entry.getValue());
                        }
                    });
                    templateList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(templateList).defaultJListKeyPressed(evt);
                        }
                    });
                }
            }
            {
                jPanel6 = new JPanel();
                FlowLayout jPanel6Layout = new FlowLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("result1", null, jPanel6, null);
                {
                    resultBtn1 = new JButton();
                    jPanel6.add(resultBtn1);
                    resultBtn1.setText("to String[]");
                    resultBtn1.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            JTableUtil tableUtil = JTableUtil.newInstance(resultArea);
                            int[] rowPoss = tableUtil.getSelectedRows();
                            DefaultTableModel model = tableUtil.getModel();
                            List<Object> valueList = new ArrayList<Object>();
                            for (int ii = 0; ii < rowPoss.length; ii++) {
                                valueList.add(model.getValueAt(rowPoss[ii], 0));
                            }
                            String reult = valueList.toString().replaceAll("[\\s]", "")
                                    .replaceAll("[\\,]", "\",\"").replaceAll("[\\[\\]]", "\"");
                            ClipboardUtil.getInstance().setContents(reult);
                        }
                    });
                }
                {
                    resultBtn2 = new JButton();
                    jPanel6.add(resultBtn2);
                    resultBtn2.setText("TODO");
                    resultBtn2.setPreferredSize(new java.awt.Dimension(105, 32));
                    resultBtn2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("resultBtn1.actionPerformed, event=" + evt);
                            //TODO add your code for resultBtn1.actionPerformed
                            JCommonUtil._jOptionPane_showMessageDialog_info("TODO");
                        }
                    });
                }
            }
        }
        this.setSize(512, 350);
        JCommonUtil.setFont(repToText, repFromText, replaceArea, templateList);

        JCommonUtil.frameCloseDo(this, new WindowAdapter() {
            public void windowClosing(WindowEvent paramWindowEvent) {
                if (StringUtils.isNotBlank(repFromText.getText())) {
                    prop.put(repFromText.getText(), repToText.getText());
                }
                try {
                    prop.store(new FileOutputStream(propFile), "regexText");
                } catch (Exception e) {
                    JCommonUtil.handleException("properties store error!", e);
                }
                setVisible(false);
                dispose();
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:mendeley2kindle.MainUIFrame.java

public MainUIFrame(Properties config, Mendeley2Kindle core) {
    super("Mendeley2Kindle");
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    this.core = core;
    core.addStateListener(new UISyncStateListener());

    components = new ArrayList<JComponent>();

    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("File");
    JMenuItem openMenuItem = new JMenuItem("Open Mendeley database");
    openMenuItem.addActionListener(new OpenMendeleyListener());
    JMenuItem selectKindleMenuItem = new JMenuItem("Select Kindle device path");
    selectKindleMenuItem.addActionListener(new SelectKindleListener());
    JMenuItem exitMenuItem = new JMenuItem("Quit");
    exitMenuItem.addActionListener(new QuitListener());
    fileMenu.add(openMenuItem);//from w ww .  j a v  a 2s .c o m
    fileMenu.add(selectKindleMenuItem);
    fileMenu.add(exitMenuItem);
    menuBar.add(fileMenu);

    JMenu helpMenu = new JMenu("Help");
    JMenuItem aboutMenuItem = new JMenuItem("About");
    aboutMenuItem.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String text = "Mendeley2Kindle 0.3.2\n"
                    + " (c) Copyright Yukinari Toyota, 2013. All rights reserved.\n"
                    + " Contact: Yukinari Toyota <xxseyxx@gmail.com>\n"
                    + " Site: http://sites.google.com/site/xxseyxx/\n" + "Some Icons by Yusuke Kamiyamane\n"
                    + " Site: http://p.yusukekamiyamane.com/\n"
                    + "sqlite-jdbc-3.7.2.jar is provided by xerial.org\n"
                    + " under Apache License version 2.0 (http://www.apache.org/licenses/ )\n"
                    + " Site: https://bitbucket.org/xerial/sqlite-jdbc\n";
            JOptionPane.showMessageDialog(MainUIFrame.this, text);
        }
    });
    helpMenu.add(aboutMenuItem);
    menuBar.add(helpMenu);

    setJMenuBar(menuBar);

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

    getContentPane().add(new JLabel("Select Mendeley collections"));

    collectionsJList = new JList();
    DragSelectionListener mil = new DragSelectionListener();
    collectionsJList.addMouseMotionListener(mil);
    collectionsJList.addMouseListener(mil);
    collectionsJList.setCellRenderer(new MyCellRenderer());
    // collectionsJList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

    JScrollPane scroll = new JScrollPane();
    scroll.setPreferredSize(new Dimension(200, 300));
    scroll.getViewport().setView(collectionsJList);
    getContentPane().add(scroll);

    mainButton = new JButton("Open Mendeley database");
    mainButton.addActionListener(new OpenMendeleyListener());
    getContentPane().add(mainButton);

    components.add(collectionsJList);

    for (JComponent c : components)
        c.setEnabled(false);

    pack();
}