Example usage for javax.swing JTextPane JTextPane

List of usage examples for javax.swing JTextPane JTextPane

Introduction

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

Prototype

public JTextPane() 

Source Link

Document

Creates a new JTextPane.

Usage

From source file:com.evanbelcher.DrillBook.display.DBMenuBar.java

/**
 * Displays help window//  w w w  .j a  v  a  2  s  .c  o  m
 */
private void help() {
    String msg = "";

    MutableDataSet options = new MutableDataSet();
    Parser parser = Parser.builder(options).build();
    HtmlRenderer renderer = HtmlRenderer.builder(options).build();

    try {
        msg = IOUtils.toString(Main.getFile("Usage.md", this));
        Node document = parser.parse(msg);
        msg = renderer.render(document);
    } catch (IOException e) {
        e.printStackTrace();
    }

    JTextPane area = new JTextPane();
    area.setContentType("text/html");
    area.setText(msg);
    area.setCaretPosition(0);
    area.setEditable(false);

    JScrollPane scrollPane = new JScrollPane(area);
    scrollPane
            .setMaximumSize(new Dimension(GraphicsRunner.SCREEN_SIZE.width, GraphicsRunner.SCREEN_SIZE.height));
    scrollPane.setPreferredSize(
            new Dimension(GraphicsRunner.SCREEN_SIZE.width - 10, GraphicsRunner.SCREEN_SIZE.height - 10));
    scrollPane.scrollRectToVisible(new Rectangle());
    JOptionPane.showMessageDialog(this, scrollPane, "Help", JOptionPane.PLAIN_MESSAGE);
}

From source file:net.sf.jabref.gui.mergeentries.MergeEntries.java

private JTextPane getStyledTextPane() {
    JTextPane pane = new JTextPane();
    pane.setContentType(CONTENT_TYPE);//from  w  ww.  j  a v a  2  s . c o m
    StyleSheet sheet = ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet();
    sheet.addRule(BODY_STYLE);
    sheet.addRule(ADDITION_STYLE);
    sheet.addRule(REMOVAL_STYLE);
    sheet.addRule(CHANGE_STYLE);
    pane.setEditable(false);
    return pane;
}

From source file:de.codesourcery.jasm16.utils.ASTInspector.java

