Java Code Examples for javax.swing.JEditorPane#getBackground()
The following examples show how to use
javax.swing.JEditorPane#getBackground() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LineNumberBorder.java From nextreports-designer with Apache License 2.0 | 6 votes |
/** * Constructs a new <code>LineNumberBorder</code>. * * @param scrollPane The scroll pane using this border as the viewport * border. * @param editorPane The text component for which line numbers will be * displayed. * @param numberColor The color to use for the line numbers. If * <code>null</code>, a default is used. */ public LineNumberBorder(JScrollPane scrollPane, JEditorPane editorPane, Color numberColor) { this.editorPane = editorPane; this.scrollPane = scrollPane; setForeground(numberColor != null ? numberColor : DEFAULT_FOREGROUND); Color bg = editorPane.getBackground(); setBackground(bg == null ? Color.WHITE : bg); editorPane.addCaretListener(this); editorPane.addPropertyChangeListener(this); scrollPane.getViewport().addChangeListener(this); editorPane.getDocument().addDocumentListener(this); currentLine = 1; setFont(null); // default font. insets = new Insets(0, 0, 0, 0); updateCellHeights(); updateCellWidths(); }
Example 2
Source File: OQLEditor.java From netbeans with Apache License 2.0 | 6 votes |
public void setEditable(boolean b) { JEditorPane editor = getEditor(); if (editor.isEditable() == b) return; editor.setEditable(b); if (b) { if (lastBgColor != null) editor.setBackground(lastBgColor); if (lastCaret != null) editor.setCaret(lastCaret); } else { lastBgColor = editor.getBackground(); lastCaret = editor.getCaret(); editor.setBackground(disabledBgColor); editor.setCaret(nullCaret); } }
Example 3
Source File: OQLEditor.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void setEditable(boolean b) { JEditorPane editor = getEditor(); if (editor.isEditable() == b) return; editor.setEditable(b); if (b) { if (lastBgColor != null) editor.setBackground(lastBgColor); if (lastCaret != null) editor.setCaret(lastCaret); } else { lastBgColor = editor.getBackground(); lastCaret = editor.getCaret(); editor.setBackground(disabledBgColor); editor.setCaret(nullCaret); } }
Example 4
Source File: XArrayDataViewer.java From hottub with GNU General Public License v2.0 | 4 votes |
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; }
Example 5
Source File: XArrayDataViewer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 6
Source File: XArrayDataViewer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 7
Source File: XArrayDataViewer.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 8
Source File: XArrayDataViewer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
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; }
Example 9
Source File: XArrayDataViewer.java From visualvm with GNU General Public License v2.0 | 4 votes |
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"); // NOI18N 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 + ")"; // NOI18N 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() + "," + // NOI18N oddRowColor.getGreen() + "," + // NOI18N oddRowColor.getBlue() + ")"; // NOI18N Color foreground = arrayEditor.getForeground(); String textColor = String.format("%06x", // NOI18N foreground.getRGB() & 0xFFFFFF); StringBuilder sb = new StringBuilder(); sb.append("<html><body text=#"+textColor+"><table width=\"100%\">"); // NOI18N for (int i = 0; i < arr.length; i++) { if (i % 2 == 0) { sb.append("<tr style=\"background-color: " + // NOI18N evenRowColorStr + "\"><td><pre>" + // NOI18N (arr[i] == null ? arr[i] : htmlize(arr[i].toString())) + "</pre></td></tr>"); // NOI18N } else { sb.append("<tr style=\"background-color: " + // NOI18N oddRowColorStr + "\"><td><pre>" + // NOI18N (arr[i] == null ? arr[i] : htmlize(arr[i].toString())) + "</pre></td></tr>"); // NOI18N } } if (arr.length == 0) { sb.append("<tr style=\"background-color: " + // NOI18N evenRowColorStr + "\"><td></td></tr>"); // NOI18N } sb.append("</table></body></html>"); // NOI18N arrayEditor.setText(sb.toString()); JScrollPane scrollp = new JScrollPane(arrayEditor); comp = scrollp; } return comp; }
Example 10
Source File: XArrayDataViewer.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
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; }
Example 11
Source File: XArrayDataViewer.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 12
Source File: XArrayDataViewer.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
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; }
Example 13
Source File: XArrayDataViewer.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
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; }
Example 14
Source File: XArrayDataViewer.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
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; }
Example 15
Source File: XArrayDataViewer.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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; }
Example 16
Source File: XArrayDataViewer.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
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; }
Example 17
Source File: XArrayDataViewer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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; }