LexerNode(boolean isParent) { StyleContext sc = StyleContext.getDefaultStyleContext(); defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); }
StyleContext sc = StyleContext.getDefaultStyleContext(); AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);
setLocationRelativeTo(null); final StyleContext cont = StyleContext.getDefaultStyleContext(); final AttributeSet attr = cont.addAttribute(cont.getEmptySet(), StyleConstants.Foreground, Color.RED); final AttributeSet attrBlack = cont.addAttribute(cont.getEmptySet(), StyleConstants.Foreground, Color.BLACK);
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
private void init() { StyleContext styleContext = StyleContext.getDefaultStyleContext(); Style defaultStyle = styleContext.getStyle(StyleContext.DEFAULT_STYLE);
/** * Returns the specified font. * * @param family The font family. * @param style The style of font. * @param size The size of the font. * @return The font. */ private static Font getFont(String family, int style, int size) { // Use StyleContext to get a composite font for Asian glyphs. StyleContext sc = StyleContext.getDefaultStyleContext(); return sc.getFont(family, style, size); }
/** * Changes the "base font" for this syntax scheme. This is called by * <code>RSyntaxTextArea</code> when its font changes via * <code>setFont()</code>. This looks for tokens that use a derivative of * the text area's old font (but bolded and/or italicized) and make them * use the new font with those stylings instead. This is desirable because * most programmers prefer a single font to be used in their text editor, * but might want bold (say for keywords) or italics. * * @param old The old font of the text area. * @param font The new font of the text area. */ void changeBaseFont(Font old, Font font) { for (int i=0; i<styles.length; i++) { Style style = styles[i]; if (style!=null && style.font!=null) { if (style.font.getFamily().equals(old.getFamily()) && style.font.getSize()==old.getSize()) { int s = style.font.getStyle(); // Keep bold or italic StyleContext sc = StyleContext.getDefaultStyleContext(); style.font= sc.getFont(font.getFamily(), s, font.getSize()); } } } }
StyleContext sc = StyleContext.getDefaultStyleContext();
StyleContext sc = StyleContext.getDefaultStyleContext(); Font font = null;
StyleContext sc = StyleContext.getDefaultStyleContext(); Font boldFont = sc.getFont(baseFont.getFamily(), Font.BOLD, baseFont.getSize());
/** * Creates new form Card * * @param card * @param bigCard * @param dimension * @param gameId */ public Card(CardView card, BigCard bigCard, CardDimensions dimension, UUID gameId) { this.dimension = dimension; initComponents(); this.gameId = gameId; this.card = card; this.bigCard = bigCard; small = new BufferedImage(Config.dimensions.frameWidth, Config.dimensions.frameHeight, BufferedImage.TYPE_INT_RGB); backgroundName = getBackgroundName(); background = ImageHelper.getBackground(card, backgroundName); StyledDocument doc = text.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "arial"); Style s = doc.addStyle("small", regular); StyleConstants.setFontSize(s, 9); //addMouseListener(this); //text.addMouseListener(this); //addFocusListener(this); //addMouseMotionListener(this); //text.addMouseMotionListener(this); //addComponentListener(this); }
private void changeAttribute(Color color) { lastColor = color; StyleContext sc = StyleContext.getDefaultStyleContext(); aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color); } /**
LexerNode(boolean isParent) { StyleContext sc = StyleContext.getDefaultStyleContext(); defaultStyle = sc.getStyle(StyleContext.DEFAULT_STYLE); }
public void appendText(String s) { StyleContext sc = StyleContext.getDefaultStyleContext(); AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.BLACK); textField.setCharacterAttributes(aset, false); textField.replaceSelection(s); int len = doc.getLength(); textField.setCaretPosition(len); }
private void print(String s, TextColor c) { StyleContext sc = StyleContext.getDefaultStyleContext(); AttributeSet color = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c.getColor()); int len = textPane.getDocument().getLength(); textPane.setCaretPosition(len); textPane.setCharacterAttributes(color, false); textPane.replaceSelection(s); }
private void appendToPane(JTextPane tp, String msg, Color c) { StyleContext sc = StyleContext.getDefaultStyleContext(); AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c); aset = sc.addAttribute(aset, StyleConstants.FontFamily, "Lucida Console"); aset = sc.addAttribute(aset, StyleConstants.Alignment, StyleConstants.ALIGN_JUSTIFIED); int len = tp.getDocument().getLength(); tp.setCaretPosition(len); tp.setCharacterAttributes(aset, false); tp.replaceSelection(msg); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }
protected void addStylesToDocument(JTextPane outputArea) { StyledDocument doc = outputArea.getStyledDocument(); Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); Style regular = doc.addStyle("regular", def); StyleConstants.setFontFamily(def, "Monospaced"); promptStyle = doc.addStyle("prompt", regular); StyleConstants.setForeground(promptStyle, Color.BLUE); commandStyle = doc.addStyle("command", regular); StyleConstants.setForeground(commandStyle, Color.MAGENTA); outputStyle = doc.addStyle("output", regular); StyleConstants.setBold(outputStyle, true); }