private void setupUI() throws MalformedURLException {
    // editor pane
    editorPane = new JTextPane();
    editorScrollPane = new JScrollPane(editorPane);
    editorPane.addCaretListener(listener);

    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 600));
    editorScrollPane.setMinimumSize(new Dimension(100, 100));

    final AdjustmentListener adjustmentListener = new AdjustmentListener() {

        @Override//from ww w. ja v a  2s  . c om
        public void adjustmentValueChanged(AdjustmentEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (currentUnit != null) {
                    doSemanticHighlighting(currentUnit);
                }
            }
        }
    };
    editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener);
    editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener);

    // button panel
    final JPanel topPanel = new JPanel();

    final JToolBar toolbar = new JToolBar();
    final JButton showASTButton = new JButton("Show AST");
    showASTButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false;
            if (currentlyVisible) {
                showASTButton.setText("Show AST");
            } else {
                showASTButton.setText("Hide AST");
            }
            if (currentlyVisible) {
                astInspector.setVisible(false);
            } else {
                showASTInspector();
            }

        }
    });

    fileChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) {
                chooser = new JFileChooser(lastOpenDirectory);
            } else {
                lastOpenDirectory = null;
                chooser = new JFileChooser();
            }

            final FileFilter filter = new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.isDirectory()) {
                        return true;
                    }
                    return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm")
                            || f.getName().endsWith(".dasm16"));
                }

                @Override
                public String getDescription() {
                    return "DCPU-16 assembler sources";
                }
            };
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(frame);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File newFile = chooser.getSelectedFile();
                if (newFile.isFile()) {
                    lastOpenDirectory = newFile.getParentFile();
                    try {
                        openFile(newFile);
                    } catch (IOException e1) {
                        statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1);
                    }
                }
            }
        }
    });
    toolbar.add(fileChooser);
    toolbar.add(showASTButton);

    final ComboBoxModel<String> model = new ComboBoxModel<String>() {

        private ICompilerPhase selected;

        private final List<String> realModel = new ArrayList<String>();

        {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                realModel.add(p.getName());
                if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) {
                    selected = p;
                }
            }
        }

        @Override
        public Object getSelectedItem() {
            return selected != null ? selected.getName() : null;
        }

        private ICompilerPhase getPhaseByName(String name) {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.getName().equals(name)) {
                    return p;
                }
            }
            return null;
        }

        @Override
        public void setSelectedItem(Object name) {
            selected = getPhaseByName((String) name);
        }

        @Override
        public void addListDataListener(ListDataListener l) {
        }

        @Override
        public String getElementAt(int index) {
            return realModel.get(index);
        }

        @Override
        public int getSize() {
            return realModel.size();
        }

        @Override
        public void removeListDataListener(ListDataListener l) {
        }

    };
    comboBox.setModel(model);
    comboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (model.getSelectedItem() != null) {
                ICompilerPhase oldPhase = findDisabledPhase();
                if (oldPhase != null) {
                    oldPhase.setStopAfterExecution(false);
                }
                compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true);
                try {
                    compile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }

        private ICompilerPhase findDisabledPhase() {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.isStopAfterExecution()) {
                    return p;
                }
            }
            return null;
        }
    });

    toolbar.add(new JLabel("Stop compilation after: "));
    toolbar.add(comboBox);

    cursorPosition.setSize(new Dimension(400, 15));
    cursorPosition.setEditable(false);

    statusArea.setPreferredSize(new Dimension(400, 100));
    statusArea.setModel(statusModel);

    /**
     * TOOLBAR
     * SOURCE
     * cursor position
     * status area 
     */
    topPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(toolbar, cnstrs);

    cnstrs = constraints(0, 1, GridBagConstraints.BOTH);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    topPanel.add(editorScrollPane, cnstrs);

    cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(cursorPosition, cnstrs);

    cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;

    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());

    statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    statusArea.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final int row = statusArea.rowAtPoint(e.getPoint());
                StatusMessage message = statusModel.getMessage(row);
                if (message.getLocation() != null) {
                    moveCursorTo(message.getLocation());
                }
            }
        };
    });

    statusArea.setFillsViewportHeight(true);
    statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    final JScrollPane statusPane = new JScrollPane(statusArea);
    statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    statusPane.setPreferredSize(new Dimension(400, 100));
    statusPane.setMinimumSize(new Dimension(100, 20));

    cnstrs = constraints(0, 0, GridBagConstraints.BOTH);
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;

    bottomPanel.add(statusPane, cnstrs);

    // setup frame
    frame = new JFrame(
            "DCPU-16 assembler " + Compiler.VERSION + "   (c) 2012 by tobias.gierke@code-sourcery.de");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
    splitPane.setBackground(Color.WHITE);
    frame.getContentPane().add(splitPane);

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

    splitPane.setDividerLocation(0.9);
}

From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java

/**
 * Gets the application log./*from www  .j  a va  2  s  .  com*/
 * 
 * @param panelLog The panel of the log.
 * @return The application log.
 */
private JTextPane getTxtLog(JPanel panelLog) {
    JTextPane textPaneLog = new JTextPane();
    textPaneLog.setBounds(4, 4, 209, 195);
    textPaneLog.setEditable(false);
    panelLog.add(textPaneLog);
    textPaneLog.setContentType("text/html");
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    panelLog_1.setLayout(null);
    textPaneLog.setEditorKit(kit);
    textPaneLog.setDocument(doc);

    textPaneLog.setText("<!DOCTYPE html>" + "<html>" + "<head>" + "<style>" + "p.normal {font-weight:normal;}"
            + "p.error {font-weight:bold; color:red}" + "p.exito {font-weight:bold; color:green}"
            + "p.stop {font-weight:bold; color:blue}" + "</style>" + "</head>" + "<body>");
    JScrollPane scroll = new JScrollPane(textPaneLog);
    scroll.setBounds(10, 16, 242, 254);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    panelLog.add(scroll);
    return textPaneLog;
}

From source file:de.ailis.xadrian.components.ComplexEditor.java

/**
 * Prints the complex data/*from w w w  . j  ava 2s .c  o m*/
 */
public void print() {
    // Prepare model
    final Map<String, Object> model = new HashMap<String, Object>();
    model.put("complex", this.complex);
    model.put("print", true);
    model.put("config", Config.getInstance());

    // Generate content
    final String content = TemplateFactory.processTemplate(template, model);

    // Put content into a text pane component
    final JTextPane printPane = new JTextPane();
    printPane.setContentType("text/html");
    ((HTMLDocument) printPane.getDocument()).setBase(Main.class.getResource("templates/"));
    printPane.setText(content);

    // Print the text pane
    try {
        printPane.print(null, null, true, null, Config.getInstance().getPrintAttributes(), true);
    } catch (final PrinterException e) {
        JOptionPane.showMessageDialog(null, I18N.getString("error.cantPrint"), I18N.getString("error.title"),
                JOptionPane.ERROR_MESSAGE);
        log.error("Unable to print complex: " + e, e);
    }
}

