Search in sources :

Example 11 with JTextPane

use of javax.swing.JTextPane in project JMRI by JMRI.

the class JLogoutputFrame method createMainFrame.

/**
     * createMainFrame
     * <p>
     * @return the initialized main frame
     */
private JFrame createMainFrame() {
    //        JPanel messagePane = createMessagePane();
    JFrame result = new JFrame();
    result.setPreferredSize(new Dimension(400, 300));
    JTextPane textPane = new JTextPane();
    myAppender = createAppender(textPane);
    textPane.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(400, 300));
    result.getContentPane().add(scrollPane, BorderLayout.CENTER);
    String fontFamily = "Courier New";
    Font font = new Font(fontFamily, Font.PLAIN, 1);
    //        Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    //        for ( int i = 0; i < fonts.length; i++ )
    //        {
    //            if ( fonts[i].getFamily().equals( fontFamily ) )
    //            {
    //                textPane.setFont( fonts[i] );
    //                break;
    //            } // if fonts[i].getFamily().equals( fontFamily )
    //        } // for i
    textPane.setFont(font);
    result.pack();
    result.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    return result;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextPane(javax.swing.JTextPane) JFrame(javax.swing.JFrame) Dimension(java.awt.Dimension) Font(java.awt.Font)

Example 12 with JTextPane

use of javax.swing.JTextPane in project jabref by JabRef.

the class MergeEntries method setupFieldRows.

private int setupFieldRows(JPanel mergePanel) {
    // For all fields in joint add a row and possibly radio buttons
    int row = 2;
    int maxLabelWidth = -1;
    for (String field : allFields) {
        JLabel label = boldFontLabel(new SentenceCaseFormatter().format(field));
        mergePanel.add(label, CELL_CONSTRAINTS.xy(1, (2 * row) - 1, "left, top"));
        Optional<String> leftString = leftEntry.getField(field);
        Optional<String> rightString = rightEntry.getField(field);
        if (leftString.equals(rightString)) {
            identicalFields.add(field);
        } else {
            differentFields.add(field);
        }
        maxLabelWidth = Math.max(maxLabelWidth, label.getPreferredSize().width);
        // Left text pane
        if (leftString.isPresent()) {
            JTextPane tf = new DiffHighlightingTextPane();
            mergePanel.add(tf, CELL_CONSTRAINTS.xy(3, (2 * row) - 1, "f, f"));
            leftTextPanes.put(field, tf);
        }
        // Add radio buttons if the two entries do not have identical fields
        if (identicalFields.contains(field)) {
            // Will only happen if both entries have the field and the content is identical
            mergedEntry.setField(field, leftString.get());
        } else {
            ButtonGroup group = new ButtonGroup();
            List<JRadioButton> list = new ArrayList<>(3);
            for (int k = 0; k < 3; k++) {
                JRadioButton button = new JRadioButton();
                group.add(button);
                mergePanel.add(button, CELL_CONSTRAINTS.xy(5 + (k * 2), (2 * row) - 1));
                button.addChangeListener(e -> updateAll());
                list.add(button);
            }
            radioButtons.put(field, list);
            if (leftString.isPresent()) {
                list.get(0).setSelected(true);
                if (!rightString.isPresent()) {
                    list.get(2).setEnabled(false);
                }
            } else {
                list.get(0).setEnabled(false);
                list.get(2).setSelected(true);
            }
        }
        // Right text pane
        if (rightString.isPresent()) {
            JTextPane tf = new DiffHighlightingTextPane();
            mergePanel.add(tf, CELL_CONSTRAINTS.xy(11, (2 * row) - 1, "f, f"));
            rightTextPanes.put(field, tf);
        }
        row++;
    }
    return maxLabelWidth;
}
Also used : JTextPane(javax.swing.JTextPane) JRadioButton(javax.swing.JRadioButton) ButtonGroup(javax.swing.ButtonGroup) DiffHighlightingTextPane(org.jabref.gui.util.component.DiffHighlightingTextPane) ArrayList(java.util.ArrayList) JLabel(javax.swing.JLabel) SentenceCaseFormatter(org.jabref.logic.formatter.casechanger.SentenceCaseFormatter)

Example 13 with JTextPane

use of javax.swing.JTextPane in project sling by apache.

the class Util method showStartupDialog.

static JTextPane showStartupDialog(final String title, final Dimension screenSize) {
    JTextPane text = new JTextPane();
    text.setText("...");
    JDialog d = new JDialog((Window) null);
    d.setTitle(title);
    d.add(text);
    d.setSize((int) screenSize.getWidth() / 2, 30);
    d.setLocation((int) screenSize.getWidth() / 4, (int) screenSize.getHeight() / 2 - 15);
    d.setVisible(true);
    return text;
}
Also used : JTextPane(javax.swing.JTextPane) JDialog(javax.swing.JDialog)

Example 14 with JTextPane

use of javax.swing.JTextPane in project jgnash by ccavanaugh.

the class PartialTwo method initComponents.

private void initComponents() {
    table = new PartialTable(qAcc);
    deleteButton = new JButton(rb.getString("Button.Delete"));
    helpPane = new JTextPane();
    helpPane.setEditable(false);
    helpPane.setEditorKit(new StyledEditorKit());
    helpPane.setBackground(getBackground());
    helpPane.setText(TextResource.getString("QifTwo.txt"));
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentShown(ComponentEvent evt) {
            refreshInfo();
        }
    });
    deleteButton.addActionListener(this);
}
Also used : StyledEditorKit(javax.swing.text.StyledEditorKit) JTextPane(javax.swing.JTextPane) JButton(javax.swing.JButton) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Example 15 with JTextPane

use of javax.swing.JTextPane in project GCViewer by chewiebug.

the class TextFileViewer method initComponents.

private void initComponents(String fileName) {
    super.initComponents();
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.addHyperlinkListener(new HyperlinkAdapter(this));
    try {
        textPane.setText(readFile(fileName));
        textPane.setCaretPosition(0);
    } catch (IOException e) {
        e.printStackTrace();
    }
    JScrollPane scrollPane = new JScrollPane(textPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    getContentPane().add("Center", scrollPane);
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextPane(javax.swing.JTextPane) IOException(java.io.IOException)

Aggregations

JTextPane (javax.swing.JTextPane)32 JScrollPane (javax.swing.JScrollPane)13 JButton (javax.swing.JButton)9 JLabel (javax.swing.JLabel)9 JPanel (javax.swing.JPanel)8 Color (java.awt.Color)6 Dimension (java.awt.Dimension)6 JRadioButton (javax.swing.JRadioButton)6 JTextField (javax.swing.JTextField)6 Insets (java.awt.Insets)4 IOException (java.io.IOException)4 JCheckBox (javax.swing.JCheckBox)4 JPasswordField (javax.swing.JPasswordField)4 JTable (javax.swing.JTable)4 BorderLayout (java.awt.BorderLayout)3 Component (java.awt.Component)3 FlowLayout (java.awt.FlowLayout)3 Font (java.awt.Font)3 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3