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


Java HTMLEditorKit类代码示例

本文整理汇总了Java中javax.swing.text.html.HTMLEditorKit的典型用法代码示例。如果您正苦于以下问题:Java HTMLEditorKit类的具体用法?Java HTMLEditorKit怎么用?Java HTMLEditorKit使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: actionPerformed

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
    String elName =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getName();
    /*
     * if ((elName.toUpperCase().equals("PRE")) ||
     * (elName.toUpperCase().equals("P-IMPLIED"))) {
     * editor.replaceSelection("\r"); return;
     */
    HTML.Tag tag = HTML.getTag(elName);
    if (elName.toUpperCase().equals("P-IMPLIED"))
        tag = HTML.Tag.IMPLIED;

    HTMLEditorKit.InsertHTMLTextAction hta =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertBR",
            "<br>",
            tag,
            HTML.Tag.BR);
    hta.actionPerformed(e);

    //insertHTML("<br>",editor.getCaretPosition());

}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:26,代码来源:HTMLEditor.java

示例2: ulActionB_actionPerformed

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public void ulActionB_actionPerformed(ActionEvent e) {
	String parentname =
		document
			.getParagraphElement(editor.getCaretPosition())
			.getParentElement()
			.getName();
	HTML.Tag parentTag = HTML.getTag(parentname);
	HTMLEditorKit.InsertHTMLTextAction ulAction =
		new HTMLEditorKit.InsertHTMLTextAction(
			"insertUL",
			"<ul><li></li></ul>",
			parentTag,
			HTML.Tag.UL);
	ulAction.actionPerformed(e);

}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:17,代码来源:HTMLEditor.java

示例3: actionPerformed

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
	String elName =
		document
			.getParagraphElement(editor.getCaretPosition())
			.getName();
	/*
	 * if ((elName.toUpperCase().equals("PRE")) ||
	 * (elName.toUpperCase().equals("P-IMPLIED"))) {
	 * editor.replaceSelection("\r"); return;
	 */
	HTML.Tag tag = HTML.getTag(elName);
	if (elName.toUpperCase().equals("P-IMPLIED"))
		tag = HTML.Tag.IMPLIED;

	HTMLEditorKit.InsertHTMLTextAction hta =
		new HTMLEditorKit.InsertHTMLTextAction(
			"insertBR",
			"<br>",
			tag,
			HTML.Tag.BR);
	hta.actionPerformed(e);

	//insertHTML("<br>",editor.getCaretPosition());

}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:26,代码来源:HTMLEditor.java

