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:pl.kotcrab.arget.gui.MainWindow.java

private void createAndShowGUI() {
    setTitle(App.APP_NAME);// w  ww  . java 2 s  .c  o m
    setBounds(100, 100, 800, 700);
    setMinimumSize(new Dimension(500, 250));
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setIconImage(App.loadImage("/data/icon/icon.png"));

    sessionWindowManager = new SessionWindowManager(this);

    if (profile.mainWindowBounds != null
            && GraphicsUtils.isRectangleDisplayableOnScreen(profile.mainWindowBounds))
        setBounds(profile.mainWindowBounds);

    createMenuBars();

    contactsPanel = new ContactsPanel(profile, this);

    statusPane = new JTextPane();
    statusPane.setBorder(new EmptyBorder(1, 3, 2, 0));
    statusPane.setContentType("text/html");
    statusPane.setBackground(null);
    statusPane.setHighlighter(null);
    statusPane.setEditable(false);
    statusPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    statusPane.setFont(new Font("Tahoma", Font.PLAIN, 13));

    statusPane.addHyperlinkListener(new HyperlinkListener() {

        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                String desc = e.getDescription();

                if (desc.startsWith("version-mismatch")) {
                    desc = desc.substring(desc.indexOf("://") + 3);
                    String[] versionInfo = desc.split("!");
                    new VersionMismatchDialog(MainWindow.instance, versionInfo[0],
                            Integer.valueOf(versionInfo[1]));
                }
            }
        }
    });

    JPanel bottomPanel = new JPanel(new BorderLayout(0, 0));

    getContentPane().add(bottomPanel, BorderLayout.SOUTH);

    scrollLockToggle = new WebToggleButton();
    scrollLockToggle.setToolTipText("Scroll lock");
    scrollLockToggle.setRolloverDecoratedOnly(true);
    scrollLockToggle.setDrawFocus(false);
    scrollLockToggle.setIcon(App.loadImageIcon("/data/scrolllock.png"));
    scrollLockToggle.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            postScrollLockUpdate();
        }
    });

    bottomPanel.add(statusPane);
    bottomPanel.add(scrollLockToggle, BorderLayout.EAST);

    splitPane = new JSplitPane();
    splitPane.setBorder(new BottomSplitPaneBorder());
    splitPane.setResizeWeight(0);
    splitPane.setContinuousLayout(true);
    splitPane.setOneTouchExpandable(true);
    getContentPane().add(splitPane, BorderLayout.CENTER);

    homePanel = new HomePanel(profile.fileName);
    logPanel = new LoggerPanel();

    errorStatusPanel = new ErrorStatusPanel();

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(contactsPanel, BorderLayout.CENTER);
    leftPanel.add(errorStatusPanel, BorderLayout.SOUTH);

    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(null);
    setCenterScreenTo(homePanel);

    addWindowFocusListener(new WindowAdapter() {
        @Override
        public void windowGainedFocus(WindowEvent e) {
            instance.validate();
            instance.revalidate();
            instance.repaint();

            getCenterScreen().onShow();
        }

        @Override
        public void windowLostFocus(WindowEvent e) {
            getCenterScreen().onHide();
        }

    });

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            ExitCleaner.forceExit();
        }
    });

    setVisible(true);
}

From source file:pl.kotcrab.arget.gui.session.msg.TextMessage.java

