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


Java HTML类代码示例

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


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

示例1: actionPerformed

import javax.swing.text.html.HTML; //导入依赖的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: actionPerformed

import javax.swing.text.html.HTML; //导入依赖的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

示例3: endTag

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Writes out an end tag for the element.
 *
 * @param elem    an Element
 * @exception IOException on any I/O error
 */
protected void endTag(Element elem) throws IOException {
    if (synthesizedElement(elem)) {
        return;
    }
    if (matchNameAttribute(elem.getAttributes(), HTML.Tag.PRE)) {
        inPre = false;
    }

    // write out end tags for item on stack
    closeOutUnwantedEmbeddedTags(elem.getAttributes());
    if (inContent) {
        if (!newlineOutputed) {
            writeLineSeparator();
        }
        newlineOutputed = false;
        inContent = false;
    }
    indent();
    write('<');
    write('/');
    write(elem.getName());
    write('>');
    writeLineSeparator();
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:31,代码来源:AltHTMLWriter.java

示例4: writeEmbeddedTags

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
 
开发者ID:ser316asu,项目名称:Wilmersdorf_SER316,代码行数:34,代码来源:AltHTMLWriter.java

示例5: actionPerformed

import javax.swing.text.html.HTML; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
	/*
	 * String elName =
	 * document.getParagraphElement(editor.getCaretPosition()).getName();
	 * HTML.Tag tag = HTML.getTag(elName); if
	 * (elName.toUpperCase().equals("P-IMPLIED")) tag =
	 * HTML.Tag.IMPLIED; HTMLEditorKit.InsertHTMLTextAction hta = new
	 * HTMLEditorKit.InsertHTMLTextAction("insertHR", " <hr> ", tag,
	 * HTML.Tag.HR);
	 */
	try {
		editorKit.insertHTML(
			document,
			editor.getCaretPosition(),
			"<hr>",
			0,
			0,
			HTML.Tag.HR);
	} catch (Exception ex) {
		ex.printStackTrace();
	}

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

示例6: handleStartTag

import javax.swing.text.html.HTML; //导入依赖的package包/类
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN)/* && where == IN_AREF */) {
                /*where = IN_AREF;*/
                // Ignore formatting
            }
            else {
                where = IN_BALAST;
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SearchThreadJdk12.java

示例7: handleStartTag

import javax.swing.text.html.HTML; //导入依赖的package包/类
public @Override void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {

            if ( t == HTML.Tag.DT ) {
                where = IN_DT;
                currentDii = null;
            }
            else if ( t == HTML.Tag.A && where == IN_DT ) {
                where = IN_AREF;
                Object val = a.getAttribute( HTML.Attribute.HREF );
                if ( val != null ) {
                    hrefVal = val.toString();
                    currentDii = new DocIndexItem( null, null, contextURL, hrefVal );
                }
            }
            else if ( t == HTML.Tag.A && (where == IN_DESCRIPTION_SUFFIX || where == IN_DESCRIPTION) ) {
                // Just ignore
            }
            else if ( (t == HTML.Tag.B || t == HTML.Tag.SPAN) && where == IN_AREF ) {
                where = IN_AREF;
            }
            else {
                where = IN_BALAST;
            }
        }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:SearchThreadJdk12_japan.java

示例8: setHRef

import javax.swing.text.html.HTML; //导入依赖的package包/类
public void setHRef(int pos, Document doc) {
    hRef = null;
    text = null;
    if (!(doc instanceof HTMLDocument)) {
        return;
    }
    HTMLDocument hdoc = (HTMLDocument) doc;
    Iterator iterator = hdoc.getIterator(HTML.Tag.A);
    while (iterator.isValid()) {
        if (pos >= iterator.getStartOffset() && pos < iterator.getEndOffset()) {
            AttributeSet attributes = iterator.getAttributes();
            if (attributes != null && attributes.getAttribute(HTML.Attribute.HREF) != null) {
                try {
                    text = hdoc.getText(iterator.getStartOffset(), iterator.getEndOffset() - iterator.getStartOffset()).trim();
                    hRef = attributes.getAttribute(HTML.Attribute.HREF).toString();
                    setIndexOfHrefAndText(hdoc, pos, text, hRef);
                } catch (BadLocationException e) {
                    e.printStackTrace();
                }
                return;
            }
        }
        iterator.next();
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:26,代码来源:REditorPane.java

示例9: olActionB_actionPerformed

import javax.swing.text.html.HTML; //导入依赖的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: convertToHTML40

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:22,代码来源:AltHTMLWriter.java

示例11: RectangleRegionContainment

import javax.swing.text.html.HTML; //导入依赖的package包/类
public RectangleRegionContainment(AttributeSet as) {
    int[] coords = extractCoords(as.getAttribute(HTML.Attribute.COORDS));

    percents = null;
    if (coords == null || coords.length != 4) {
        throw new RuntimeException("Unable to parse rectangular area");
    }
    else {
        x0 = coords[0];
        y0 = coords[1];
        x1 = coords[2];
        y1 = coords[3];
        if (x0 < 0 || y0 < 0 || x1 < 0 || y1 < 0) {
            percents = new float[4];
            lastWidth = lastHeight = -1;
            for (int counter = 0; counter < 4; counter++) {
                if (coords[counter] < 0) {
                    percents[counter] = Math.abs(coords[counter]) / 100.0f;
                }
                else {
                    percents[counter] = -1.0f;
                }
            }
        }
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Ingolstadt,代码行数:27,代码来源:AltHTMLWriter.java

示例12: if

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Determines the number of columns occupied by
 * the table cell represented by given element.
 */
/*protected*/ int getColumnsOccupied(View v) {
    // PENDING(prinz) this code should be in the html
    // paragraph, but we can't add api to enable it.
    AttributeSet a = v.getElement().getAttributes();
    String s = (String) a.getAttribute(HTML.Attribute.COLSPAN);
    if (s != null) {
        try {
            return Integer.parseInt(s);
        } catch (NumberFormatException nfe) {
            // fall through to one column
        }
    }

    return 1;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:TableView.java

示例13: olActionB_actionPerformed

import javax.swing.text.html.HTML; //导入依赖的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-Munich,代码行数:18,代码来源:HTMLEditor.java

示例14: writeOption

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Writes out the content of the Option form element.
 * @param option  an Option
 * @exception IOException on any I/O error
 *
 */
protected void writeOption(Option option) throws IOException {

    indent();
    write('<');
    write("option");
    // PENDING: should this be changed to check for null first?
    Object value = option.getAttributes().getAttribute(HTML.Attribute.VALUE);
    if (value != null) {
        write(" value=" + value);
    }
    if (option.isSelected()) {
        write(" selected");
    }
    write('>');
    if (option.getLabel() != null) {
        write(option.getLabel());
    }
    writeLineSeparator();
}
 
开发者ID:ser316asu,项目名称:Dahlem_SER316,代码行数:26,代码来源:AltHTMLWriter.java

示例15: isFrameSetDocument

import javax.swing.text.html.HTML; //导入依赖的package包/类
/**
 * Checks whether the document has frames. Only HTMLDocument might
 * have frames.
 *
 * @param document the {@code Document} to check
 * @return {@code true} if the {@code document} has frames
 */
private static boolean isFrameSetDocument(final Document document) {
    boolean ret = false;
    if (document instanceof HTMLDocument) {
        HTMLDocument htmlDocument = (HTMLDocument)document;
        if (htmlDocument.getIterator(HTML.Tag.FRAME).isValid()) {
            ret = true;
        }
    }
    return ret;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:TextComponentPrintable.java


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