From source file:com.github.benchdoos.weblocopener.weblocOpener.gui.EditDialog.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*  w  w w. j  a  v a 2 s  .  co  m*/
 */
private void $$$setupUI$$$() {
    contentPane = new JPanel();
    contentPane.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 10, 0), -1, -1));
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridLayoutManager(1, 2, new Insets(0, 10, 10, 10), -1, -1));
    contentPane.add(panel1,
            new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, 1, null, null,
                    null, 0, false));
    final Spacer spacer1 = new Spacer();
    panel1.add(spacer1,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
    final JPanel panel2 = new JPanel();
    panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1, true, false));
    panel1.add(panel2,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    buttonOK = new JButton();
    this.$$$loadButtonText$$$(buttonOK,
            ResourceBundle.getBundle("translations/EditDialogBundle").getString("buttonOk"));
    buttonOK.putClientProperty("hideActionText", Boolean.FALSE);
    panel2.add(buttonOK,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    buttonCancel = new JButton();
    this.$$$loadButtonText$$$(buttonCancel,
            ResourceBundle.getBundle("translations/EditDialogBundle").getString("buttonCancel"));
    panel2.add(buttonCancel,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    final JPanel panel3 = new JPanel();
    panel3.setLayout(new GridLayoutManager(2, 3, new Insets(5, 10, 0, 10), -1, -1));
    contentPane.add(panel3,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    final Spacer spacer2 = new Spacer();
    panel3.add(spacer2,
            new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1,
                    GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
    createWeblocFileTextPane = new JLabel();
    createWeblocFileTextPane.setAutoscrolls(true);
    createWeblocFileTextPane.setEnabled(true);
    createWeblocFileTextPane.setFocusable(false);
    Font createWeblocFileTextPaneFont = this.$$$getFont$$$("Open Sans", Font.BOLD, 14,
            createWeblocFileTextPane.getFont());
    if (createWeblocFileTextPaneFont != null)
        createWeblocFileTextPane.setFont(createWeblocFileTextPaneFont);
    createWeblocFileTextPane.setOpaque(false);
    createWeblocFileTextPane.setRequestFocusEnabled(true);
    this.$$$loadLabelText$$$(createWeblocFileTextPane,
            ResourceBundle.getBundle("translations/EditDialogBundle").getString("EditWeblocLink"));
    createWeblocFileTextPane.setVerifyInputWhenFocusTarget(false);
    createWeblocFileTextPane.setVisible(true);
    panel3.add(createWeblocFileTextPane,
            new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_VERTICAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, null,
                    null, 0, false));
    final JPanel panel4 = new JPanel();
    panel4.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
    panel3.add(panel4,
            new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_NORTH, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    urlLabel = new JLabel();
    Font urlLabelFont = this.$$$getFont$$$("Open Sans", Font.BOLD, 14, urlLabel.getFont());
    if (urlLabelFont != null)
        urlLabel.setFont(urlLabelFont);
    this.$$$loadLabelText$$$(urlLabel,
            ResourceBundle.getBundle("translations/EditDialogBundle").getString("urlLabelText"));
    panel4.add(urlLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
            GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
    textField = new JTextField();
    Font textFieldFont = this.$$$getFont$$$("Open Sans", -1, 12, textField.getFont());
    if (textFieldFont != null)
        textField.setFont(textFieldFont);
    textField.setText("");
    panel4.add(textField,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL,
                    GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null,
                    new Dimension(150, -1), null, 1, false));
    iconLabel = new JLabel();
    iconLabel.setIcon(new ImageIcon(getClass().getResource("/images/icon96.png")));
    iconLabel.setText("");
    panel3.add(iconLabel,
            new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE,
                    GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0,
                    false));
    errorPanel = new JPanel();
    errorPanel.setLayout(new BorderLayout(0, 0));
    errorPanel.setBackground(new Color(-65536));
    errorPanel.setVisible(false);
    contentPane.add(errorPanel,
            new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
                    GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null,
                    null, 0, false));
    errorTextPane = new JTextPane();
    errorTextPane.setEditable(false);
    errorTextPane.setFocusCycleRoot(false);
    errorTextPane.setFocusable(false);
    Font errorTextPaneFont = this.$$$getFont$$$("Segoe UI", Font.BOLD, 14, errorTextPane.getFont());
    if (errorTextPaneFont != null)
        errorTextPane.setFont(errorTextPaneFont);
    errorTextPane.setForeground(new Color(-1));
    errorTextPane.setOpaque(false);
    errorTextPane.setRequestFocusEnabled(false);
    errorTextPane.setText("Error");
    errorTextPane.setVerifyInputWhenFocusTarget(true);
    errorPanel.add(errorTextPane, BorderLayout.NORTH);
    urlLabel.setLabelFor(textField);
    iconLabel.setLabelFor(createWeblocFileTextPane);
}

From source file:com.mirth.connect.client.ui.SettingsPanelResources.java

private void initComponents() {
    setLayout(new MigLayout("insets 12, novisualpadding, hidemode 3, fill"));
    setBackground(UIConstants.BACKGROUND_COLOR);

    JPanel resourceListPanel = new JPanel(new MigLayout("insets 0, novisualpadding, hidemode 3, fill"));
    resourceListPanel.setBackground(getBackground());
    resourceListPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Resources",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));

    resourceTable = new MirthTable();
    resourceTable.setModel(//from ww w  .j  av a2s.  c om
            new RefreshTableModel(new Object[] { "Properties", "Name", "Type", "Global Scripts" }, 0) {
                @Override
                public boolean isCellEditable(int row, int column) {
                    if (row == 0) {
                        return column == GLOBAL_SCRIPTS_COLUMN;
                    } else {
                        return column == NAME_COLUMN || column == TYPE_COLUMN
                                || column == GLOBAL_SCRIPTS_COLUMN;
                    }
                }
            });
    resourceTable.setDragEnabled(false);
    resourceTable.setRowSelectionAllowed(true);
    resourceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    resourceTable.setRowHeight(UIConstants.ROW_HEIGHT);
    resourceTable.setFocusable(true);
    resourceTable.setOpaque(true);
    resourceTable.getTableHeader().setReorderingAllowed(false);
    resourceTable.setEditable(true);
    resourceTable.setSortable(false);

    if (Preferences.userNodeForPackage(Mirth.class).getBoolean("highlightRows", true)) {
        resourceTable.setHighlighters(HighlighterFactory.createAlternateStriping(UIConstants.HIGHLIGHTER_COLOR,
                UIConstants.BACKGROUND_COLOR));
    }

    for (ResourceClientPlugin plugin : LoadedExtensions.getInstance().getResourceClientPlugins().values()) {
        propertiesPanelMap.put(plugin.getType(), plugin.getPropertiesPanel());
    }

    resourceTable.getColumnModel().getColumn(NAME_COLUMN).setCellEditor(new NameEditor());
    resourceTable.getColumnExt(NAME_COLUMN).setToolTipText("The unique name of the resource.");

    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMinWidth(100);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setMaxWidth(200);
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN)
            .setCellRenderer(new ComboBoxRenderer(propertiesPanelMap.keySet().toArray()));
    resourceTable.getColumnModel().getColumn(TYPE_COLUMN).setCellEditor(new ComboBoxEditor(resourceTable,
            propertiesPanelMap.keySet().toArray(), 1, true, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent evt) {
                    typeComboBoxActionPerformed(evt);
                }
            }));
    resourceTable.getColumnExt(TYPE_COLUMN).setToolTipText("The type of resource.");

    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setMinWidth(80);
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setMaxWidth(80);
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setCellRenderer(new CheckBoxRenderer());
    resourceTable.getColumnModel().getColumn(GLOBAL_SCRIPTS_COLUMN).setCellEditor(new CheckBoxEditor());
    resourceTable.getColumnExt(GLOBAL_SCRIPTS_COLUMN).setToolTipText(
            "<html>If checked, libraries associated with the corresponding<br/>resource will be included in global script contexts.</html>");

    resourceTable.removeColumn(resourceTable.getColumnModel().getColumn(PROPERTIES_COLUMN));

    resourceTable.getSelectionModel().addListSelectionListener(this);

    resourceTable
            .setToolTipText("<html>Add or remove resources to use<br/>in specific channels/connectors.</html>");

    resourceTable.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
            .put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "selectNextColumnCell");

    resourceListPanel.add(new JScrollPane(resourceTable), "grow, push");

    add(resourceListPanel, "grow, h 20%");

    for (ResourcePropertiesPanel panel : propertiesPanelMap.values()) {
        add(panel, "newline, grow, h 80%");
    }

    fillerPanel = new JPanel(new MigLayout("insets 5, novisualpadding, hidemode 3, fill", "", "[][grow]"));
    fillerPanel.setBackground(getBackground());
    fillerPanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(204, 204, 204)), "Resource Settings",
            TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 1, 11)));
    fillerLabel = new JLabel("Select a resource from the table above.");
    fillerPanel.add(fillerLabel);

    exceptionTextPane = new JTextPane();
    exceptionTextPane.setBackground(new Color(224, 223, 227));
    exceptionTextPane.setEditable(false);
    exceptionScrollPane = new JScrollPane(exceptionTextPane);
    fillerPanel.add(exceptionScrollPane, "newline, grow");

    add(fillerPanel, "newline, grow, h 80%");
}

