⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stylesheet.html

📁 API資料大全
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Thu Apr 27 23:42:39 PDT 2000 --><TITLE>Java 2 Platform SE v1.3: Class  StyleSheet</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="class-use/StyleSheet.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup>&nbsp;2&nbsp;Platform<br>Std.&nbsp;Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../../javax/swing/text/html/ParagraphView.html"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../../javax/swing/text/html/StyleSheet.BoxPainter.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="StyleSheet.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY: &nbsp;<A HREF="#inner_class_summary">INNER</A>&nbsp;|&nbsp;<A HREF="#fields_inherited_from_class_javax.swing.text.StyleContext">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: &nbsp;FIELD&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.swing.text.html</FONT><BR>Class  StyleSheet</H2><PRE><A HREF="../../../../java/lang/Object.html">java.lang.Object</A>  |  +--<A HREF="../../../../javax/swing/text/StyleContext.html">javax.swing.text.StyleContext</A>        |        +--<B>javax.swing.text.html.StyleSheet</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../../javax/swing/text/AbstractDocument.AttributeContext.html">AbstractDocument.AttributeContext</A>, <A HREF="../../../../java/io/Serializable.html">Serializable</A></DD></DL><HR><DL><DT>public class <B>StyleSheet</B><DT>extends <A HREF="../../../../javax/swing/text/StyleContext.html">StyleContext</A></DL><P>Support for defining the visual characteristics of HTML views being rendered.  The StyleSheet is used to translate the HTML model into visual characteristics. This enables views to be customized by a look-and-feel, multiple views over the same model can be rendered differently, etc.  This can be thought of as a CSS rule repository.  The key for CSS attributes is an object of type CSS.Attribute.  The type of the value is up to the StyleSheet implementation, but the <code>toString</code> method is required to return a string representation of CSS value. <p> The primary entry point for HTML View implementations to get their attributes is the  <a href="#getViewAttributes">getViewAttributes</a> method.  This should be implemented to establish the desired policy used to associate attributes with the view. Each HTMLEditorKit (i.e. and therefore each associated JEditorPane) can have its own StyleSheet, but by default one sheet will be shared by all of the HTMLEditorKit instances. HTMLDocument instance can also have a StyleSheet, which holds the document-specific CSS specifications. <p> In order for Views to store less state and therefore be more lightweight, the StyleSheet can act as a factory for painters that handle some of the rendering tasks.  This allows implementations to determine what they want to cache and have the sharing potentially at the level that a selector is common to multiple views.  Since the StyleSheet may be used by views over multiple documents and typically the HTML attributes don't effect the selector being used, the potential for sharing is significant. <p> The rules are stored as named styles, and other information is stored to translate the context of an element to a  rule quickly.  The following code fragment will display the named styles, and therefore the CSS rules contained. <code><pre> &nbsp;  &nbsp; import java.util.*; &nbsp; import javax.swing.text.*; &nbsp; import javax.swing.text.html.*; &nbsp;  &nbsp; public class ShowStyles { &nbsp;  &nbsp;     public static void main(String[] args) { &nbsp; 	HTMLEditorKit kit = new HTMLEditorKit(); &nbsp; 	HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); &nbsp; 	StyleSheet styles = doc.getStyleSheet(); &nbsp; 	 &nbsp; 	Enumeration rules = styles.getStyleNames(); &nbsp; 	while (rules.hasMoreElements()) { &nbsp; 	    String name = (String) rules.nextElement(); &nbsp; 	    Style rule = styles.getStyle(name); &nbsp; 	    System.out.println(rule.toString()); &nbsp; 	} &nbsp; 	System.exit(0); &nbsp;     } &nbsp; } &nbsp;  </pre></code> <p> The semantics for when a CSS style should overide visual attributes defined by an element are not well defined. For example, the html <code>&lt;body bgcolor=red&gt;</code> makes the body have a red background. But if the html file also contains the CSS rule <code>body { background: blue }</code> it becomes less clear as to what color the background of the body should be. The current implemention gives visual attributes defined in the element the highest precedence, that is they are always checked before any styles. Therefore, in the previous example the background would have a red color as the body element defines the background color to be red. <p> As already mentioned this supports CSS. We don't support the full CSS spec. Refer to the javadoc of the CSS class to see what properties we support. The two major CSS parsing related concepts we do not currently support are pseudo selectors, such as <code>A:link { color: red }</code>, and the <code>important</code> modifier. <p> <font color="red">Note: This implementation is currently incomplete.  It can be replaced with alternative implementations that are complete.  Future versions of this class will provide better CSS support.</font><P><DL><DT><B>See Also: </B><DD><A HREF="../../../../serialized-form.html#javax.swing.text.html.StyleSheet">Serialized Form</A></DL><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><A NAME="inner_class_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Inner Class Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.BoxPainter.html">StyleSheet.BoxPainter</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class to carry out some of the duties of CSS formatting.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;class</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.ListPainter.html">StyleSheet.ListPainter</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Class to carry out some of the duties of CSS list formatting.</TD></TR></TABLE>&nbsp;<A NAME="inner_classes_inherited_from_class_javax.swing.text.StyleContext"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Inner classes inherited from class javax.swing.text.<A HREF="../../../../javax/swing/text/StyleContext.html">StyleContext</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../../javax/swing/text/StyleContext.NamedStyle.html">StyleContext.NamedStyle</A>, <A HREF="../../../../javax/swing/text/StyleContext.SmallAttributeSet.html">StyleContext.SmallAttributeSet</A></CODE></TD></TR></TABLE>&nbsp;<!-- =========== FIELD SUMMARY =========== --><A NAME="fields_inherited_from_class_javax.swing.text.StyleContext"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"><TD><B>Fields inherited from class javax.swing.text.<A HREF="../../../../javax/swing/text/StyleContext.html">StyleContext</A></B></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><A HREF="../../../../javax/swing/text/StyleContext.html#DEFAULT_STYLE">DEFAULT_STYLE</A></CODE></TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.html#StyleSheet()">StyleSheet</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Construct a StyleSheet</TD></TR></TABLE>&nbsp;<!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../../javax/swing/text/AttributeSet.html">AttributeSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.html#addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object)">addAttribute</A></B>(<A HREF="../../../../javax/swing/text/AttributeSet.html">AttributeSet</A>&nbsp;old,             <A HREF="../../../../java/lang/Object.html">Object</A>&nbsp;key,             <A HREF="../../../../java/lang/Object.html">Object</A>&nbsp;value)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds an attribute to the given set, and returns the new representative set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;<A HREF="../../../../javax/swing/text/AttributeSet.html">AttributeSet</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.html#addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet)">addAttributes</A></B>(<A HREF="../../../../javax/swing/text/AttributeSet.html">AttributeSet</A>&nbsp;old,              <A HREF="../../../../javax/swing/text/AttributeSet.html">AttributeSet</A>&nbsp;attr)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds a set of attributes to the element.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;void</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.html#addCSSAttribute(javax.swing.text.MutableAttributeSet, javax.swing.text.html.CSS.Attribute, java.lang.String)">addCSSAttribute</A></B>(<A HREF="../../../../javax/swing/text/MutableAttributeSet.html">MutableAttributeSet</A>&nbsp;attr,                <A HREF="../../../../javax/swing/text/html/CSS.Attribute.html">CSS.Attribute</A>&nbsp;key,                <A HREF="../../../../java/lang/String.html">String</A>&nbsp;value)</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Adds a CSS attribute to the given set.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>&nbsp;boolean</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../javax/swing/text/html/StyleSheet.html#addCSSAttributeFromHTML(javax.swing.text.MutableAttributeSet, javax.swing.text.html.CSS.Attribute, java.lang.String)">addCSSAttributeFromHTML</A></B>(<A HREF="../../../../javax/swing/text/MutableAttributeSet.html">MutableAttributeSet</A>&nbsp;attr,                        <A HREF="../../../../javax/swing/text/html/CSS.Attribute.html">CSS.Attribute</A>&nbsp;key,                        <A HREF="../../../../java/lang/String.html">String</A>&nbsp;value)</CODE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -