本文整理匯總了Java中javax.swing.JEditorPane.getForeground方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.getForeground方法的具體用法?Java JEditorPane.getForeground怎麽用?Java JEditorPane.getForeground使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JEditorPane
的用法示例。
在下文中一共展示了JEditorPane.getForeground方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: BraceToolTip
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public BraceToolTip(JEditorPane editorPane, JEditorPane previewPane) {
this.previewPane = previewPane;
setLayout(new BorderLayout());
add(previewPane, BorderLayout.CENTER);
putClientProperty("tooltip-type", "fold-preview"); // Checked in NbToolTip
addGlyphGutter(previewPane);
editorPaneWidth = editorPane.getSize().width;
Color foreColor = previewPane.getForeground();
setBorder(new LineBorder(foreColor));
setOpaque(true);
}
示例2: loadArray
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public static Component loadArray(Object value) {
Component comp = null;
if (isViewableValue(value)) {
Object[] arr;
if (value instanceof Collection) {
arr = ((Collection<?>) value).toArray();
} else if (value instanceof Map) {
arr = ((Map<?,?>) value).entrySet().toArray();
} else if (value instanceof Object[]) {
arr = (Object[]) value;
} else {
int length = Array.getLength(value);
arr = new Object[length];
for (int i = 0; i < length; i++) {
arr[i] = Array.get(value, i);
}
}
JEditorPane arrayEditor = new JEditorPane();
arrayEditor.setContentType("text/html");
arrayEditor.setEditable(false);
Color evenRowColor = arrayEditor.getBackground();
int red = evenRowColor.getRed();
int green = evenRowColor.getGreen();
int blue = evenRowColor.getBlue();
String evenRowColorStr =
"rgb(" + red + "," + green + "," + blue + ")";
Color oddRowColor = new Color(
red < 20 ? red + 20 : red - 20,
green < 20 ? green + 20 : green - 20,
blue < 20 ? blue + 20 : blue - 20);
String oddRowColorStr =
"rgb(" + oddRowColor.getRed() + "," +
oddRowColor.getGreen() + "," +
oddRowColor.getBlue() + ")";
Color foreground = arrayEditor.getForeground();
String textColor = String.format("%06x",
foreground.getRGB() & 0xFFFFFF);
StringBuilder sb = new StringBuilder();
sb.append("<html><body text=#"+textColor+"><table width=\"100%\">");
for (int i = 0; i < arr.length; i++) {
if (i % 2 == 0) {
sb.append("<tr style=\"background-color: " +
evenRowColorStr + "\"><td><pre>" +
(arr[i] == null ?
arr[i] : htmlize(arr[i].toString())) +
"</pre></td></tr>");
} else {
sb.append("<tr style=\"background-color: " +
oddRowColorStr + "\"><td><pre>" +
(arr[i] == null ?
arr[i] : htmlize(arr[i].toString())) +
"</pre></td></tr>");
}
}
if (arr.length == 0) {
sb.append("<tr style=\"background-color: " +
evenRowColorStr + "\"><td></td></tr>");
}
sb.append("</table></body></html>");
arrayEditor.setText(sb.toString());
JScrollPane scrollp = new JScrollPane(arrayEditor);
comp = scrollp;
}
return comp;
}
示例3: loadArray
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public static Component loadArray(Object value) {
Component comp = null;
if (isViewableValue(value)) {
Object[] arr;
if (value instanceof Collection) {
arr = ((Collection<?>) value).toArray();
} else if (value instanceof Map) {
arr = ((Map<?,?>) value).entrySet().toArray();
} else if (value instanceof Object[]) {
arr = (Object[]) value;
} else {
int length = Array.getLength(value);
arr = new Object[length];
for (int i = 0; i < length; i++) {
arr[i] = Array.get(value, i);
}
}
JEditorPane arrayEditor = new JEditorPane();
arrayEditor.setContentType("text/html");
arrayEditor.setEditable(false);
Color evenRowColor = arrayEditor.getBackground();
int red = evenRowColor.getRed();
int green = evenRowColor.getGreen();
int blue = evenRowColor.getBlue();
String evenRowColorStr =
"rgb(" + red + "," + green + "," + blue + ")";
Color oddRowColor = new Color(
red < 20 ? red + 20 : red - 20,
green < 20 ? green + 20 : green - 20,
blue < 20 ? blue + 20 : blue - 20);
String oddRowColorStr =
"rgb(" + oddRowColor.getRed() + "," +
oddRowColor.getGreen() + "," +
oddRowColor.getBlue() + ")";
Color foreground = arrayEditor.getForeground();
String textColor = String.format("%06x",
foreground.getRGB() & 0xFFFFFF);
StringBuilder sb = new StringBuilder();
sb.append("<html><body text=#").append(textColor).append("><table width=\"100%\">");
for (int i = 0; i < arr.length; i++) {
if (i % 2 == 0) {
sb.append("<tr style=\"background-color: ")
.append(evenRowColorStr).append("\"><td><pre>")
.append(arr[i] == null ?
arr[i] : htmlize(arr[i].toString()))
.append("</pre></td></tr>");
} else {
sb.append("<tr style=\"background-color: ")
.append(oddRowColorStr).append("\"><td><pre>")
.append(arr[i] == null ?
arr[i] : htmlize(arr[i].toString()))
.append("</pre></td></tr>");
}
}
if (arr.length == 0) {
sb.append("<tr style=\"background-color: ")
.append(evenRowColorStr).append("\"><td></td></tr>");
}
sb.append("</table></body></html>");
arrayEditor.setText(sb.toString());
JScrollPane scrollp = new JScrollPane(arrayEditor);
comp = scrollp;
}
return comp;
}