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.diversityarrays.dal.server.SqlDialog.java

private void showHelp() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    pw.println("<html>");

    for (String line : HELP_LINES) {
        pw.println(line);/*from w ww  .ja  v a 2s  .com*/
    }
    pw.println("</html>");
    pw.close();

    JTextPane helpText = new JTextPane();
    helpText.setEditorKit(new HTMLEditorKit());
    helpText.setText(sw.toString());
    helpText.setEditable(false);

    addPanelToTabbedPane(new JScrollPane(helpText));
}

From source file:org.astrojournal.gui.AJMainGUI.java

/**
 * Set AstroJournal jTextPane. This is the output panel.
 * //  www.  ja va  2 s.c  om
 * @return the jScrollPane containing jTextPane.
 */
private JScrollPane setJTextPane() {
    // Create the text area containing the program text output
    textPane = new JTextPane();
    // Move the JScrollPane to the bottom automatically.
    DefaultCaret caret = (DefaultCaret) textPane.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textPane.setEditable(false);

    // Now attach the log appender necessary for redirecting the log
    // messages into the JTextPane
    JTextPaneAppender.addJTextPane(textPane);

    // Let's add a scroll pane
    return new JScrollPane(textPane);
}

From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java

private JTextPane createTextPane(Color bgColor) {
    JTextPane pane = new JTextPane();
    pane.setEditable(false);//from  ww w  .j a  va 2  s . co  m
    pane.setBackground(bgColor);
    pane.setCaret(new NonAdjustingCaret());
    return pane;
}

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

private void initComponents() {
    setLayout(new MigLayout("insets 12", "[]", "[fill][]"));

    notificationPanel = new JPanel();
    notificationPanel.setLayout(new MigLayout("insets 0 0 0 0, fill", "[200!][]", "[25!]0[]"));
    notificationPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    archiveAll = new JLabel("Archive All");
    archiveAll.setForeground(java.awt.Color.blue);
    archiveAll.setText("<html><u>Archive All</u></html>");
    archiveAll.setToolTipText("Archive all notifications below.");
    archiveAll.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    newNotificationsLabel = new JLabel();
    newNotificationsLabel.setFont(newNotificationsLabel.getFont().deriveFont(Font.BOLD));
    headerListPanel = new JPanel();
    headerListPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    headerListPanel.setLayout(new MigLayout("insets 2, fill"));
    headerListPanel.setBorder(BorderFactory.createLineBorder(borderColor));

    list = new JList();
    list.setCellRenderer(new NotificationListCellRenderer());
    list.addListSelectionListener(new ListSelectionListener() {
        @Override//from  w w  w  .  java2s.c  o  m
        public void valueChanged(ListSelectionEvent event) {
            if (!event.getValueIsAdjusting()) {
                currentNotification = (Notification) list.getSelectedValue();
                if (currentNotification != null) {
                    notificationNameTextField.setText(currentNotification.getName());
                    contentTextPane.setText(currentNotification.getContent());
                    archiveSelected();
                }
            }
        }
    });
    listScrollPane = new JScrollPane();
    listScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    listScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));
    listScrollPane.setViewportView(list);
    listScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    archiveLabel = new JLabel();
    archiveLabel.setForeground(java.awt.Color.blue);
    archiveLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));

    notificationNameTextField = new JTextField();
    notificationNameTextField.setFont(notificationNameTextField.getFont().deriveFont(Font.BOLD));
    notificationNameTextField.setEditable(false);
    notificationNameTextField.setFocusable(false);
    notificationNameTextField.setBorder(BorderFactory.createEmptyBorder());
    notificationNameTextField.setBackground(UIConstants.HIGHLIGHTER_COLOR);
    DefaultCaret nameCaret = (DefaultCaret) notificationNameTextField.getCaret();
    nameCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    headerContentPanel = new JPanel();
    headerContentPanel.setLayout(new MigLayout("insets 2, fill"));
    headerContentPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    headerContentPanel.setBackground(UIConstants.HIGHLIGHTER_COLOR);

    contentTextPane = new JTextPane();
    contentTextPane.setContentType("text/html");
    contentTextPane.setEditable(false);
    contentTextPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            if (evt.getEventType() == EventType.ACTIVATED && Desktop.isDesktopSupported()) {
                try {
                    if (Desktop.isDesktopSupported()) {
                        Desktop.getDesktop().browse(evt.getURL().toURI());
                    } else {
                        BareBonesBrowserLaunch.openURL(evt.getURL().toString());
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    });
    DefaultCaret contentCaret = (DefaultCaret) contentTextPane.getCaret();
    contentCaret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    contentScrollPane = new JScrollPane();
    contentScrollPane.setViewportView(contentTextPane);
    contentScrollPane.setBorder(BorderFactory.createMatteBorder(0, 1, 1, 1, borderColor));

    archiveLabel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            int index = list.getSelectedIndex();
            if (currentNotification.isArchived()) {
                notificationModel.setArchived(false, index);
                unarchivedCount++;
            } else {
                notificationModel.setArchived(true, index);
                unarchivedCount--;
            }
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    archiveAll.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            for (int i = 0; i < notificationModel.getSize(); i++) {
                notificationModel.setArchived(true, i);
            }
            unarchivedCount = 0;
            archiveSelected();
            updateUnarchivedCountLabel();
        }
    });

    notificationCheckBox = new JCheckBox("Show new notifications on login");
    notificationCheckBox.setBackground(UIConstants.BACKGROUND_COLOR);

    if (checkForNotifications == null || BooleanUtils.toBoolean(checkForNotifications)) {
        checkForNotificationsSetting = true;
        if (showNotificationPopup == null || BooleanUtils.toBoolean(showNotificationPopup)) {
            notificationCheckBox.setSelected(true);
        } else {
            notificationCheckBox.setSelected(false);
        }
    } else {
        notificationCheckBox.setSelected(false);
    }

    notificationCheckBox.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (notificationCheckBox.isSelected() && !checkForNotificationsSetting) {
                alertSettingsChange();
            }
        }
    });

    closeButton = new JButton("Close");
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSave();
        }
    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            doSave();
        }
    });
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java