public TextMessage(MsgType type, String text, boolean markAsRead) {
    super(type);//from  w  ww.  ja va2  s .c o  m

    textPane = new JTextPane();
    textPane.setAlignmentX(Component.LEFT_ALIGNMENT);
    textPane.setEditorKit(new WrapHTMLEditorKit());
    textPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, true);
    textPane.setEditable(false);
    textPane.setBackground(null);
    textPane.setBorder(new EmptyBorder(3, 3, 0, 0));
    textPane.setFont(textFont);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hle) {
            if (HyperlinkEvent.EventType.ACTIVATED.equals(hle.getEventType())) {

                if (DesktopUtils.openWebsite(hle.getURL()) == false)
                    JOptionPane.showMessageDialog(null, "Invalid URL: " + hle.getURL(), "Error",
                            JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    setText(text);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(textPane);

    DateFormat dateFormat = new SimpleDateFormat("[HH:mm] ");
    Date date = new Date();

    String textToShow = dateFormat.format(date);

    if (markAsRead == false)
        textToShow += "*";

    timeLabel = new JLabel(textToShow);
    timeLabel.setBorder(new EmptyBorder(0, 3, 3, 0));
    timeLabel.setForeground(Color.GRAY);
    timeLabel.setFont(smallTextFont);
    add(timeLabel);
}

From source file:pl.otros.logview.gui.LogViewPanel.java

public LogViewPanel(final LogDataTableModel dataTableModel, TableColumns[] visibleColumns,
        final OtrosApplication otrosApplication) {
    super();/*from  ww w  . ja  v a 2s  . c  om*/
    this.dataTableModel = dataTableModel;
    this.otrosApplication = otrosApplication;
    this.statusObserver = otrosApplication.getStatusObserver();
    configuration = otrosApplication.getConfiguration();

    AllPluginables allPluginable = AllPluginables.getInstance();
    markersContainer = allPluginable.getMarkersContainser();
    markersContainer.addListener(new MarkersMenuReloader());
    logFiltersContainer = allPluginable.getLogFiltersContainer();
    messageColorizersContainer = allPluginable.getMessageColorizers();
    messageFormattersContainer = allPluginable.getMessageFormatters();
    selectedMessageColorizersContainer = new PluginableElementsContainer<MessageColorizer>();
    selectedMessageFormattersContainer = new PluginableElementsContainer<MessageFormatter>();
    for (MessageColorizer messageColorizer : messageColorizersContainer.getElements()) {
        selectedMessageColorizersContainer.addElement(messageColorizer);
    }
    for (MessageFormatter messageFormatter : messageFormattersContainer.getElements()) {
        selectedMessageFormattersContainer.addElement(messageFormatter);
    }
    messageColorizersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageColorizer>(selectedMessageColorizersContainer));
    messageFormattersContainer.addListener(
            new SynchronizePluginableContainerListener<MessageFormatter>(selectedMessageFormattersContainer));

    menuLabelFont = new JLabel().getFont().deriveFont(Font.BOLD);
    filtersPanel = new JPanel();
    logsTablePanel = new JPanel();
    logsMarkersPanel = new JPanel();
    leftPanel = new JPanel(new MigLayout());
    logDetailTextArea = new JTextPane();
    logDetailTextArea.setEditable(false);
    MouseAdapter locationInfo = new LocationClickMouseAdapter(otrosApplication, logDetailTextArea);
    logDetailTextArea.addMouseMotionListener(locationInfo);
    logDetailTextArea.addMouseListener(locationInfo);
    logDetailTextArea.setBorder(BorderFactory.createTitledBorder("Details"));
    logDetailWithRulerScrollPane = RulerBarHelper.wrapTextComponent(logDetailTextArea);
    table = new JTableWith2RowHighliting(dataTableModel);

    // Initialize default column visible before creating context menu
    table.setColumnControlVisible(true);
    final ColumnControlButton columnControlButton = new ColumnControlButton(table) {

        @Override
        public void togglePopup() {
            populatePopup();
            super.togglePopup();
        }

        @Override
        protected List<Action> getAdditionalActions() {
            final List<Action> additionalActions = super.getAdditionalActions();
            final AbstractAction saveLayout = new AbstractAction("Save current to new column layout",
                    Icons.DISK) {
                @Override
                public void actionPerformed(ActionEvent actionEvent) {
                    String newLayoutName = JOptionPane.showInputDialog(table, "New Layout name");
                    if (newLayoutName == null) {
                        return;
                    }
                    newLayoutName = newLayoutName.trim();
                    LOGGER.info(String.format("Saving New column layout '%s'", newLayoutName));
                    ArrayList<String> visibleColNames = new ArrayList<String>();
                    for (TableColumn tc : table.getColumns()) {
                        Object o = tc.getIdentifier();
                        if (!(o instanceof TableColumns)) {
                            LOGGER.severe("TableColumn identifier of unexpected type: "
                                    + tc.getIdentifier().getClass().getName());
                            LOGGER.warning("Throw up a pop-up");
                            return;
                        }
                        TableColumns tcs = (TableColumns) o;
                        visibleColNames.add(tcs.getName());
                    }
                    ColumnLayout columnLayout = new ColumnLayout(newLayoutName, visibleColNames);
                    final List<ColumnLayout> columnLayouts = LogTableFormatConfigView
                            .loadColumnLayouts(configuration);
                    columnLayouts.add(columnLayout);
                    LogTableFormatConfigView.saveColumnLayouts(columnLayouts, configuration);
                    populatePopup();
                }
            };
            additionalActions.add(saveLayout);

            final List<ColumnLayout> columnLayoutNames = LogTableFormatConfigView
                    .loadColumnLayouts(configuration);
            for (final ColumnLayout columnLayout : columnLayoutNames) {
                final String name = columnLayout.getName();
                final AbstractAction applyColumnLayout = new ApplyColumnLayoutAction(name, Icons.EDIT_COLUMNS,
                        columnLayout, table);
                additionalActions.add(applyColumnLayout);
            }
            return additionalActions;
        }
    };
    table.setColumnControl(columnControlButton);

    List<TableColumn> columns = table.getColumns(true);
    for (int i = 0; i < columns.size(); i++) {
        columns.get(i).setIdentifier(TableColumns.getColumnById(i));
    }
    for (TableColumn tableColumn : columns) {
        table.getColumnExt(tableColumn.getIdentifier()).setVisible(false);
    }
    for (TableColumns tableColumns : visibleColumns) {
        table.getColumnExt(tableColumns).setVisible(true);
    }

    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    updateColumnsSize();
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    final Renderers renderers = Renderers.getInstance(otrosApplication);
    table.setDefaultRenderer(String.class, new TableMarkDecoratorRenderer(renderers.getStringRenderer()));
    table.setDefaultRenderer(Object.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Integer.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Object.class)));
    table.setDefaultRenderer(Level.class, new TableMarkDecoratorRenderer(renderers.getLevelRenderer()));
    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(renderers.getDateRenderer()));
    final TimeDeltaRenderer timeDeltaRenderer = new TimeDeltaRenderer();
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent listSelectionEvent) {
            final int[] selectedRows = table.getSelectedRows();
            if (selectedRows.length > 0) {
                final int selectedRow = selectedRows[selectedRows.length - 1];
                final Date selectedDate = dataTableModel.getLogData(table.convertRowIndexToModel(selectedRow))
                        .getDate();
                timeDeltaRenderer.setSelectedTimestamp(selectedDate);
                table.repaint();
            }
        }
    });
    table.setDefaultRenderer(TimeDelta.class, new TableMarkDecoratorRenderer(timeDeltaRenderer));

    ((EventSource) configuration.getConfiguration()).addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent ce) {
            if (ce.getType() == AbstractConfiguration.EVENT_SET_PROPERTY && !ce.isBeforeUpdate()) {
                if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT)) {
                    table.setDefaultRenderer(Date.class, new TableMarkDecoratorRenderer(new DateRenderer(
                            configuration.getString(ConfKeys.LOG_TABLE_FORMAT_DATE_FORMAT, "HH:mm:ss.SSS"))));
                    updateTimeColumnSize();
                } else if (ce.getPropertyName().equals(ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER)) {
                    table.setDefaultRenderer(Level.class,
                            new TableMarkDecoratorRenderer(new LevelRenderer(configuration.get(
                                    LevelRenderer.Mode.class, ConfKeys.LOG_TABLE_FORMAT_LEVEL_RENDERER,
                                    LevelRenderer.Mode.IconsOnly))));
                    updateLevelColumnSize();
                }
            }
        }
    });

    table.setDefaultRenderer(Boolean.class,
            new TableMarkDecoratorRenderer(table.getDefaultRenderer(Boolean.class)));
    table.setDefaultRenderer(Note.class, new TableMarkDecoratorRenderer(new NoteRenderer()));
    table.setDefaultRenderer(MarkerColors.class, new TableMarkDecoratorRenderer(new MarkTableRenderer()));
    table.setDefaultEditor(Note.class, new NoteTableEditor());
    table.setDefaultEditor(MarkerColors.class, new MarkTableEditor(otrosApplication));
    table.setDefaultRenderer(ClassWrapper.class,
            new TableMarkDecoratorRenderer(renderers.getClassWrapperRenderer()));
    sorter = new TableRowSorter<LogDataTableModel>(dataTableModel);
    for (int i = 0; i < dataTableModel.getColumnCount(); i++) {
        sorter.setSortable(i, false);
    }
    sorter.setSortable(TableColumns.ID.getColumn(), true);
    sorter.setSortable(TableColumns.TIME.getColumn(), true);
    table.setRowSorter(sorter);

    messageDetailListener = new MessageDetailListener(this, dateFormat, selectedMessageFormattersContainer,
            selectedMessageColorizersContainer);
    table.getSelectionModel().addListSelectionListener(messageDetailListener);
    dataTableModel.addNoteObserver(messageDetailListener);

    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            boolean hasFocus = otrosApplication.getApplicationJFrame().isFocused();
            final boolean enabled = otrosApplication.getConfiguration()
                    .getBoolean(ConfKeys.JUMP_TO_CODE_AUTO_JUMP_ENABLED, false);
            if (hasFocus && enabled && !e.getValueIsAdjusting()) {
                try {
                    final LogData logData = dataTableModel
                            .getLogData(table.convertRowIndexToModel(e.getFirstIndex()));
                    LocationInfo li = new LocationInfo(logData.getClazz(), logData.getMethod(),
                            logData.getFile(), Integer.valueOf(logData.getLine()));
                    final JumpToCodeService jumpToCodeService = otrosApplication.getServices()
                            .getJumpToCodeService();
                    final boolean ideAvailable = jumpToCodeService.isIdeAvailable();
                    if (ideAvailable) {
                        LOGGER.fine("Jumping to " + li);
                        jumpToCodeService.jump(li);
                    }
                } catch (Exception e1) {
                    LOGGER.warning("Can't perform jump to code " + e1.getMessage());
                }

            }
        }
    });

    notes = new JTextArea();
    notes.setEditable(false);
    NoteObserver allNotesObserver = new AllNotesTextAreaObserver(notes);
    dataTableModel.addNoteObserver(allNotesObserver);

    addFiltersGUIsToPanel(filtersPanel);
    logsTablePanel.setLayout(new BorderLayout());
    logsTablePanel.add(new JScrollPane(table));
    JPanel messageDetailsPanel = new JPanel(new BorderLayout());
    messageDetailToolbar = new JToolBar("MessageDetail");
    messageDetailsPanel.add(messageDetailToolbar, BorderLayout.NORTH);
    messageDetailsPanel.add(logDetailWithRulerScrollPane);
    initMessageDetailsToolbar();

    jTabbedPane = new JTabbedPane();
    jTabbedPane.add("Message detail", messageDetailsPanel);
    jTabbedPane.add("All notes", new JScrollPane(notes));

    leftPanel.add(filtersPanel, "wrap, growx");
    leftPanel.add(new JSeparator(SwingConstants.HORIZONTAL), "wrap,growx");
    leftPanel.add(logsMarkersPanel, "wrap,growx");

    JSplitPane splitPaneLogsTableAndDetails = new JSplitPane(JSplitPane.VERTICAL_SPLIT, logsTablePanel,
            jTabbedPane);
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftPanel,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
            splitPaneLogsTableAndDetails);
    splitPane.setOneTouchExpandable(true);
    this.setLayout(new BorderLayout());
    this.add(splitPane);

    splitPaneLogsTableAndDetails.setDividerLocation(0.5d);
    splitPaneLogsTableAndDetails.setOneTouchExpandable(true);
    splitPane.setDividerLocation(leftPanel.getPreferredSize().width + 10);

    PopupListener popupListener = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initTableContextMenu();
        }
    });
    table.addMouseListener(popupListener);
    table.addKeyListener(popupListener);

    PopupListener popupListenerMessageDetailMenu = new PopupListener(new Callable<JPopupMenu>() {
        @Override
        public JPopupMenu call() throws Exception {
            return initMessageDetailPopupMenu();
        }
    });
    logDetailTextArea.addMouseListener(popupListenerMessageDetailMenu);
    logDetailTextArea.addKeyListener(popupListenerMessageDetailMenu);

    dataTableModel.notifyAllNoteObservers(new NoteEvent(EventType.CLEAR, dataTableModel, null, 0));

    table.addKeyListener(new MarkRowBySpaceKeyListener(otrosApplication));
    initAcceptConditions();
}

