當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.setMargin方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.setMargin方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.setMargin方法的具體用法?Java JEditorPane.setMargin怎麽用?Java JEditorPane.setMargin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.setMargin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureEditor

import javax.swing.JEditorPane; //導入方法依賴的package包/類
void configureEditor(JEditorPane editor) {
     final Dictionary<URL, Image> imageCache = ((SwingPlatform) document.getPlatform()).imageCache;
             
     editor.setEditorKit(new HTMLEditorKit() {
       @Override
       public javax.swing.text.Document createDefaultDocument() {
         HTMLDocument result = (HTMLDocument) super.createDefaultDocument();
             try {
               result.setBase(document.getUrl().toURL());
             } catch (MalformedURLException e) {
               e.printStackTrace();
             }
             result.putProperty("imageCache", imageCache);

		return result;
       }
     });
     editor.setMargin(new Insets(0,0,0,0));
     editor.setOpaque(false);
     editor.setEditable(false);
}
 
開發者ID:stefanhaustein,項目名稱:nativehtml,代碼行數:22,代碼來源:SwingTextComponent.java

示例2: 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


注:本文中的javax.swing.JEditorPane.setMargin方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。