当前位置: 首页>>代码示例>>Java>>正文


Java JEditorPane.setFont方法代码示例

本文整理汇总了Java中javax.swing.JEditorPane.setFont方法的典型用法代码示例。如果您正苦于以下问题:Java JEditorPane.setFont方法的具体用法?Java JEditorPane.setFont怎么用?Java JEditorPane.setFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.setFont方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getErrorMessage

import javax.swing.JEditorPane; //导入方法依赖的package包/类
private JEditorPane getErrorMessage() {
    JEditorPane errorMsg = new JEditorPane();

    errorMsg.setEditable(false);
    errorMsg.setPreferredSize(new Dimension(700, 130));
    errorMsg.setBackground(null);
    // Text font
    Font font = new Font("Sans", Font.PLAIN, 6);
    errorMsg.setFont(font);
    // Handle HTML
    errorMsg.setEditorKit(new HTMLEditorKit());
    errorMsg.addHyperlinkListener(this);

    errorMsg.setText(ERROR_MSG);

    return errorMsg;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:18,代码来源:BugReportDialog.java

示例2: ResultPanelOutput

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
 * Creates a new instance of ResultPanelOutput
 */
ResultPanelOutput(ResultDisplayHandler displayHandler) {
    super();
    if (LOG) {
        System.out.println("ResultPanelOutput.<init>");
    }
    
    textPane = new JEditorPane();
    textPane.setFont(new Font("monospaced", Font.PLAIN, getFont().getSize()));
    textPane.setEditorKit(new OutputEditorKit());
    textPane.setEditable(false);
    textPane.getCaret().setVisible(true);
    textPane.getCaret().setBlinkRate(0);
    textPane.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    setViewportView(textPane);

    /*
     * On GTK L&F, background of the text pane is gray, even though it is
     * white on a JTextArea. The following is a hack to fix it:
     */
    Color background = UIManager.getColor("TextPane.background");   //NOI18N
    if (background != null) {
        textPane.setBackground(background);
    }

    doc = textPane.getDocument();

    AccessibleContext ac = textPane.getAccessibleContext();
    ac.setAccessibleName(NbBundle.getMessage(getClass(),
                                            "ACSN_OutputTextPane"));//NOI18N
    ac.setAccessibleDescription(NbBundle.getMessage(getClass(),
                                            "ACSD_OutputTextPane"));//NOI18N
    
    this.displayHandler = displayHandler;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:ResultPanelOutput.java

示例3: createComponent

import javax.swing.JEditorPane; //导入方法依赖的package包/类
public JComponent createComponent() {
    JPanel panel = new JPanel();
    JPanel console = new JPanel();
    panel.setLayout(new BorderLayout());

    final JEditorPane text = new JTextPane();

    text.setMargin(new Insets(8, 8, 8, 8));
    text.setCaretColor(new Color(0xa4, 0x00, 0x00));
    text.setBackground(new Color(0xf2, 0xf2, 0xf2));
    text.setForeground(new Color(0xa4, 0x00, 0x00));
    Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{
            "Monaco", "Andale Mono"});

    text.setFont(font);
    JScrollPane pane = new JScrollPane();
    pane.setViewportView(text);
    pane.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    panel.add(pane, BorderLayout.CENTER);
    console.validate();

    final TextAreaReadline tar = new TextAreaReadline(text,
            getString("Wellcom") + " \n\n");

    RubyInstanceConfig config = new RubyInstanceConfig() {
        {
            //setInput(tar.getInputStream());
            //setOutput(new PrintStream(tar.getOutputStream()));
            //setError(new PrintStream(tar.getOutputStream()));
            setObjectSpaceEnabled(false);
        }
    };
    Ruby runtime = Ruby.newInstance(config);
    tar.hookIntoRuntimeWithStreams(runtime);

    run(runtime);
    return panel;
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:39,代码来源:RubyConsole.java

示例4: buildDetail

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void buildDetail(String id, JPanel panel) {
    if (this.id.equals(id)) return;

    panel.setLayout(new MigLayout("wrap 1, center"));

    JLabel header = Utility.localizedHeaderLabel(Messages.nameKey(id),
        SwingConstants.LEADING, FontLibrary.FontSize.SMALL);
    panel.add(header, "align center, wrap 20");

    JEditorPane editorPane = new JEditorPane("text/html",
        Messages.getDescription(id)) {

        @Override
        public void paintComponent(Graphics g) {
            Graphics2D graphics2d = (Graphics2D) g;
            graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                                        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
            /*
            graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING,
                                        RenderingHints.VALUE_RENDER_QUALITY);
            graphics2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
                                        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
            */
            super.paintComponent(graphics2d);
        }
    };
    editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
                                 Boolean.TRUE);
    editorPane.setFont(panel.getFont());
    editorPane.setOpaque(false);
    editorPane.setEditable(false);
    editorPane.addHyperlinkListener(colopediaPanel);

    panel.add(editorPane, "width 95%");
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:40,代码来源:ConceptDetailPanel.java

示例5: install

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/** Set to a sane font (not proportional!). */
public @Override void install(JEditorPane pane) {
    super.install(pane);
    pane.setFont(new Font("Monospaced", Font.PLAIN, pane.getFont().getSize() + 1)); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:BaseDocument.java

示例6: createHtmlTextToolTip

import javax.swing.JEditorPane; //导入方法依赖的package包/类
private JEditorPane createHtmlTextToolTip() {
    class HtmlTextToolTip extends JEditorPane {
        public @Override void setSize(int width, int height) {
            Dimension prefSize = getPreferredSize();
            if (width >= prefSize.width) {
                width = prefSize.width;
            } else { // smaller available width
                super.setSize(width, 10000); // the height is unimportant
                prefSize = getPreferredSize(); // re-read new pref width
            }
            if (height >= prefSize.height) { // enough height
                height = prefSize.height;
            }
            super.setSize(width, height);
        }
        @Override
        public void setKeymap(Keymap map) {
            //#181722: keymaps are shared among components with the same UI
            //a default action will be set to the Keymap of this component below,
            //so it is necessary to use a Keymap that is not shared with other components
            super.setKeymap(addKeymap(null, map));
        }
    }

    JEditorPane tt = new HtmlTextToolTip();

    // setup tooltip keybindings
    filterBindings(tt.getActionMap());
    tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
    tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
    tt.getKeymap().setDefaultAction(NO_ACTION);

    Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
    Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
    Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N

    if (font != null) {
        tt.setFont(font);
    }
    if (foreColor != null) {
        tt.setForeground(foreColor);
    }
    if (backColor != null) {
        tt.setBackground(backColor);
    }

    tt.setOpaque(true);
    tt.setBorder(BorderFactory.createCompoundBorder(
        BorderFactory.createLineBorder(tt.getForeground()),
        BorderFactory.createEmptyBorder(0, 3, 0, 3)
    ));
    tt.setContentType("text/html"); //NOI18N

    return tt;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:ToolTipSupport.java

示例7: install

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/** Set to a sane font (not proportional!). */
@Override
public void install(JEditorPane pane) {
    super.install(pane);
    pane.setFont(new Font("Monospaced", Font.PLAIN, pane.getFont().getSize() + 1)); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:CloneableEditorSupport.java

示例8: testToolTipView

import javax.swing.JEditorPane; //导入方法依赖的package包/类
public void testToolTipView() throws Exception {
        loggingOn();
        RandomTestContainer container = createContainer();
        final JEditorPane pane = container.getInstance(JEditorPane.class);
        final Document doc = pane.getDocument();
        doc.putProperty("mimeType", "text/plain");
        RandomTestContainer.Context context = container.context();
//        ViewHierarchyRandomTesting.disableHighlighting(container);
        DocumentTesting.setSameThreadInvoke(context, true); // Do not post to EDT
        DocumentTesting.insert(context, 0, "abc\ndef\nghi\n");
        final JEditorPane[] toolTipPaneRef = new JEditorPane[1];
        final BadLocationException[] excRef = new BadLocationException[1];
        final JFrame[] toolTipFrameRef = new JFrame[1];
        Runnable tooltipRun = new Runnable() {
            @Override
            public void run() {
                JEditorPane toolTipPane = new JEditorPane();
                toolTipPaneRef[0] = toolTipPane;
                toolTipPane.setEditorKit(pane.getEditorKit());
                try {
                    Position startPos = doc.createPosition(4); // Line begining
                    Position endPos = doc.createPosition(8); // Line boundary too
                    toolTipPane.putClientProperty("document-view-start-position", startPos);
                    toolTipPane.putClientProperty("document-view-end-position", endPos);
                    toolTipPane.setDocument(doc);
                    JFrame toolTipFrame = new JFrame("ToolTip Frame");
                    toolTipFrameRef[0] = toolTipFrame;
                    toolTipFrame.getContentPane().add(new JScrollPane(toolTipPane));
                    toolTipFrame.setSize(100, 100);
                    toolTipFrame.setVisible(true);

                    doc.insertString(4, "o", null);
                    toolTipPane.setFont(new Font("Monospaced", Font.PLAIN, 22)); // Force VH rebuild
                    toolTipPane.modelToView(6);
                    doc.remove(3, 3);
                    doc.insertString(4, "ab", null);
                    
                    assert (endPos.getOffset() == 8);
                    doc.remove(7, 2);
                    toolTipPane.setFont(new Font("Monospaced", Font.PLAIN, 23)); // Force VH rebuild
                    toolTipPane.modelToView(6);

                } catch (BadLocationException ex) {
                    excRef[0] = ex;
                }

            }
        };
        SwingUtilities.invokeAndWait(tooltipRun);
        if (excRef[0] != null) {
            throw new IllegalStateException(excRef[0]);
        }

        DocumentTesting.setSameThreadInvoke(context, false);
        DocumentTesting.undo(context, 2);
        DocumentTesting.undo(context, 1);
        DocumentTesting.undo(context, 1);
        DocumentTesting.redo(context, 4);
        
        // Hide tooltip's frame
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                if (toolTipFrameRef[0] != null) {
                    toolTipFrameRef[0].setVisible(false);
                }
            }
        });
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:70,代码来源:JavaViewHierarchyRandomTest.java

示例9: enforceJEditorPaneFont

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
 * Enforces JEditorPane font.
 * Once the content type of a JEditorPane is set to text/html the font on the Pane starts to be managed by Swing.
 * This method forces using provided font.
 */
public static void enforceJEditorPaneFont(JEditorPane jEditorPane, Font font) {
	jEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	jEditorPane.setFont(font);
}
 
开发者ID:igr,项目名称:swingspy,代码行数:10,代码来源:SwingUtil.java


注:本文中的javax.swing.JEditorPane.setFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。