From source file:pl.otros.logview.gui.message.editor.MessageColorizerEditor.java

public MessageColorizerEditor(PluginableElementsContainer<MessageColorizer> container,
        StatusObserver observer) {/*from   ww w  .  j  av  a  2s  .  com*/
    this.container = container;
    statusObserver = observer;
    this.setLayout(new BorderLayout());
    DefaultSyntaxKit.initKit();
    editorPane = new JEditorPane();
    JScrollPane comp = new JScrollPane(editorPane);
    JLabel propertyEditorLabel = new JLabel("Enter you message colorizer properties");
    editorPane.setContentType("text/properties");
    label = new JLabel();
    String defaultContent = getDefaultContent();
    try {
        editorPane.getDocument().insertString(0, defaultContent, null);
    } catch (BadLocationException e1) {
        LOGGER.severe(String.format("Can't set text: %s", e1.getMessage()));
    }

    deleyedSwingInvoke = new DelayedSwingInvoke() {

        @Override
        protected void performActionHook() {
            refreshView();

        }
    };
    DocumentListener documentListener = new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            deleyedSwingInvoke.performAction();
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            deleyedSwingInvoke.performAction();
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    };
    editorPane.getDocument().addDocumentListener(documentListener);

    JLabel textPaneLabel = new JLabel("Enter log message body");
    textPane = new JTextPane();
    textPane.getDocument().addDocumentListener(documentListener);

    JPanel north = new JPanel(new BorderLayout());
    north.add(propertyEditorLabel, BorderLayout.NORTH);
    north.add(comp);
    JPanel south = new JPanel(new BorderLayout());
    south.add(textPaneLabel, BorderLayout.NORTH);
    south.add(new JScrollPane(textPane));
    JSplitPane jSplitPaneEditors = new JSplitPane(SwingConstants.HORIZONTAL, north, south);
    jSplitPaneEditors.setOneTouchExpandable(true);
    jSplitPaneEditors.setDividerLocation(0.5d);
    this.add(jSplitPaneEditors);
    this.add(label, BorderLayout.SOUTH);
}