/**
 * Constructor./*www  .jav a  2  s. com*/
 */
public GapFillingFrame(final AbstractTabView atv, final Instances dataSet, final Attribute attr,
        final int dateIdx, final int valuesBeforeAndAfter, final int position, final int gapsize,
        final StationsDataProvider gcp, final boolean inBatchMode) {
    super();

    setTitle("Gap filling for " + attr.name() + " ("
            + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position).value(dateIdx)) + " -> "
            + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position + gapsize).value(dateIdx)) + ")");
    LogoHelper.setLogo(this);

    this.atv = atv;

    this.dataSet = dataSet;
    this.attr = attr;
    this.dateIdx = dateIdx;
    this.valuesBeforeAndAfter = valuesBeforeAndAfter;
    this.position = position;
    this.gapsize = gapsize;

    this.gcp = gcp;

    final Instances testds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0,
            dataSet.numAttributes() - 1, Math.max(0, position - valuesBeforeAndAfter),
            Math.min(position + gapsize + valuesBeforeAndAfter, dataSet.numInstances() - 1));

    this.attrNames = WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(testds);

    this.isGapSimulated = (this.attrNames.contains(attr.name()));
    this.originaldataSet = new Instances(dataSet);
    if (this.isGapSimulated) {
        setTitle(getTitle() + " [SIMULATED GAP]");
        /*final JXLabel fictiveGapLabel=new JXLabel("                                                                        FICTIVE GAP");
        fictiveGapLabel.setForeground(Color.RED);
        fictiveGapLabel.setFont(new Font(fictiveGapLabel.getFont().getName(), Font.PLAIN,fictiveGapLabel.getFont().getSize()*2));
        final JXPanel fictiveGapPanel=new JXPanel();
        fictiveGapPanel.setLayout(new BorderLayout());
        fictiveGapPanel.add(fictiveGapLabel,BorderLayout.CENTER);
        getContentPane().add(fictiveGapPanel,BorderLayout.NORTH);*/
        this.attrNames.remove(attr.name());
        this.originalDataBeforeGapSimulation = dataSet.attributeToDoubleArray(attr.index());
        for (int i = position; i < position + gapsize; i++)
            dataSet.instance(i).setMissing(attr);
    }

    final Object[] attrNamesObj = this.attrNames.toArray();

    this.centerPanel = new JXPanel();
    this.centerPanel.setLayout(new BorderLayout());
    getContentPane().add(this.centerPanel, BorderLayout.CENTER);

    //final JXPanel algoPanel=new JXPanel();
    //getContentPane().add(algoPanel,BorderLayout.NORTH);
    final JXPanel filterPanel = new JXPanel();
    //filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.Y_AXIS));      
    filterPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(10, 10, 10, 10);
    getContentPane().add(filterPanel, BorderLayout.WEST);

    final JXComboBox algoCombo = new JXComboBox(Algo.values());
    algoCombo.setBorder(new TitledBorder("Algorithm"));
    filterPanel.add(algoCombo, gbc);
    gbc.gridy++;

    final JXLabel infoLabel = new JXLabel("Usable = with no missing values on the period");
    //infoLabel.setBorder(new TitledBorder(""));
    filterPanel.add(infoLabel, gbc);
    gbc.gridy++;

    final JList<Object> timeSeriesList = new JList<Object>(attrNamesObj);
    timeSeriesList.setBorder(new TitledBorder("Usable time series"));
    timeSeriesList.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    final JScrollPane jcpMap = new JScrollPane(timeSeriesList);
    jcpMap.setPreferredSize(new Dimension(225, 150));
    jcpMap.setMinimumSize(new Dimension(225, 150));
    filterPanel.add(jcpMap, gbc);
    gbc.gridy++;

    final JXPanel mapPanel = new JXPanel();
    mapPanel.setBorder(new TitledBorder(""));
    mapPanel.setLayout(new BorderLayout());
    mapPanel.add(gcp.getMapPanel(Arrays.asList(attr.name()), this.attrNames, true), BorderLayout.CENTER);
    filterPanel.add(mapPanel, gbc);
    gbc.gridy++;

    final JXLabel mssLabel = new JXLabel(
            "<html>Most similar usable serie: <i>[... computation ...]</i></html>");
    mssLabel.setBorder(new TitledBorder(""));
    filterPanel.add(mssLabel, gbc);
    gbc.gridy++;

    final JXLabel nsLabel = new JXLabel("<html>Nearest usable serie: <i>[... computation ...]</i></html>");
    nsLabel.setBorder(new TitledBorder(""));
    filterPanel.add(nsLabel, gbc);
    gbc.gridy++;

    final JXLabel ussLabel = new JXLabel("<html>Upstream serie: <i>[... computation ...]</i></html>");
    ussLabel.setBorder(new TitledBorder(""));
    filterPanel.add(ussLabel, gbc);
    gbc.gridy++;

    final JXLabel dssLabel = new JXLabel("<html>Downstream serie: <i>[... computation ...]</i></html>");
    dssLabel.setBorder(new TitledBorder(""));
    filterPanel.add(dssLabel, gbc);
    gbc.gridy++;

    final JCheckBox hideOtherSeriesCB = new JCheckBox("Hide the others series");
    hideOtherSeriesCB.setSelected(DEFAULT_HIDE_OTHER_SERIES_OPTION);
    filterPanel.add(hideOtherSeriesCB, gbc);
    gbc.gridy++;

    final JCheckBox showErrorCB = new JCheckBox("Show error on plot");
    filterPanel.add(showErrorCB, gbc);
    gbc.gridy++;

    final JCheckBox zoomCB = new JCheckBox("Auto-adjusted size");
    zoomCB.setSelected(DEFAULT_ZOOM_OPTION);
    filterPanel.add(zoomCB, gbc);
    gbc.gridy++;

    final JCheckBox multAxisCB = new JCheckBox("Multiple axis");
    filterPanel.add(multAxisCB, gbc);
    gbc.gridy++;

    final JCheckBox showEnvelopeCB = new JCheckBox("Show envelope (all algorithms, SLOW)");
    filterPanel.add(showEnvelopeCB, gbc);
    gbc.gridy++;

    final JXButton showModelButton = new JXButton("Show the model");
    filterPanel.add(showModelButton, gbc);
    gbc.gridy++;

    showModelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final JXFrame dialog = new JXFrame();
            dialog.setTitle("Model");
            LogoHelper.setLogo(dialog);
            dialog.getContentPane().removeAll();
            dialog.getContentPane().setLayout(new BorderLayout());
            final JTextPane modelTxtPane = new JTextPane();
            modelTxtPane.setText(gapFiller.getModel());
            modelTxtPane.setBackground(Color.WHITE);
            modelTxtPane.setEditable(false);
            final JScrollPane jsp = new JScrollPane(modelTxtPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            jsp.setSize(new Dimension(400 - 20, 400 - 20));
            dialog.getContentPane().add(jsp, BorderLayout.CENTER);
            dialog.setSize(new Dimension(400, 400));
            dialog.setLocationRelativeTo(centerPanel);
            dialog.pack();
            dialog.setVisible(true);
        }
    });

    algoCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
                showModelButton.setEnabled(gapFiller.hasExplicitModel());
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    timeSeriesList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(final ListSelectionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
                mapPanel.removeAll();
                final List<String> currentlySelected = new ArrayList<String>();
                currentlySelected.add(attr.name());
                for (final Object sel : timeSeriesList.getSelectedValues())
                    currentlySelected.add(sel.toString());
                mapPanel.add(gcp.getMapPanel(currentlySelected, attrNames, true), BorderLayout.CENTER);
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    hideOtherSeriesCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    showErrorCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    zoomCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    showEnvelopeCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    multAxisCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    this.inBatchMode = inBatchMode;

    if (!inBatchMode) {
        try {
            refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), new int[0],
                    DEFAULT_HIDE_OTHER_SERIES_OPTION, false, DEFAULT_ZOOM_OPTION, false, false);
            showModelButton.setEnabled(gapFiller.hasExplicitModel());
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }

    if (!inBatchMode) {
        /* automatically select computed series */
        new AbstractSimpleAsync<Void>(true) {
            @Override
            public Void execute() throws Exception {
                mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames,
                        false);
                mssLabel.setText("<html>Most similar usable serie: <b>" + mostSimilar + "</b></html>");

                nearest = gcp.findNearestStation(attr.name(), attrNames);
                nsLabel.setText("<html>Nearest usable serie: <b>" + nearest + "</b></html>");

                upstream = gcp.findUpstreamStation(attr.name(), attrNames);
                if (upstream != null) {
                    ussLabel.setText("<html>Upstream usable serie: <b>" + upstream + "</b></html>");
                } else {
                    ussLabel.setText("<html>Upstream usable serie: <b>N/A</b></html>");
                }

                downstream = gcp.findDownstreamStation(attr.name(), attrNames);
                if (downstream != null) {
                    dssLabel.setText("<html>Downstream usable serie: <b>" + downstream + "</b></html>");
                } else {
                    dssLabel.setText("<html>Downstream usable serie: <b>N/A</b></html>");
                }

                timeSeriesList.setSelectedIndices(
                        new int[] { attrNames.indexOf(mostSimilar), attrNames.indexOf(nearest),
                                attrNames.indexOf(upstream), attrNames.indexOf(downstream) });

                return null;
            }

            @Override
            public void onSuccess(final Void result) {
            }

            @Override
            public void onFailure(final Throwable caught) {
                caught.printStackTrace();
            }
        }.start();
    } else {
        try {
            mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames, false);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        nearest = gcp.findNearestStation(attr.name(), attrNames);
        upstream = gcp.findUpstreamStation(attr.name(), attrNames);
        downstream = gcp.findDownstreamStation(attr.name(), attrNames);
    }
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

public void init() {

    //   dataPoints = new LinkedList();
    t1_x = t2_x = 0;//  w  w  w .j  ava 2  s.  c  om
    t1_y = t2_y = 0.001;
    simulatedPoints = setupUniformSimulate(numStocks, numSimulate);
    tabbedPanelContainer = new JTabbedPane();
    show_tangent = true;

    //   addGraph(chartPanel);
    //   addToolbar(sliderPanel);
    initGraphPanel();
    initMixPanel();
    initInputPanel();
    emptyTool();
    emptyTool2();
    leftControl = new JPanel();
    leftControl.setLayout(new BoxLayout(leftControl, BoxLayout.PAGE_AXIS));
    addRadioButton2Left("Number of Stocks:", "", numStocksArray, numStocks - 2, this);
    addRadioButton2Left("Show Tangent Line :", "", on_off, 0, this);

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

    addTabbedPane(GRAPH, graphPanel);

    addTabbedPane(INPUT, inputPanel);

    addTabbedPane(ALL, mixPanelContainer);

    setChart();

    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();
                setChart();

            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == INPUT) {
                //
                setInputPanel();
            }
        }
    });

    statusTextArea = new JTextPane(); //right side lower
    statusTextArea.setEditable(false);
    JScrollPane statusContainer = new JScrollPane(statusTextArea);
    statusContainer.setPreferredSize(new Dimension(600, 140));

    JSplitPane upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftControl),
            new JScrollPane(tabbedPanelContainer));

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

        this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    }
    this.getMainPanel().validate();

}

