Package javax.swing.text

Examples of javax.swing.text.StyleContext.addAttribute()


    StyleContext sc = new StyleContext();
    SimpleAttributeSet as = new SimpleAttributeSet();

    try
      {
        sc.addAttribute(as, "key", null);
        h.fail("StyleContext.addAttribute must not accept null value");
      }
    catch (NullPointerException ex)
      {
        h.check(true);
View Full Code Here


     * Non-mutable (<code>StyleContext.SmallAttributeSet</code>) is passed
     * as parameter.
     */
    public void testOptionSmallAttrSet() {
        AttributeContext context = new StyleContext();
        attrs = context.addAttribute(context.getEmptySet(), "key", "value");

        item = new Option(attrs);
        final AttributeSet itAttrs = item.getAttributes();
        assertFalse(itAttrs instanceof MutableAttributeSet);
        assertTrue(itAttrs instanceof StyleContext.SmallAttributeSet);
View Full Code Here

@SuppressWarnings("serial")
public class ColorPane extends JTextPane {
  public void append(Color c, String s) {
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, c);

    int len = getDocument().getLength(); // same value as getText().length();
    setCaretPosition(len); // place caret at the end (with no selection)
    setCharacterAttributes(aset, false);
    replaceSelection(s); // there is no selection, so inserts at caret
View Full Code Here

      // seems only to work when the text panel is editable
      {


        StyleContext sc = StyleContext.getDefaultStyleContext();
        AttributeSet attr_set = sc.addAttribute(SimpleAttributeSet.EMPTY,
          StyleConstants.Foreground, color);

        int len = jTextPane1.getDocument().getLength();
        jTextPane1.setCaretPosition(len); // place cursor at the end (with no selection)
        jTextPane1.setCharacterAttributes(attr_set, false);
View Full Code Here

     * Non-mutable (<code>StyleContext.SmallAttributeSet</code>) is passed
     * as parameter.
     */
    public void testOptionSmallAttrSet() {
        AttributeContext context = new StyleContext();
        attrs = context.addAttribute(context.getEmptySet(), "key", "value");

        item = new Option(attrs);
        final AttributeSet itAttrs = item.getAttributes();
        assertFalse(itAttrs instanceof MutableAttributeSet);
        assertTrue(itAttrs instanceof StyleContext.SmallAttributeSet);
View Full Code Here

  }
 
  AttributeSet scriptAttributeSet(boolean isStatus){
    if (!isStatus) return null;
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.DARK_GRAY);
    aset = sc.addAttribute(aset, StyleConstants.Bold, true);
    return aset;
  }
 
  private void displayScriptLine(String line, boolean isStatus){
View Full Code Here

 
  AttributeSet scriptAttributeSet(boolean isStatus){
    if (!isStatus) return null;
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.DARK_GRAY);
    aset = sc.addAttribute(aset, StyleConstants.Bold, true);
    return aset;
  }
 
  private void displayScriptLine(String line, boolean isStatus){
    StyledDocument doc = txtSqlOutput.getStyledDocument();
View Full Code Here

  }
 
  AttributeSet attributeSet(boolean iserror){
    if (!iserror) return null;
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.red);
    aset = sc.addAttribute(aset, StyleConstants.Bold, true);
    return aset;
  }
 
  void insertStatusMessage(String message, boolean isError){
View Full Code Here

 
  AttributeSet attributeSet(boolean iserror){
    if (!iserror) return null;
    StyleContext sc = StyleContext.getDefaultStyleContext();
    AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, Color.red);
    aset = sc.addAttribute(aset, StyleConstants.Bold, true);
    return aset;
  }
 
  void insertStatusMessage(String message, boolean isError){
    StyledDocument doc = txtStatus.getStyledDocument();
View Full Code Here

    }
   
    @Override
    public void addColoredRegion(final Interval region, final Color color) {
        StyleContext context = StyleContext.getDefaultStyleContext();
        final AttributeSet a = context.addAttribute(defaultStyle, StyleConstants.Foreground, color);
        EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                document.setCharacterAttributes(region.startsAt(), region.length(), a, true);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.