From source file:plugin.notes.gui.NotesTreeNode.java

/**
 * Gets a JTextPane that contains the content of the "data.html" in this
 * directory (or the modified document if it has been modified), or is empty
 * if that file does not exist. This function caches the JTextPan so that the
 * speed doesn't suck.//from  www. j  av  a2 s . com
 *
 * @return The populated JTextPane
 */
public JTextPane getTextPane() {
    boolean repopulate = false;
    cacheCounter = 10;

    if (pane == null) {
        pane = new JTextPane();
        repopulate = true;

        ExtendedHTMLEditorKit htmlKit = new ExtendedHTMLEditorKit();
        pane.setEditorKit(htmlKit);
        notesDoc = (ExtendedHTMLDocument) (htmlKit.createDefaultDocument());
        notesDoc.putProperty(DOCROOT, dir.getAbsolutePath() + File.separator + DATA_HTML);
    }

    pane.setDocument(notesDoc);

    if (repopulate) {
        File notes = new File(dir.getAbsolutePath() + File.separator + DATA_HTML);

        if (notes.exists()) {
            try {
                StringBuilder sb;
                try (BufferedReader br = new BufferedReader(new FileReader(notes))) {
                    sb = new StringBuilder();
                    String newLine;

                    do {
                        newLine = br.readLine();

                        if (newLine != null) {
                            sb.append(newLine).append(Constants.LINE_SEPARATOR);
                        }
                    } while (newLine != null);

                }
                pane.setText(sb.toString());
            } catch (Exception e) {
                Logging.errorPrint(e.getMessage(), e);
            }
        }

        pane.setCaretPosition(0);
        notesDoc.addDocumentListener(this);
    }

    return pane;
}