From source file:TextSamplerDemo.java

private JTextPane createTextPane() {
    String[] initString = { "This is an editable JTextPane, ", //regular
            "another ", //italic
            "styled ", //bold
            "text ", //small
            "component, ", //large
            "which supports embedded components..." + newline, //regular
            " " + newline, //button
            "...and embedded icons..." + newline, //regular
            " ", //icon
            newline + "JTextPane is a subclass of JEditorPane that "
                    + "uses a StyledEditorKit and StyledDocument, and provides "
                    + "cover methods for interacting with those objects." };

    String[] initStyles = { "regular", "italic", "bold", "small", "large", "regular", "button", "regular",
            "icon", "regular" };

    JTextPane textPane = new JTextPane();
    StyledDocument doc = textPane.getStyledDocument();
    addStylesToDocument(doc);// w w  w  .ja v  a 2s .  c o m

    try {
        for (int i = 0; i < initString.length; i++) {
            doc.insertString(doc.getLength(), initString[i], doc.getStyle(initStyles[i]));
        }
    } catch (BadLocationException ble) {
        System.err.println("Couldn't insert initial text into text pane.");
    }

    return textPane;
}

From source file:com.adito.upgrade.GUIUpgrader.java

public void upgrade() throws Exception {
    if (JOptionPane.showConfirmDialog(this,
            "All selected resources will be now upgrade from the source installation to the target. Are you sure you wish to continue?",
            "Run Upgrade", JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) == JOptionPane.YES_OPTION) {
        ////from  w  ww  . j av  a 2 s  . c om
        final List l = new ArrayList();
        for (int i = 0; i < upgradeSelectionPanel.getComponentCount(); i++) {
            JCheckBox b = (JCheckBox) upgradeSelectionPanel.getComponent(i);
            if (b.isSelected()) {
                l.add(b.getClientProperty("upgrade"));
            }
        }

        removeUpgradeSelectionComponent();
        invalidate();
        removeAll();

        // Progress panel
        JPanel progressPanel = new JPanel(new BorderLayout());
        progressPanel.setBorder(BorderFactory.createTitledBorder("Progress"));
        final JProgressBar b = new JProgressBar(0, l.size());
        b.setStringPainted(true);
        progressPanel.add(b, BorderLayout.CENTER);
        add(progressPanel, BorderLayout.NORTH);

        // Console panel
        JPanel consolePanel = new JPanel(new BorderLayout());
        consolePanel.setBorder(BorderFactory.createTitledBorder("Output"));
        console = new JTextPane();
        JScrollPane scrollPane = new JScrollPane(console);
        consolePanel.add(scrollPane, BorderLayout.CENTER);
        add(consolePanel, BorderLayout.CENTER);

        //

        validate();
        repaint();

        //

        Thread t = new Thread() {
            public void run() {
                try {
                    for (Iterator i = l.iterator(); i.hasNext();) {
                        AbstractDatabaseUpgrade upgrade = (AbstractDatabaseUpgrade) i.next();
                        b.setValue(b.getValue() + 1);
                        upgrade.upgrade(GUIUpgrader.this);
                        try {
                            Thread.sleep(750);
                        } catch (InterruptedException ie) {
                        }
                    }
                    info("Complete");
                    Toolkit.getDefaultToolkit().beep();
                } catch (Exception e) {
                    error("Failed to upgrade.", e);
                }
            }
        };
        t.start();

    }

}

From source file:edu.ku.brc.specify.tools.schemalocale.SchemaLocalizerFrame.java

/**
 * /*from  www. ja  va2s  .  c  o m*/
 */
protected void buildUI() {
    SchemaLocalizerXMLHelper slxh = new SchemaLocalizerXMLHelper(schemaType, tableMgr);
    localizableIO = slxh;
    localizableIO.load(false);

    //stripToSingleLocale("pt", slxh);

    LocalizableStrFactory localizableStrFactory = new LocalizableStrFactory() {
        public LocalizableStrIFace create() {
            SpLocaleItemStr str = new SpLocaleItemStr();
            str.initialize();
            return str;
        }

        public LocalizableStrIFace create(String text, Locale locale) {
            return new SpLocaleItemStr(text, locale); // no initialize needed for this constructor
        }
    };

    LocalizerBasePanel.setLocalizableStrFactory(localizableStrFactory);
    SchemaLocalizerXMLHelper.setLocalizableStrFactory(localizableStrFactory);

    schemaLocPanel = new SchemaLocalizerPanel(null, dataObjFieldFormatMgrCache, uiFieldFormatterMgrCache,
            webLinkMgrCache, schemaType);
    schemaLocPanel.setLocalizableIO(localizableIO);
    schemaLocPanel.setStatusBar(statusBar);

    boolean useDisciplines = AppPreferences.getLocalPrefs().getBoolean("SCHEMA_DISP", false);
    schemaLocPanel.setUseDisciplines(useDisciplines);

    // rods - for now 
    //schemaLocPanel.setIncludeHiddenUI(true);
    schemaLocPanel.buildUI();
    schemaLocPanel.setHasChanged(localizableIO.didModelChangeDuringLoad());

    statusBar.setSectionText(1,
            schemaType == SpLocaleContainer.CORE_SCHEMA ? getResourceString("SchemaLocalizerFrame.FULL_SCHEMA") //$NON-NLS-1$
                    : getResourceString("SchemaLocalizerFrame.WB_SCHEMA")); //$NON-NLS-1$

    UIRegistry.setStatusBar(statusBar);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    String title = "File"; //$NON-NLS-1$
    String mneu = "F"; //$NON-NLS-1$
    JMenu fileMenu = UIHelper.createLocalizedMenu(menuBar, title, mneu);

    title = "Save"; //$NON-NLS-1$
    mneu = "S"; //$NON-NLS-1$
    JMenuItem saveMenuItem = UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", false, //$NON-NLS-1$
            new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    write();
                }
            });
    saveMenuItem.setEnabled(false);

    title = "Export"; //$NON-NLS-1$
    mneu = "E"; //$NON-NLS-1$
    UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$
    {
        public void actionPerformed(ActionEvent e) {
            export();
        }
    });

    title = "SchemaLocalizerFrame.ExportLOCALE"; //$NON-NLS-1$
    mneu = "SchemaLocalizerFrame.ExportLOCALEMnu"; //$NON-NLS-1$
    UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$
    {
        public void actionPerformed(ActionEvent e) {
            exportSingleLocale();
        }
    });

    title = "Exit"; //$NON-NLS-1$
    mneu = "x"; //$NON-NLS-1$
    if (!UIHelper.isMacOS()) {
        fileMenu.addSeparator();

        UIHelper.createLocalizedMenuItem(fileMenu, title, mneu, "", true, new ActionListener() //$NON-NLS-1$
        {
            public void actionPerformed(ActionEvent e) {
                shutdown();
            }
        });
    }
    /*
    JMenu toolMenu = UIHelper.createMenu(menuBar, "Tools", "T");
    UIHelper.createMenuItem(toolMenu, "Create Resource Files", "C", "", true, new ActionListener()
    {
    public void actionPerformed(ActionEvent e)
    {
        createResourceFiles();
    }
    });
    */

    menuBar.add(SchemaI18NService.getInstance().createLocaleMenu(this, new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("locale")) //$NON-NLS-1$
            {
                schemaLocPanel.localeChanged((Locale) evt.getNewValue());
                statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName());
            }
        }
    }));

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    setSize(800, 600);

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(schemaLocPanel, BorderLayout.CENTER);
    mainPanel.add(statusBar, BorderLayout.SOUTH);

    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    setContentPane(mainPanel);

    statusBar.setSectionText(0, SchemaI18NService.getCurrentLocale().getDisplayName());

    schemaLocPanel.setSaveMenuItem(saveMenuItem);

    schemaLocPanel.getContainerList().setEnabled(true);

    AppPreferences localPrefs = AppPreferences.getLocalPrefs();
    localPrefs.setDirPath(UIRegistry.getAppDataDir());

    ImageIcon helpIcon = IconManager.getIcon("AppIcon", IconSize.Std16); //$NON-NLS-1$
    HelpMgr.initializeHelp("SpecifyHelp", helpIcon.getImage()); //$NON-NLS-1$

    AppPrefsCache.setUseLocalOnly(true);
    SpecifyAppPrefs.loadColorAndFormatPrefs();

    if (localizableIO.didModelChangeDuringLoad()) {
        saveMenuItem.setEnabled(true);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame(getResourceString("SchemaLocalizerFrame.CHG_TO_SCHEMA")); //$NON-NLS-1$
                frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

                JTextPane tp = new JTextPane();
                JScrollPane js = new JScrollPane();
                js.getViewport().add(tp);

                tp.setContentType("text/html");
                tp.setText(((SchemaLocalizerXMLHelper) localizableIO).getChangesBuffer());

                frame.setContentPane(js);
                frame.pack();
                frame.setSize(400, 500);
                frame.setVisible(true);
            }
        });
    }
}

From source file:com.sec.ose.osi.ui.frm.main.identification.stringmatch.JPanStringMatchMain.java

public JTextPane getJTextPaneSourceCode() {
    if (jTextPaneSourceCode == null) {
        jTextPaneSourceCode = new JTextPane();
        jTextPaneSourceCode.setEditable(false);
        jTextPaneSourceCode.setAutoscrolls(false);

        docSourceCode = jTextPaneSourceCode.getStyledDocument();
    }//  w w w . j av a2s  . co  m
    return jTextPaneSourceCode;
}