示例4: postInitComponents

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
private void postInitComponents () {
    this.jLabel2.setVisible(false);
    this.platformHome.setVisible(false);
    final Collection installFolders = platform.getInstallFolderURLs();
    if (platform.getInstallFolders().isEmpty() && installFolders.size() > 0) {
        this.jLabel2.setVisible(true);
        this.platformHome.setVisible(true);
        this.platformHome.setForeground(new Color (164,0,0));
        this.platformHome.setText (Utilities.toFile(URI.create(((URL)installFolders.iterator().next()).toExternalForm())).getAbsolutePath());
    }
    HTMLEditorKit htmlkit = new HTMLEditorKit();                
    StyleSheet css = htmlkit.getStyleSheet();
    if (css.getStyleSheets() == null) {
        StyleSheet css2 = new StyleSheet();
        Font f = jLabel2.getFont();
        css2.addRule(new StringBuffer("body { font-size: ").append(f.getSize()) // NOI18N
            .append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
        css2.addStyleSheet(css);
        htmlkit.setStyleSheet(css2);
    }
    jTextPane1.setEditorKit(htmlkit);        
    jTextPane1.setText(NbBundle.getMessage(BrokenPlatformCustomizer.class,"MSG_BrokenProject"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:BrokenPlatformCustomizer.java

示例5: postInitComponents

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
@Messages("LBL_TemplatesPanel_PleaseWait=Please wait...")
private void postInitComponents () {        
    Mnemonics.setLocalizedText(jLabel1, this.firer.getCategoriesName());
    Mnemonics.setLocalizedText(jLabel2, this.firer.getTemplatesName());
    this.description.setEditorKit(new HTMLEditorKit());
    description.putClientProperty( JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );

    // please wait node, see issue 52900
    pleaseWait = new AbstractNode (Children.LEAF) {
        @Override
        public Image getIcon (int ignore) {
            return PLEASE_WAIT_ICON;
        }
    };
    pleaseWait.setName(LBL_TemplatesPanel_PleaseWait());
    Children ch = new Children.Array ();
    ch.add (new Node[] {pleaseWait});
    final Node root = new AbstractNode (ch);
    SwingUtilities.invokeLater (new Runnable () {
        @Override public void run() {
            ((ExplorerProviderPanel)categoriesPanel).setRootNode (root);
        }
    });
    ((ExplorerProviderPanel)projectsPanel).addDefaultActionListener( firer );
    description.addHyperlinkListener(new ClickHyperlinks());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:TemplatesPanelGUI.java

示例6: ExtendedHTMLEditorKit

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public ExtendedHTMLEditorKit() {
	styleSheet = new StyleSheet();
	try {
		InputStream is = HTMLEditorKit.class.getResourceAsStream(DEFAULT_CSS);
		Reader r = new BufferedReader(new InputStreamReader(is, "ISO-8859-1"));
		styleSheet.loadRules(r, null);
		r.close();
	} catch (Exception e) {
		// LogService.getRoot().log(Level.WARNING, "Cannot install stylesheet: "+e, e);
		LogService.getRoot().log(
				Level.WARNING,
				I18N.getMessage(LogService.getRoot().getResourceBundle(),
						"com.rapidminer.gui.tools.ExtendedHTMLEditorKit.installing_stylesheet_error", e), e);
		// on error we simply have no styles... the html
		// will look mighty wrong but still function.
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:18,代码来源:ExtendedHTMLEditorKit.java

示例7: AbstractLinkButton

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public AbstractLinkButton(final Action action, Color linkTextColor) {
	super("text/html", makeHTML(action));
	this.action = action;

	if (action == null) {
		throw new IllegalArgumentException("action must not be null!");
	}

	installDefaultStylesheet();
	setEditable(false);
	setOpaque(false);
	setToolTipText((String) action.getValue(Action.SHORT_DESCRIPTION));

	HTMLEditorKit htmlKit = (HTMLEditorKit) getEditorKit();
	String hexColor = String.format(SwingTools.getColorHexValue(linkTextColor));
	htmlKit.getStyleSheet().addRule("a {color:" + hexColor + ";}");

	makeHyperLinkListener(action);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:AbstractLinkButton.java

示例8: makeMainLabel

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
/**
 * Creates the main text representation of this result.
 *
 * @param text
 * @return
 */
private Component makeMainLabel(String text) {
	JEditorPane label = new ExtendedHTMLJEditorPane("text/html", text);
	StyleSheet css = ((HTMLEditorKit) label.getEditorKit()).getStyleSheet();
	css.addRule("body {font-family:Sans;font-size:11pt}");
	css.addRule("h3 {margin:0; padding:0}");
	css.addRule("h4 {margin-bottom:0; margin-top:1ex; padding:0}");
	css.addRule("p  {margin-top:0; margin-bottom:1ex; padding:0}");
	css.addRule("ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
			+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/circle.png") + ")}");
	css.addRule("ul li {padding-bottom: 2px}");
	css.addRule("li.outPorts {padding-bottom: 0px}");
	css.addRule("ul li ul {margin-top:0; margin-bottom:1ex; list-style-image: url("
			+ getClass().getResource("/com/rapidminer/resources/icons/modern/help/line.png") + ")");
	css.addRule("li ul li {padding-bottom:0}");

	label.setEditable(false);

	JScrollPane pane = new JScrollPane(label);
	pane.setOpaque(false);
	pane.setBackground(null);
	pane.setBorder(null);
	return pane;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:30,代码来源:SingleResultOverview.java

示例9: olActionB_actionPerformed

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public void olActionB_actionPerformed(ActionEvent e) {
    String parentname =
        document
            .getParagraphElement(editor.getCaretPosition())
            .getParentElement()
            .getName();
    HTML.Tag parentTag = HTML.getTag(parentname);
    HTMLEditorKit.InsertHTMLTextAction olAction =
        new HTMLEditorKit.InsertHTMLTextAction(
            "insertOL",
            "<ol><li></li></ol>",
            parentTag,
            HTML.Tag.OL);
    olAction.actionPerformed(e);
    //removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
    list = true;
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:18,代码来源:HTMLEditor.java

示例10: insertDocument

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
protected void insertDocument(String msg) {
    try {
        HTMLEditorKit kit = (HTMLEditorKit) historyWidget.getEditorKit();
        HTMLDocument doc = (HTMLDocument) historyWidget.getDocument();
        // historyWidget.getDocument().insertString(len - offset,
        // trimMsg(msg), null);
        // Element root = doc.getDefaultRootElement();
        // Element body = root.getElement(1);
        // doc.insertBeforeEnd(body, msg);
        int pos = historyWidget.getCaretPosition();
        kit.insertHTML(doc, doc.getLength(), msg, 0, 0, null);
        historyWidget.setCaretPosition(scrollLock ? pos : doc.getLength());
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:Jamling,项目名称:SmartQQ4IntelliJ,代码行数:17,代码来源:IMChatConsole.java

示例11: olActionB_actionPerformed

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public void olActionB_actionPerformed(ActionEvent e) {
	String parentname =
		document
			.getParagraphElement(editor.getCaretPosition())
			.getParentElement()
			.getName();
	HTML.Tag parentTag = HTML.getTag(parentname);
	HTMLEditorKit.InsertHTMLTextAction olAction =
		new HTMLEditorKit.InsertHTMLTextAction(
			"insertOL",
			"<ol><li></li></ol>",
			parentTag,
			HTML.Tag.OL);
	olAction.actionPerformed(e);
	//removeIfEmpty(document.getParagraphElement(editor.getCaretPosition()-1));
	list = true;
}
 
开发者ID:ser316asu,项目名称:SER316-Aachen,代码行数:18,代码来源:HTMLEditor.java

示例12: PreviewView

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public PreviewView(ReportEditorView reportEditorView) {
    this.reportEditorView = reportEditorView;
    JScrollPane pane = new JScrollPane(editorPane);
    HTMLEditorKit kit = new HTMLEditorKit() {
        /**
         *
         */
        private static final long serialVersionUID = -8040272164224951314L;

        @Override
        public Document createDefaultDocument() {
            Document document = super.createDefaultDocument();
            document.putProperty("IgnoreCharsetDirective", true);
            return document;
        }
    };

    editorPane.setEditorKit(kit);
    editorPane.setEditable(false);
    this.add(pane, BorderLayout.CENTER);
}
 
开发者ID:Vitaliy-Yakovchuk,项目名称:ramus,代码行数:22,代码来源:PreviewView.java

示例13: main

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
public static void main(String[] args) {
    String htmlDoc = "<pre><p> </pre>";
    try {
        HTMLEditorKit kit = new HTMLEditorKit();
        Class c = Class.forName(
                "javax.swing.text.html.parser.ParserDelegator");
        HTMLEditorKit.Parser parser = (HTMLEditorKit.Parser) c.newInstance();
        HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument();
        HTMLEditorKit.ParserCallback htmlReader = doc.getReader(0);
        parser.parse(new CharArrayReader(htmlDoc.toCharArray()),
                htmlReader, true);
        htmlReader.flush();
        CharArrayWriter writer = new CharArrayWriter(1000);
        kit.write(writer, doc, 0, doc.getLength());
        writer.flush();
    } catch (Exception ex) {
        throw new RuntimeException("Test Failed " + ex);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:HTMLEditorKitWriterBug.java

示例14: createUIComponents

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
private void createUIComponents() {
    final Font font = UIManager.getFont("Label.font");
    final String bodyRule = "body { font-family: " + font.getFamily() + "; " + "font-size: " + font.getSize() + "pt; }";
    informationEditorPane = new JEditorPane();
    informationEditorPane.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) informationEditorPane.getDocument()).getStyleSheet().addRule(bodyRule);
    cvsEditorPane = new JEditorPane();
    cvsEditorPane.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) cvsEditorPane.getDocument()).getStyleSheet().addRule(bodyRule);
    jrebelEditorPane = new JEditorPane();
    jrebelEditorPane.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) jrebelEditorPane.getDocument()).getStyleSheet().addRule(bodyRule);
    jiraEditorPane = new JEditorPane();
    jiraEditorPane.setEditorKit(new HTMLEditorKit());
    ((HTMLDocument) jiraEditorPane.getDocument()).getStyleSheet().addRule(bodyRule);
    jiraEditorPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:InformationStep.java

示例15: createTaskInfoPanel

import javax.swing.text.html.HTMLEditorKit; //导入依赖的package包/类
@Override
public JComponent createTaskInfoPanel(Project project) {
  myTaskTextPane = new JTextPane();
  final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane);
  myTaskTextPane.setContentType(new HTMLEditorKit().getContentType());
  final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = editorColorsScheme.getEditorFontSize();
  final String fontName = editorColorsScheme.getEditorFontName();
  final Font font = new Font(fontName, Font.PLAIN, fontSize);
  String bodyRule = "body { font-family: " + font.getFamily() + "; " +
                    "font-size: " + font.getSize() + "pt; }" +
                    "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" +
                    "code {font-family: Courier; display: flex; float: left; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}";
  ((HTMLDocument)myTaskTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
  myTaskTextPane.setEditable(false);
  if (!UIUtil.isUnderDarcula()) {
    myTaskTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
  }
  myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10));
  myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  return scrollPane;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:25,代码来源:StudySwingToolWindow.java


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