From source file:plugin.notes.gui.NotesView.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  2 s  . c  om
 */
private void initComponents() {
    //GEN-BEGIN:initComponents
    jSplitPane1 = new FlippingSplitPane();
    jScrollPane1 = new JScrollPane();
    notesTree = new JTree();
    jPanel1 = new JPanel();
    jScrollPane2 = new JScrollPane();
    editor = new JTextPane();
    jPanel2 = new JPanel();
    fileBar = new JToolBar();
    newButton = new JButton();
    saveButton = new JButton();
    exportButton = new JButton();
    revertButton = new JButton();
    deleteButton = new JButton();
    clipboardBar = new JToolBar();
    cutButton = new JButton();
    copyButton = new JButton();
    pasteButton = new JButton();
    formatBar = new JToolBar();
    sizeCB = new JComboBox();
    boldButton = new JButton();
    italicButton = new JButton();
    underlineButton = new JButton();
    colorButton = new JButton();
    bulletButton = new JButton();
    enumButton = new JButton();
    imageButton = new JButton();
    alignmentBar = new JToolBar();
    leftJustifyButton = new JButton();
    centerJustifyButton = new JButton();
    rightJustifyButton = new JButton();
    filePane = new JPanel();
    fileLeft = new JButton();
    fileRight = new JButton();
    filesBar = new JToolBar();

    setLayout(new java.awt.BorderLayout());

    jSplitPane1.setDividerLocation(175);
    jSplitPane1.setDividerSize(5);
    jScrollPane1.setViewportView(notesTree);

    jSplitPane1.setLeftComponent(jScrollPane1);

    jPanel1.setLayout(new java.awt.BorderLayout());

    editor.addCaretListener(this::editorCaretUpdate);

    jScrollPane2.setViewportView(editor);

    jPanel1.add(jScrollPane2, java.awt.BorderLayout.CENTER);

    jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT, 0, 0));

    newButton.setIcon(Icons.stock_new.getImageIcon());
    newButton.setToolTipText("New Node");
    newButton.setBorder(new EtchedBorder());
    newButton.setEnabled(false);
    newButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            newButtonActionPerformed();
        }
    });

    fileBar.add(newButton);

    saveButton.setIcon(Icons.stock_save.getImageIcon());
    saveButton.setToolTipText("Save Node");
    saveButton.setBorder(new EtchedBorder());
    saveButton.setEnabled(false);
    saveButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            saveButtonActionPerformed();
        }
    });

    fileBar.add(saveButton);

    exportButton.setIcon(Icons.stock_export.getImageIcon());
    exportButton.setToolTipText("Export");
    exportButton.setBorder(new EtchedBorder());
    exportButton.setEnabled(false);
    exportButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exportButtonActionPerformed();
        }
    });

    fileBar.add(exportButton);

    revertButton.setIcon(Icons.stock_revert.getImageIcon());
    revertButton.setToolTipText("Revert to Saved");
    revertButton.setBorder(new EtchedBorder());
    revertButton.setEnabled(false);
    revertButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            revertButtonActionPerformed();
        }
    });

    fileBar.add(revertButton);

    deleteButton.setIcon(Icons.stock_broken_image.getImageIcon());
    deleteButton.setToolTipText("Delete Node");
    deleteButton.setBorder(new EtchedBorder());
    deleteButton.setEnabled(false);
    deleteButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            deleteButtonActionPerformed();
        }
    });

    fileBar.add(deleteButton);

    jPanel2.add(fileBar);

    cutButton.setIcon(Icons.stock_cut.getImageIcon());
    cutButton.setToolTipText("Cut");
    cutButton.setBorder(new EtchedBorder());
    cutButton.addActionListener(this::cutButtonActionPerformed);

    clipboardBar.add(cutButton);

    copyButton.setIcon(Icons.stock_copy.getImageIcon());
    copyButton.setToolTipText("Copy");
    copyButton.setBorder(new EtchedBorder());
    copyButton.addActionListener(this::copyButtonActionPerformed);

    clipboardBar.add(copyButton);

    pasteButton.setIcon(Icons.stock_paste.getImageIcon());
    pasteButton.setToolTipText("Paste");
    pasteButton.setBorder(new EtchedBorder());
    pasteButton.addActionListener(this::pasteButtonActionPerformed);

    clipboardBar.add(pasteButton);

    jPanel2.add(clipboardBar);

    sizeCB.setToolTipText("Size");
    sizeCB.setBorder(new EtchedBorder());
    sizeCB.addActionListener(this::sizeCBActionPerformed);

    formatBar.add(sizeCB);

    boldButton.setIcon(Icons.stock_text_bold.getImageIcon());
    boldButton.setToolTipText("Bold");
    boldButton.setBorder(new EtchedBorder());
    boldButton.addActionListener(this::boldButtonActionPerformed);

    formatBar.add(boldButton);

    italicButton.setIcon(Icons.stock_text_italic.getImageIcon());
    italicButton.setToolTipText("Italic");
    italicButton.setBorder(new EtchedBorder());
    italicButton.addActionListener(this::italicButtonActionPerformed);

    formatBar.add(italicButton);

    underlineButton.setIcon(Icons.stock_text_underline.getImageIcon());
    underlineButton.setToolTipText("Underline");
    underlineButton.setBorder(new EtchedBorder());
    underlineButton.addActionListener(this::underlineButtonActionPerformed);

    formatBar.add(underlineButton);

    colorButton.setForeground(java.awt.SystemColor.text);
    colorButton.setIcon(Icons.createImageIcon("menu-mode-RGB-alt.png"));
    colorButton.setToolTipText("Color");
    colorButton.setBorder(new EtchedBorder());
    colorButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            colorButtonActionPerformed();
        }
    });

    formatBar.add(colorButton);

    bulletButton.setIcon(Icons.stock_list_bulet.getImageIcon());
    bulletButton.setToolTipText("Bulleted List");
    bulletButton.setAction(actionListUnordered);
    bulletButton.setBorder(new EtchedBorder());
    formatBar.add(bulletButton);

    enumButton.setIcon(Icons.stock_list_enum.getImageIcon());
    enumButton.setToolTipText("Numbered List");
    enumButton.setAction(actionListOrdered);
    enumButton.setBorder(new EtchedBorder());
    formatBar.add(enumButton);

    imageButton.setIcon(Icons.stock_insert_graphic.getImageIcon());
    imageButton.setBorder(new EtchedBorder());
    imageButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            imageButtonActionPerformed();
        }
    });

    formatBar.add(imageButton);

    jPanel2.add(formatBar);

    leftJustifyButton.setIcon(Icons.stock_text_align_left.getImageIcon());
    leftJustifyButton.setToolTipText("Left Justify");
    leftJustifyButton.setBorder(new EtchedBorder());
    leftJustifyButton.addActionListener(this::leftJustifyButtonActionPerformed);

    alignmentBar.add(leftJustifyButton);

    centerJustifyButton.setIcon(Icons.stock_text_align_center.getImageIcon());
    centerJustifyButton.setToolTipText("Center");
    centerJustifyButton.setBorder(new EtchedBorder());
    centerJustifyButton.addActionListener(this::centerJustifyButtonActionPerformed);

    alignmentBar.add(centerJustifyButton);

    rightJustifyButton.setIcon(Icons.stock_text_align_right.getImageIcon());
    rightJustifyButton.setToolTipText("Right Justify");
    rightJustifyButton.setBorder(new EtchedBorder());
    rightJustifyButton.addActionListener(this::rightJustifyButtonActionPerformed);

    alignmentBar.add(rightJustifyButton);

    jPanel2.add(alignmentBar);

    jPanel1.add(jPanel2, java.awt.BorderLayout.NORTH);

    filePane.setLayout(new BoxLayout(filePane, BoxLayout.X_AXIS));

    fileLeft.setText("<");
    fileLeft.setBorder(new EtchedBorder());
    fileLeft.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileLeftActionPerformed();
        }
    });

    filePane.add(fileLeft);

    fileRight.setText(">");
    fileRight.setBorder(new EtchedBorder());
    fileRight.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            fileRightActionPerformed();
        }
    });

    filePane.add(fileRight);

    filePane.add(filesBar);

    jPanel1.add(filePane, java.awt.BorderLayout.SOUTH);

    jSplitPane1.setRightComponent(jPanel1);

    add(jSplitPane1, java.awt.BorderLayout.CENTER);
}

From source file:tufts.vue.ui.InspectorPane.java

private static JComponent buildSummary(final Resource r, final MetaMap data) {
    final JTextPane htmlText = new JTextPane();
    htmlText.setEditable(false);/*from  w  w w.j  a v a 2 s  .c o m*/
    htmlText.setContentType("text/html");
    htmlText.setName("description:" + r);
    htmlText.addHyperlinkListener(DefaultHyperlinkListener);

    //final MetaMap data = (node == null ? null : node.getRawData());

    final String desc = findProperty(r, data, "descriptionSummary", "Description", "Summary");

    final String summary;

    if (desc != null || r == null) {

        summary = buildSummaryWithDescription(r, data, desc);
        if (summary == null || summary.length() == 0)
            return null;
        //htmlText.setText("No Description");// todo: should just hide panel
        else
            htmlText.setText(summary);

        if (DEBUG.DATA && data != null)
            data.put("$reformatted", "[" + summary + "]");

    } else { //if (r != null) {

        //------------------------------------------------------------------
        // No description was found: build a summary from just the Resource
        //------------------------------------------------------------------

        summary = buildSummaryFromResource(r);

        htmlText.setText(summary);

        if (DEBUG.DATA)
            r.setProperty("~reformatted", summary);

    }
    //else return null;

    // This must be done last.  Why this doesn't work up front I don't know: there
    // must be some other way...

    GUI.setDocumentFont(htmlText, GUI.ContentFace);

    return htmlText;

    //         if (loader != null) {
    //             // this not actually helping, other than we get to see "Loading..." before it hangs.
    //             final Thread _loader = loader;
    //             GUI.invokeAfterAWT(new Runnable() { public void run() {
    //                 _loader.start();
    //             }});
    //         }

}

From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularApplicationAboutDialog.java

/**
 * Inits the components.//  w  w  w. j a  v a  2 s  .  c  om
 */
public void initComponents() {

    // initialise gui
    mainPanel = new JPanel();
    JLabel logoLabel = new JLabel();
    logoLabel.setIcon(ImageUtils.getIcon(ImageUtils.IconName.LOGO_WHITE));
    logoLabel.setBackground(Color.WHITE);
    logoLabel.setOpaque(true);
    infoPane = new JTextPane();
    infoPane.setEditorKit(new HTMLEditorKit());
    infoPane.setText(createHTMLText());
    infoPane.setEditable(false);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(logoLabel, BorderLayout.NORTH);
    mainPanel.add(new JScrollPane(infoPane), BorderLayout.CENTER);
    createButtonsPanel();

    getContentPane().add(mainPanel);
    setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    setPreferredSize(new Dimension(400, 500));
    setResizable(true);
}