Package javax.swing.text

Examples of javax.swing.text.Style


    public static final String SYSTEMERR = "SystemErr";

        /** Creates the style context for the Console. */
        public ConsoleStyleContext() {
            super();
            Style root = getStyle(DEFAULT_STYLE);
            Style s = addStyle(CUSTOM, root);
            StyleConstants.setForeground(s, Color.BLACK);
            s = addStyle(SYSTEMOUT, root);
            StyleConstants.setForeground(s, Color.GREEN);
            s = addStyle(SYSTEMERR, root);
            StyleConstants.setForeground(s, Color.RED);
View Full Code Here


   * @param doc  StyledDocument for which styles are available
   */
  public void outputPaneStyles(StyledDocument doc)
  {
    StyleContext sctx = new StyleContext();
    Style def = sctx.getStyle(StyleContext.DEFAULT_STYLE);

    // Our basic style
    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(regular, "Arial");
    StyleConstants.setFontSize(regular, 12);

    // Style for input echoed in the window
    doc.addStyle("input", regular);
View Full Code Here

 
  private String styleKey(MatchResult.Status status, boolean highligthed) {
    return status.toString() + (highligthed ? "1" : "0");
  }
  private Style createStyle(MatchResult.Status status, boolean highligthed) {
    Style style = addStyle(styleKey(status, highligthed), null);
   
   
    // text color from status
   
    StyleConstants.setForeground(style, statusColors.get(status));
View Full Code Here

      createStyle(s, true);
      createStyle(s, false);
     
    }   
   
    Style style = addStyle(STYLE_SUPER, null);
    StyleConstants.setSuperscript(style, true);
   
    style = addStyle(STYLE_NORMAL, null);   
   
    setEditable(false);
View Full Code Here

                    } catch (NumberFormatException numberFormatException) {
                        // no need to change the foreground color
                    }
                }

                Style style = null;
                switch (responseLevel) {
                case 3:
                    style = statsDoc.getStyle(STYLE_REDIRECT);
                    break;
                case 4:
View Full Code Here

        stats.setBackground(backGround);

        // Add styles to use for different types of status messages
        StyledDocument doc = (StyledDocument) stats.getDocument();

        Style style = doc.addStyle(STYLE_REDIRECT, null);
        StyleConstants.setForeground(style, REDIRECT_COLOR);

        style = doc.addStyle(STYLE_CLIENT_ERROR, null);
        StyleConstants.setForeground(style, CLIENT_ERROR_COLOR);
View Full Code Here

  private int insertNotation(GameNode startNode, StyledDocument doc, int pos) {
    String s = "";
    int startPos = pos;
    boolean isContinuous = false;

    Style boldStyle, regularStyle, commentStyle, currentNodeStyle, nagStyle, grayStyle;
    grayStyle = notationTextPane.getStyle("gray");
    GameNode currentNode = history.getCurrentGameNode();
    if ((currentNode.isLeaf() && startNode == currentNode.getParent()) || startNode == currentNode) {
      // Make sure only the current variation is colored.
      boldStyle = notationTextPane.getStyle("bold");
      regularStyle = notationTextPane.getStyle("regular");
      commentStyle = notationTextPane.getStyle("comment");
      currentNodeStyle = notationTextPane.getStyle("currentNode");
      nagStyle = notationTextPane.getStyle("nag");
    } else {
      boldStyle = notationTextPane.getStyle("graybold");
      regularStyle = notationTextPane.getStyle("gray");
      commentStyle = notationTextPane.getStyle("gray");
      currentNodeStyle = notationTextPane.getStyle("gray");
      nagStyle = notationTextPane.getStyle("gray");
    }
    try {
      if (startNode.getComment().length() > 0) {
        s = startNode.getComment() + " ";
        commentStyle.addAttribute("gameNode", startNode);
        doc.insertString(pos, s, commentStyle);
        pos += s.length();
      }
      for (int n = 0; n < startNode.getChildCount(); n++) {
        GameNode node = (GameNode) startNode.getChildAt(n);
        boolean isCurrentNode = (node == currentNode);
        if (node.isLeaf()) {
          if (node.isWhiteMove()) {
            s = node.getFullMoveNumber() + ". ";
            boldStyle.addAttribute("gameNode", node);
            doc.insertString(pos, s, boldStyle);
            pos += s.length();
            s = node.getMove();
            Style style = isCurrentNode ? currentNodeStyle : regularStyle;
            style.addAttribute("gameNode", node);
            doc.insertString(pos, s, style);
            pos += s.length();
            isContinuous = true;
          } else {
            if (isContinuous) {
              s = node.getMove();
              Style style = isCurrentNode ? currentNodeStyle : regularStyle;
              style.addAttribute("gameNode", node);
              doc.insertString(pos, s, style);
              pos += s.length();
            } else {
              isContinuous = true;
              s = node.getFullMoveNumber() + "... ";
              boldStyle.addAttribute("gameNode", node);
              doc.insertString(pos, s, boldStyle);
              pos += s.length();
              s = node.getMove();
              Style style = isCurrentNode ? currentNodeStyle : regularStyle;
              style.addAttribute("gameNode", node);
              doc.insertString(pos, s, style);
              pos += s.length();
            }
          }
          if (node.hasComment()) {
View Full Code Here

    this.history = history;
    notationDocument = new javax.swing.text.DefaultStyledDocument();

    notationTextPane = new JTextPane(notationDocument);
    notationTextPane.setEditable(false);
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
    Style regular = notationTextPane.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");
    Style s = notationTextPane.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);
    s = notationTextPane.addStyle("bold", regular);
    StyleConstants.setBold(s, true);
    s = notationTextPane.addStyle("comment", regular);
    StyleConstants.setForeground(s, new Color(50, 50, 255));
View Full Code Here

    //    chatViewport.setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
    view = chatViewport.getView();
    add("Center", scrollPane);

    //Initialize some styles.
    Style def =
      StyleContext.getDefaultStyleContext().getStyle(
          StyleContext.DEFAULT_STYLE);
    Style regular = textPane.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = textPane.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);

    s = textPane.addStyle("annotation", regular);
    StyleConstants.setFontFamily(s, "Serif");
    StyleConstants.setBold(s, true);
View Full Code Here

    //add(spb);
    spa.setBorder(null);
  }

  private void addStyles(StyledDocument doc) {
    Style def = StyleContext.getDefaultStyleContext().
          getStyle(StyleContext.DEFAULT_STYLE);

    Style command = doc.addStyle("command", def);
    StyleConstants.setFontFamily(def, "SansSerif");
    StyleConstants.setForeground(command, Color.BLACK);

    //responses

    Style regular = doc.addStyle("regular", command);
    StyleConstants.setForeground(regular, Color.GRAY);

    Style s = doc.addStyle("tryagain", command);
    StyleConstants.setForeground(s, Color.ORANGE);

    s = doc.addStyle("pending", command);
    StyleConstants.setForeground(s, new Color(51, 102, 153));
View Full Code Here

TOP

Related Classes of javax.swing.text.Style

Copyright © 2018 www.massapicom. 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.