List of usage examples for javax.swing.text StyleContext StyleContext
public StyleContext()
From source file:pl.otros.logview.gui.MessageDetailListener.java
public MessageDetailListener(JTable table, JTextPane logDetailTextArea, LogDataTableModel dataTableModel, SimpleDateFormat dateFormat, PluginableElementsContainer<MessageFormatter> formattersContainer, PluginableElementsContainer<MessageColorizer> colorizersContainer) { super();/*from w ww. ja va2 s .co m*/ this.table = table; this.logDetailTextArea = logDetailTextArea; this.dataTableModel = dataTableModel; this.dateFormat = dateFormat; this.formattersContainer = formattersContainer; this.colorizersContainer = colorizersContainer; sc = new StyleContext(); defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); mainStyle = sc.addStyle("MainStyle", defaultStyle); StyleConstants.setFontSize(mainStyle, 12); StyleConstants.setForeground(mainStyle, Color.BLACK); classMethodStyle = sc.addStyle("classMethod", null); StyleConstants.setFontFamily(classMethodStyle, "monospaced"); StyleConstants.setForeground(classMethodStyle, Color.BLUE); noteStyle = sc.addStyle("note", mainStyle); StyleConstants.setFontFamily(noteStyle, "arial"); StyleConstants.setBold(noteStyle, true); formattersContainer.addListener(new PluginableElementEventListenerImplementation<MessageFormatter>()); colorizersContainer.addListener(new PluginableElementEventListenerImplementation<MessageColorizer>()); }
From source file:simplealbum.mvc.autocomplete.DController.java
void changeSeeker(Seeker seeker) { view.setTitle(seeker.getTitle());//from w w w . j a v a 2 s .co m // jTextPane.setText(""); TODO model.emptyList(); model.setSeeker(seeker); request(); List<String> colors = seeker.getColors(); styles = new Style[colors.size()]; StyleContext sc = new StyleContext(); for (int i = 0; i < colors.size(); i++) { styles[i] = sc.addStyle((String) colors.get(i), sc.getStyle(StyleContext.DEFAULT_STYLE)); StyleConstants.setForeground(styles[i], ColorUtils.getColorByName(colors.get(i))); StyleConstants.setBold(styles[i], true); } colorInputText(); filter = seeker.getFilter(); }
From source file:simplealbum.mvc.autocomplete.JTextPaneX.java
public JTextPaneX() { //Create the style array to show the colors // List<Object> colorList = CONFIGURATION.getList("ColorWord"); List<Object> colorList = null; styles = new Style[colorList.size()]; StyleContext sc = new StyleContext(); for (int i = 0; i < colorList.size(); i++) { styles[i] = sc.addStyle((String) colorList.get(i), sc.getStyle(StyleContext.DEFAULT_STYLE)); StyleConstants.setForeground(styles[i], ColorUtils.getColorByName((String) colorList.get(i))); StyleConstants.setBold(styles[i], true); }// w w w . j av a 2s .c o m //Get the document for adding a document listener dsd = (DefaultStyledDocument) getDocument(); dsd.addDocumentListener(new DocumentListenerTextPane()); //...and setting a document filter documentFilter = new MyDocumentFilter(); dsd.setDocumentFilter(documentFilter); }