本文整理匯總了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());
}
示例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());
}
示例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();
}
示例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);
}
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
}
示例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();
}
}
示例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;
}
示例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);
}
}
示例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;
}
}
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}