Example usage for javax.swing.text SimpleAttributeSet SimpleAttributeSet

List of usage examples for javax.swing.text SimpleAttributeSet SimpleAttributeSet

Introduction

In this page you can find the example usage for javax.swing.text SimpleAttributeSet SimpleAttributeSet.

Prototype

public SimpleAttributeSet() 

Source Link

Document

Creates a new attribute set.

Usage

From source file:coolmap.application.widget.impl.console.WidgetConsole.java

public void log(String message) {
    message = message.replaceAll("\n", "\n  ");
    message = "> " + message.trim();
    message += "\n";
    SimpleAttributeSet aset = new SimpleAttributeSet();
    StyleConstants.setForeground(aset, UI.colorBlack2);
    StyleConstants.setBold(aset, false);
    appendToPane(message, aset);// ww  w  .  j  a  va  2 s  .co m
}

From source file:com.eviware.soapui.support.log.JLogList.java

public JLogList(String title) {
    super(new BorderLayout());
    this.title = title;

    model = new LogListModel();
    logList = new JList(model);
    logList.setToolTipText(title);/*from ww w.  j  a  va 2 s.  c  om*/
    logList.setCellRenderer(new LogAreaCellRenderer());
    logList.setPrototypeCellValue("Testing 123");
    logList.setFixedCellWidth(-1);

    JPopupMenu listPopup = new JPopupMenu();
    listPopup.add(new ClearAction());
    enableAction = new EnableAction();
    enableMenuItem = new JCheckBoxMenuItem(enableAction);
    enableMenuItem.setSelected(true);
    listPopup.add(enableMenuItem);
    listPopup.addSeparator();
    listPopup.add(new CopyAction());
    listPopup.add(new SetMaxRowsAction());
    listPopup.addSeparator();
    listPopup.add(new ExportToFileAction());

    logList.setComponentPopupMenu(listPopup);

    setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    JScrollPane scrollPane = new JScrollPane(logList);
    UISupport.addPreviewCorner(scrollPane, true);
    add(scrollPane, BorderLayout.CENTER);

    requestAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(requestAttributes, Color.BLUE);

    responseAttributes = new SimpleAttributeSet();
    StyleConstants.setForeground(responseAttributes, Color.GREEN);

    try {
        maxRows = Long.parseLong(SoapUI.getSettings().getString("JLogList#" + title, "1000"));
    } catch (NumberFormatException e) {
    }
}

From source file:com.clank.launcher.swing.MessageLog.java

/**
 * Get an output stream using the give color.
 * /* ww w.  j a v a 2s. co  m*/
 * @param color color to use
 * @return output stream
 */
public ConsoleOutputStream getOutputStream(Color color) {
    SimpleAttributeSet attributes = new SimpleAttributeSet();
    StyleConstants.setForeground(attributes, color);
    return getOutputStream(attributes);
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean bold = (StyleConstants.isBold(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setBold(sas, bold);
        setCharacterAttributes(editor, sas, false);

    }/*from  w w w.  ja  v  a2  s  .  c om*/
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean italic = (StyleConstants.isItalic(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setItalic(sas, italic);
        setCharacterAttributes(editor, sas, false);
    }/*  w w w  .j av a  2 s. com*/
}

From source file:edu.scripps.fl.pubchem.xmltool.gui.GUIComponent.java

public JTextPane createJTextPane(String text) {
    JTextPane jtp = new JTextPane();
    jtp.setText(text);//  ww  w  .j a v  a  2 s  . c o  m
    SimpleAttributeSet underline = new SimpleAttributeSet();
    StyleConstants.setUnderline(underline, true);
    jtp.getStyledDocument().setCharacterAttributes(0, text.length(), underline, true);
    jtp.setEditable(false);
    jtp.setOpaque(false);
    jtp.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 10));
    jtp.setBorder(BorderFactory.createEmptyBorder());
    jtp.setForeground(Color.blue);
    jtp.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));

    return jtp;
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JTextPane editor = (JTextPane) getEditor(e);

    if (editor == null) {
        JOptionPane.showMessageDialog(null,
                "You need to select the editor pane before you can change the color.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return;/*  ww  w  . j  av  a2 s.c  o  m*/
    }
    int p0 = editor.getSelectionStart();
    StyledDocument doc = getStyledDocument(editor);
    Element paragraph = doc.getCharacterElement(p0);
    AttributeSet as = paragraph.getAttributes();
    fg = StyleConstants.getForeground(as);
    if (fg == null) {
        fg = Color.BLACK;
    }
    colorChooser.setColor(fg);

    JButton accept = new JButton("OK");
    accept.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            fg = colorChooser.getColor();
            dialog.dispose();
        }
    });

    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            cancelled = true;
            dialog.dispose();
        }
    });

    JButton none = new JButton("None");
    none.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            noChange = true;
            dialog.dispose();
        }
    });

    JPanel buttons = new JPanel();
    buttons.add(accept);
    buttons.add(none);
    buttons.add(cancel);

    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(colorChooser, BorderLayout.CENTER);
    dialog.getContentPane().add(buttons, BorderLayout.SOUTH);
    dialog.setModal(true);
    dialog.pack();
    dialog.setVisible(true);

    if (!cancelled) {

        MutableAttributeSet attr = null;
        if (editor != null) {
            if (fg != null && !noChange) {
                attr = new SimpleAttributeSet();
                StyleConstants.setForeground(attr, fg);
                setCharacterAttributes(editor, attr, false);
            }
        }
    } // end if color != null
    noChange = false;
    cancelled = false;
}

From source file:multiplayer.pong.client.LobbyFrame.java

private void appendMessage(String message, SimpleAttributeSet set) {
    // If no set of styles was passed, use the default
    if (set == null)
        set = new SimpleAttributeSet();
    Document doc = ta.getStyledDocument();
    try {/* w  w  w  .j  a v a  2 s .  co m*/
        doc.insertString(doc.getLength(), message, set);
    } catch (BadLocationException e) {
    }
}

From source file:au.org.ala.delta.ui.rtf.RTFWriter.java

private void closeOpenAttributes() throws IOException {
    SimpleAttributeSet emptyAttributes = new SimpleAttributeSet();
    for (AttributeHandler handler : _attributeHandlers.values()) {
        handler.handleAttribute(emptyAttributes);
    }/*from   w ww .  j  a  v  a 2  s.c  o  m*/
}

From source file:de.codesourcery.gittimelapse.MyFrame.java

protected final static SimpleAttributeSet createStyle(Color color) {
    SimpleAttributeSet result = new SimpleAttributeSet();
    StyleConstants.setBackground(result, color);
    return result;
}