From source file:edu.ucla.stat.SOCR.chart.Chart.java

/**This method initializes the Gui, by setting up the basic tabbedPanes.*/
public void init() {

    depMax = 1;//from ww w  .  j  av  a  2  s.c  o m
    indMax = 1;
    chartTitle = this.getClass().getName();
    chartTitle = chartTitle.substring(chartTitle.lastIndexOf(".") + 1);
    String fileName = "demo" + System.getProperty("file.separator") + chartTitle + ".html";

    url = Chart.class.getResource(fileName);

    setName(chartTitle);

    //Get frame of the applet
    //frame = getFrame(this.getContentPane());

    // Create the toolBar
    toolBar = new JToolBar();
    createActionComponents(toolBar);
    this.getContentPane().add(toolBar, BorderLayout.NORTH);

    tabbedPanelContainer = new JTabbedPane();

    dataObject = new Object[rowNumber][columnNumber];
    columnNames = new String[columnNumber];
    independentList = new ArrayList<Integer>();
    dependentList = new ArrayList<Integer>();
    for (int i = 0; i < columnNumber; i++)
        columnNames[i] = new String(DEFAULT_HEADER + (i + 1));

    initTable();
    initGraphPanel();
    initMapPanel();
    initMixPanel();
    mixPanelContainer = new JScrollPane(mixPanel);
    mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100));

    addTabbedPane(GRAPH, graphPanel);
    addTabbedPane(DATA, dataPanel);
    addTabbedPane(MAPPING, bPanel);
    addTabbedPane(ALL, mixPanelContainer);

    tabbedPanelContainer.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) {
                mixPanel.removeAll();
                setMixPanel();
                mixPanel.validate();
            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) {
                graphPanel.removeAll();
                //setGraphPanel();
                //graphPanel.validate();
                setChart();

            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == DATA) {
                //               
                setTablePane();
            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == MAPPING) {
                bPanel.removeAll();
                mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y));
                bPanel.add(mapPanel, BorderLayout.CENTER);
                bPanel.validate();
            }
        }
    });
    bPanel.addComponentListener(new ComponentListener() {
        public void componentResized(ComponentEvent e) {
        }

        public void componentMoved(ComponentEvent e) {
        }

        public void componentShown(ComponentEvent e) {
            // resultPanelTextArea.append("sucess");
            // System.out.print("Success");
            // Add code here for updating the Panel to show proper heading
            paintMappingLists(listIndex);
        }

        public void componentHidden(ComponentEvent e) {
        }

    });

    // the right side (including top and bottom panels)
    statusTextArea = new JTextPane(); //right side lower
    statusTextArea.setEditable(false);
    JScrollPane statusContainer = new JScrollPane(statusTextArea);
    statusContainer.setPreferredSize(new Dimension(600, 140));

    if (SHOW_STATUS_TEXTAREA) {
        JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(tabbedPanelContainer),
                statusContainer);
        container.setContinuousLayout(true);
        container.setDividerLocation(0.6);
        this.getContentPane().add(container, BorderLayout.CENTER);
    } else {

        this.getContentPane().add(new JScrollPane(tabbedPanelContainer), BorderLayout.CENTER);
    }

    updateStatus(url);
}

