Fix problem with setForeground and setBackground
This commit is contained in:
		
							parent
							
								
									3ab2c13b4c
								
							
						
					
					
						commit
						8d1ce46d09
					
				| @ -18,6 +18,9 @@ import java.io.FileOutputStream; | |||||||
| import javax.swing.JTextPane; | import javax.swing.JTextPane; | ||||||
| import javax.swing.event.HyperlinkEvent; | import javax.swing.event.HyperlinkEvent; | ||||||
| import javax.swing.event.HyperlinkListener; | import javax.swing.event.HyperlinkListener; | ||||||
|  | import javax.swing.text.SimpleAttributeSet; | ||||||
|  | import javax.swing.text.StyleConstants; | ||||||
|  | import javax.swing.text.StyledDocument; | ||||||
| import javax.swing.JEditorPane; | import javax.swing.JEditorPane; | ||||||
| import javax.swing.JPanel; | import javax.swing.JPanel; | ||||||
| import javax.swing.JScrollPane; | import javax.swing.JScrollPane; | ||||||
| @ -188,6 +191,7 @@ public class DescriptionArea extends JScrollPane { | |||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 		}); | 		}); | ||||||
|  | 		setForeground(editorPane.getForeground()); | ||||||
| 		editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); | 		editorPane.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -206,11 +210,19 @@ public class DescriptionArea extends JScrollPane { | |||||||
| 	public void setBackground(Color color) { | 	public void setBackground(Color color) { | ||||||
| 		if (editorPane == null) return; | 		if (editorPane == null) return; | ||||||
| 		editorPane.setBackground(color); | 		editorPane.setBackground(color); | ||||||
|  | 		StyledDocument styledDocument = (StyledDocument) editorPane.getDocument(); | ||||||
|  | 		SimpleAttributeSet attributeSet = new SimpleAttributeSet(); | ||||||
|  | 		StyleConstants.setForeground(attributeSet, color); | ||||||
|  | 		styledDocument.setCharacterAttributes(0, styledDocument.getLength(), attributeSet, false); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public void setForeground(Color color) { | 	public void setForeground(Color color) { | ||||||
| 		if (editorPane == null) return; | 		if (editorPane == null) return; | ||||||
| 		editorPane.setForeground(color); | 		editorPane.setForeground(color); | ||||||
|  | 		StyledDocument styledDocument = (StyledDocument) editorPane.getDocument(); | ||||||
|  | 		SimpleAttributeSet attributeSet = new SimpleAttributeSet(); | ||||||
|  | 		StyleConstants.setForeground(attributeSet, color); | ||||||
|  | 		styledDocument.setCharacterAttributes(0, styledDocument.getLength(), attributeSet, false); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user