本文整理匯總了Java中javax.swing.text.html.StyleSheet.addStyleSheet方法的典型用法代碼示例。如果您正苦於以下問題:Java StyleSheet.addStyleSheet方法的具體用法?Java StyleSheet.addStyleSheet怎麽用?Java StyleSheet.addStyleSheet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.html.StyleSheet
的用法示例。
在下文中一共展示了StyleSheet.addStyleSheet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: postInitComponents
import javax.swing.text.html.StyleSheet; //導入方法依賴的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"));
}
示例2: getHTMLEditorKit
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public static HTMLEditorKit getHTMLEditorKit(boolean noGapsBetweenParagraphs) {
Font font = getLabelFont();
@NonNls String family = !SystemInfo.isWindows && font != null ? font.getFamily() : "Tahoma";
int size = font != null ? font.getSize() : JBUI.scale(11);
String customCss = String.format("body, div, p { font-family: %s; font-size: %s; }", family, size);
if (noGapsBetweenParagraphs) {
customCss += " p { margin-top: 0; }";
}
final StyleSheet style = new StyleSheet();
style.addStyleSheet(isUnderDarcula() ? (StyleSheet)UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
style.addRule(customCss);
return new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return style;
}
};
}
示例3: createPackageDesignPrinciple
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
private JComponent createPackageDesignPrinciple(String path) {
JEditorPane text = new JEditorPane();
text.setContentType("text/html;charset=utf-8");
text.setEditable(false);
try {
StyleSheet ss = new StyleSheet();
StyleSheet s1 = new StyleSheet();
s1.importStyleSheet(new URL(null, "classpath:/culture/包的設計原則_files/style.css",
new ClassPathURLStreamHandler()));
ss.addStyleSheet(s1);
HTMLEditorKit kit = new HTMLEditorKit();
ss.addStyleSheet(kit.getStyleSheet());
kit.setStyleSheet(ss);
text.setEditorKit(kit);
text.setPage(new URL(null, "classpath:/culture/" + path, new ClassPathURLStreamHandler()));
text.setCaretPosition(0);
} catch (Exception e) {
e.printStackTrace();
}
return new JScrollPane(text);
}
示例4: setHTMLFontSize
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
private void setHTMLFontSize(JTextPane tp){
HTMLEditorKit ek;
try{
ek=(HTMLEditorKit)tp.getEditorKitForContentType("text/html");
}
catch (Exception e) {
return;
}
if(ek==null) return; //En las VMS antiguas no funciona bien
ek.setLinkCursor(new Cursor(Cursor.HAND_CURSOR));
StyleSheet css= getCssBase();
StyleSheet cssOriginal= ek.getStyleSheet();
String styleSize="body{font-size : "+
(int)(100+((getFontSizeSlider().getValue()-14)/48.)*100)+"%;}";
cssOriginal.addStyleSheet(css);
cssOriginal.addStyle(styleSize, cssOriginal.getRule("body"));
}
示例5: JeditorHtmlPanel
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public JeditorHtmlPanel(Document document) {
jEditorPane = new JEditorPane();
scrollPane = new JBScrollPane(jEditorPane);
// Setup the editor pane for rendering HTML.
File baseDir = new File("");
VirtualFile parent = FileDocumentManager.getInstance().getFile(document).getParent();
if (parent != null) {
// parent will be null if we use Language Injection and Fragment Editor
baseDir = new File(parent.getCanonicalPath());
}
final HTMLEditorKit kit = new AsciiDocEditorKit(baseDir);
// Create an AsciiDoc style, based on the default stylesheet supplied by UiUtil.getHTMLEditorKit()
// since it contains fix for incorrect styling of tooltips
final String cssFile = isDarcula() ? "darcula.css" : "preview.css";
final StyleSheet customStyle = loadStyleSheet(JeditorHtmlPanel.class.getResource(cssFile));
final StyleSheet style = UIUtil.getHTMLEditorKit().getStyleSheet();
style.addStyleSheet(customStyle);
kit.setStyleSheet(style);
//
jEditorPane.setEditorKit(kit);
jEditorPane.setEditable(false);
// use this to prevent scrolling to the end of the pane on setText()
((DefaultCaret)jEditorPane.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
}
示例6: getHTMLEditorKit
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public static HTMLEditorKit getHTMLEditorKit(boolean noGapsBetweenParagraphs) {
Font font = getLabelFont();
@NonNls String family = !SystemInfo.isWindows && font != null ? font.getFamily() : "Tahoma";
int size = font != null ? font.getSize() : JBUI.scale(11);
String customCss = String.format("body, div, p { font-family: %s; font-size: %s; }", family, size);
if (noGapsBetweenParagraphs) {
customCss += " p { margin-top: 0; }";
}
final StyleSheet style = new StyleSheet();
style.addStyleSheet(isUnderDarcula() ? (StyleSheet) UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
style.addRule(customCss);
return new HTMLEditorKit() {
@Override
public StyleSheet getStyleSheet() {
return style;
}
};
}
示例7: createDefaultDocument
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
@Override
public Document createDefaultDocument() {
StyleSheet styles = getStyleSheet();
StyleSheet ss = new StyleSheet();
ss.addStyleSheet(styles);
HTMLDocument doc = new CustomHTMLDocument(ss);
doc.setParser(getParser());
doc.setAsynchronousLoadPriority(4);
doc.setTokenThreshold(100);
return doc;
}
示例8: PanelBodyContainer
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
/** Creates new form InstallPanelContainer */
public PanelBodyContainer (String heading, String msg, JPanel bodyPanel) {
head = heading;
message = msg;
this.bodyPanel = bodyPanel;
initComponents ();
HTMLEditorKit htmlkit = new HTMLEditorKitEx();
// override the Swing default CSS to make the HTMLEditorKit use the
// same font as the rest of the UI.
// XXX the style sheet is shared by all HTMLEditorKits. We must
// detect if it has been tweaked by ourselves or someone else
// (code completion javadoc popup for example) and avoid doing the
// same thing again
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();
css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
}
tpPanelHeader.setEditorKit(htmlkit);
tpPanelHeader.putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
writeToHeader (head, message);
initBodyPanel ();
}
示例9: createDefaultDocument
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
/**
* Sets the async policy to flush everything in one chunk, and
* to not display unknown tags.
*/
public Document createDefaultDocument(Font defaultFont,
Color foreground) {
StyleSheet styles = getStyleSheet();
StyleSheet ss = new StyleSheet();
ss.addStyleSheet(styles);
BasicDocument doc = new BasicDocument(ss, defaultFont, foreground);
doc.setAsynchronousLoadPriority(Integer.MAX_VALUE);
doc.setPreservesUnknownTags(false);
return doc;
}
示例10: createDefaultDocument
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
@Override
public Document createDefaultDocument() {
StyleSheet styles = getStyleSheet();
StyleSheet ss = new ScaledStyleSheet();
ss.addStyleSheet(styles);
HTMLDocument doc = new HTMLDocument(ss);
doc.setParser(getParser());
doc.setAsynchronousLoadPriority(4);
doc.setTokenThreshold(100);
return doc;
}
示例11: createDefaultDocument
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public Document createDefaultDocument()
{
StyleSheet styles = getStyleSheet();
StyleSheet ss = new StyleSheet();
ss.addStyleSheet(styles);
ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
doc.setParser(getParser());
doc.setAsynchronousLoadPriority(4);
doc.setTokenThreshold(100);
return doc;
}
示例12: createDefaultDocument
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public Document createDefaultDocument() {
StyleSheet styles = getStyleSheet();
StyleSheet ss = new StyleSheet();
ss.addStyleSheet(styles);
ExtendedHTMLDocument doc = new ExtendedHTMLDocument(ss);
doc.setParser(getParser());
doc.setAsynchronousLoadPriority(4);
doc.setTokenThreshold(100);
return doc;
}
示例13: createStyleSheet
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public static StyleSheet createStyleSheet() {
StyleSheet style = new StyleSheet();
style.addStyleSheet(isUnderDarkTheme() && !isUnderGTKLookAndFeel() ? (StyleSheet)UIManager.getDefaults().get("StyledEditorKit.JBDefaultStyle") : DEFAULT_HTML_KIT_CSS);
style.addRule("code { font-size: 100%; }"); // small by Swing's default
style.addRule("small { font-size: small; }"); // x-small by Swing's default
return style;
}
示例14: DetailsPanel
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
public DetailsPanel() {
initComponents2();
HTMLEditorKit htmlkit = new HTMLEditorKitEx();
// override the Swing default CSS to make the HTMLEditorKit use the
// same font as the rest of the UI.
// XXX the style sheet is shared by all HTMLEditorKits. We must
// detect if it has been tweaked by ourselves or someone else
// (code completion javadoc popup for example) and avoid doing the
// same thing again
StyleSheet css = htmlkit.getStyleSheet();
if (css.getStyleSheets() == null) {
StyleSheet css2 = new StyleSheet();
Font f = new JList().getFont();
int size = f.getSize();
css2.addRule(new StringBuffer("body { font-size: ").append(size) // NOI18N
.append("; font-family: ").append(f.getName()).append("; }").toString()); // NOI18N
css2.addStyleSheet(css);
htmlkit.setStyleSheet(css2);
}
setEditorKit(htmlkit);
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent hlevt) {
if (EventType.ACTIVATED == hlevt.getEventType()) {
if (hlevt.getURL () != null) {
Utilities.showURL(hlevt.getURL());
}
}
}
});
setEditable(false);
setPreferredSize(new Dimension(300, 80));
RP.post(new Runnable() {
@Override
public void run() {
getAccessibleContext ().setAccessibleName (
NbBundle.getMessage (DetailsPanel.class, "ACN_DetailsPanel")); // NOI18N
}
});
putClientProperty( JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE );
}
示例15: getTraceListJComponent
import javax.swing.text.html.StyleSheet; //導入方法依賴的package包/類
private JComponent getTraceListJComponent() {
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
StyleSheet htmlStyleSheet = htmlEditorKit.getStyleSheet();
htmlStyleSheet.addStyleSheet(styleSheet);
JEditorPane traceListJEditorPane = new JEditorPane();
traceListJEditorPane.setEditable(false);
traceListJEditorPane.setContentType("text/html");
traceListJEditorPane.setEditorKitForContentType("text/html", htmlEditorKit);
StringBuffer htmlStringBuffer = new StringBuffer();
htmlStringBuffer.append("<H3 align='center'>" + LogEntryColumn.TRACELIST.getDisplayName() + "</H3>");
int columnIndex = logEntryColumnList.indexOf(LogEntryColumn.TRACELIST.getColumnId());
if (columnIndex != -1) {
List<String> logEntryValueList = logEntryData.getLogEntryValueList();
String traceListData = logEntryValueList.get(columnIndex);
if ((traceListData != null) && (!"".equals(traceListData)) && (!"NA".equals(traceListData))) {
String[] traceListArray = traceListData.split(";");
List<TableData> traceListDataList = new LinkedList<TableData>();
for (String traceList : traceListArray) {
String[] traceListNameValue = traceList.split(":", 2);
String nameColumn = traceListNameValue[0];
String valueColumn = null;
boolean isHREF = false;
if (traceListNameValue.length > 1) {
valueColumn = traceListNameValue[1];
}
TableData tableData = new TableData(nameColumn, valueColumn, isHREF);
traceListDataList.add(tableData);
}
String traceListTableStr = getTableHTMLStr("Trace List", traceListDataList, "border=\"1\"");
htmlStringBuffer.append(traceListTableStr);
traceListJEditorPane.setText(htmlStringBuffer.toString());
}
}
GridBagConstraints gbc1 = new GridBagConstraints();
gbc1.gridx = 0;
gbc1.gridy = 0;
gbc1.weightx = 1.0D;
gbc1.weighty = 1.0D;
gbc1.fill = GridBagConstraints.BOTH;
gbc1.anchor = GridBagConstraints.NORTHWEST;
gbc1.insets = new Insets(2, 15, 2, 2);
JPanel traceListJPanel = new JPanel();
traceListJPanel.setLayout(new GridBagLayout());
traceListJPanel.add(traceListJEditorPane, gbc1);
traceListJPanel.setBackground(Color.WHITE);
traceListJPanel.setBorder(BorderFactory.createLineBorder(Color.GRAY, 1));
JScrollPane traceListJScrollPane = new JScrollPane(traceListJPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
traceListJScrollPane.getVerticalScrollBar().setUnitIncrement(16);
return traceListJScrollPane;
}