From source file:multiplayer.pong.client.LobbyFrame.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*  w  w  w  .  j a  v  a 2s. c o m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jScrollPane2 = new javax.swing.JScrollPane();
    jScrollPane2.setBackground(Color.WHITE);
    usernamesT = new javax.swing.JTable();
    usernamesT.setBackground(Color.WHITE);

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setBackground(new java.awt.Color(0, 0, 0));

    usernamesT.setModel(new javax.swing.table.DefaultTableModel(
            new Object[][] { { null }, { null }, { null }, { null } }, new String[] { "Username" }) {
        boolean[] canEdit = new boolean[] { false };

        public boolean isCellEditable(int rowIndex, int columnIndex) {
            return canEdit[columnIndex];
        }
    });
    usernamesT.setGridColor(new java.awt.Color(0, 0, 0));
    usernamesT.setInheritsPopupMenu(true);
    jScrollPane2.setViewportView(usernamesT);
    if (usernamesT.getColumnModel().getColumnCount() > 0) {
        usernamesT.getColumnModel().getColumn(0).setResizable(false);
    }

    JLabel lblUtilisateursEnligne = new JLabel("Utilisateurs en-ligne");
    lblUtilisateursEnligne.setForeground(new Color(255, 255, 255));
    lblUtilisateursEnligne.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));

    commandBtn = new JButton("Envoyer");
    commandBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            commandBtnActionPerformed(e);
        }
    });

    JLabel lblLobbyPrincipal = new JLabel("Lobby Principal");
    lblLobbyPrincipal.setFont(new Font("Georgia", Font.PLAIN, 70));
    lblLobbyPrincipal.setForeground(new Color(255, 255, 255));
    lblLobbyPrincipal.setBackground(new Color(0, 0, 0));

    scrollPane = new JScrollPane();
    scrollPane.setBackground(Color.WHITE);

    cmdPrompt = new JTextField();
    cmdPrompt.setColumns(10);
    cmdPrompt.grabFocus();

    scrollPane_1 = new JScrollPane();

    lblWelcome = new JLabel("Bienvenue, " + SocketHandler.username);
    lblWelcome.setHorizontalAlignment(SwingConstants.RIGHT);
    lblWelcome.setFont(new Font("Georgia", Font.PLAIN, 18));
    lblWelcome.setForeground(Color.WHITE);

    JLabel label = new JLabel("Amis connect\u00E9s");
    label.setForeground(Color.WHITE);
    label.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(Alignment.LEADING)
                                    .addComponent(scrollPane_1, GroupLayout.PREFERRED_SIZE, 605,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cmdPrompt, 605, 605, 605))
                            .addPreferredGap(ComponentPlacement.RELATED))
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(lblLobbyPrincipal, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE)
                            .addGap(120)))
            .addGroup(layout.createParallelGroup(Alignment.TRAILING)
                    .addComponent(lblUtilisateursEnligne, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169,
                            Short.MAX_VALUE)
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 160,
                                            GroupLayout.PREFERRED_SIZE))
                    .addComponent(commandBtn, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(label, GroupLayout.PREFERRED_SIZE, 169, GroupLayout.PREFERRED_SIZE))
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING,
                            layout.createSequentialGroup().addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(Alignment.TRAILING).addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblLobbyPrincipal, GroupLayout.PREFERRED_SIZE, 85,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(lblWelcome, GroupLayout.PREFERRED_SIZE, 31,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(18)
                    .addGroup(layout.createParallelGroup(Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 164,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(lblUtilisateursEnligne, GroupLayout.PREFERRED_SIZE, 24,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(ComponentPlacement.RELATED)
                                    .addComponent(jScrollPane2, GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
                            .addComponent(scrollPane_1, GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE))
                    .addGap(9)
                    .addGroup(
                            layout.createParallelGroup(Alignment.BASELINE)
                                    .addComponent(cmdPrompt, GroupLayout.PREFERRED_SIZE, 22,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(commandBtn))
                    .addGap(22))
                    .addGroup(layout.createSequentialGroup()
                            .addComponent(label, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                            .addGap(492)))));

    ta = new JTextPane();
    ta.setEditable(false);
    ta.setFont(new Font("SansSerif", Font.PLAIN, 14));
    scrollPane_1.setViewportView(ta);

    friendsT = new JTable();
    friendsT.setModel(new DefaultTableModel(new Object[][] {}, new String[] { "Username" }));
    scrollPane.setViewportView(friendsT);
    getContentPane().setLayout(layout);

    pack();
}

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

private void initGUI() {
    try {/*from w  ww.j a v  a 2 s.  c  om*/
        {
            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();
    }
}