use of javax.swing.text.html.StyleSheet in project processing by processing.
the class DetailPanel method setTextStyle.
static void setTextStyle(JTextPane textPane, String fontSize) {
Document doc = textPane.getDocument();
if (doc instanceof HTMLDocument) {
HTMLDocument html = (HTMLDocument) doc;
StyleSheet stylesheet = html.getStyleSheet();
stylesheet.addRule("body { " + " margin: 0; padding: 0;" + " font-family: " + Toolkit.getSansFontName() + ", Arial, Helvetica, sans-serif;" + " font-size: 100%;" + "font-size: " + fontSize + "; " + "}");
}
}
use of javax.swing.text.html.StyleSheet in project processing by processing.
the class DetailPanel method setForegroundStyle.
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
/**
* Sets coloring based on whether installed or not;
* also makes ugly blue HTML links into the specified color (black).
*/
static void setForegroundStyle(JTextPane textPane, boolean installed, boolean selected) {
Document doc = textPane.getDocument();
if (doc instanceof HTMLDocument) {
HTMLDocument html = (HTMLDocument) doc;
StyleSheet stylesheet = html.getStyleSheet();
// slightly grayed when installed
String c = (installed && !selected) ? "#555555" : "#000000";
stylesheet.addRule("body { color:" + c + "; }");
stylesheet.addRule("a { color:" + c + "; }");
}
}
use of javax.swing.text.html.StyleSheet in project jdk8u_jdk by JetBrains.
the class Test6817933 method main.
public static void main(String[] args) throws Exception {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception exception) {
exception.printStackTrace();
// ignore test on non-Windows machines
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
StyleSheet css = new StyleSheet();
css.addRule(STYLE);
HTMLEditorKit kit = new HTMLEditorKit();
kit.setStyleSheet(css);
JFrame frame = new JFrame(STYLE);
frame.add(chooser = new JFileChooser());
frame.setSize(640, 480);
frame.setVisible(true);
}
});
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
toolkit.realSync(500);
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
try {
JToggleButton button = get(JToggleButton.class, get(WindowsPlacesBar.class, chooser));
int width = button.getWidth();
int height = button.getHeight() / 3;
Point point = new Point(0, height * 2);
SwingUtilities.convertPointToScreen(point, button);
width += point.x;
height += point.y;
int count = 0;
Robot robot = new Robot();
for (int x = point.x; x < width; x++) {
for (int y = point.y; y < height; y++) {
count += COLOR.equals(robot.getPixelColor(x, y)) ? -2 : 1;
}
}
if (count < 0) {
throw new Exception("TEST ERROR: a lot of red pixels");
}
} catch (Exception exception) {
throw new Error(exception);
} finally {
SwingUtilities.getWindowAncestor(chooser).dispose();
}
}
});
}
use of javax.swing.text.html.StyleSheet in project pcgen by PCGen.
the class ExtendedHTMLEditorKit method createDefaultDocument.
/* WACKY GERMAN CODE */
@Override
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;
}
use of javax.swing.text.html.StyleSheet in project intellij-community by JetBrains.
the class JBLabel method updateStyle.
private void updateStyle(@NotNull JEditorPane pane) {
EditorKit kit = pane.getEditorKit();
if (kit instanceof HTMLEditorKit) {
StyleSheet css = ((HTMLEditorKit) kit).getStyleSheet();
css.addRule("body, p {" + "color:#" + ColorUtil.toHex(getForeground()) + ";" + "font-family:" + getFont().getFamily() + ";" + "font-size:" + getFont().getSize() + "pt;" + "white-space:nowrap;}");
}
}
Aggregations