/** Creates the error area component. */ private void initErrorArea() { SimpleAttributeSet attribs = new SimpleAttributeSet(); StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT); StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily()); StyleConstants.setForeground(attribs, Color.RED); errorPane.setParagraphAttributes(attribs, true); errorPane.setPreferredSize(new Dimension(100, 50)); errorPane.setMinimumSize(new Dimension(100, 50)); errorPane.setOpaque(false); }
private void loadStyles(StyledDocument doc) { Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); StyleConstants.setFontFamily(def, "Courier New"); // Add normal style Style normal = doc.addStyle("normal", def); StyleConstants.setForeground(def, Color.LIGHT_GRAY); // Add highlighted style from normal Style red = doc.addStyle("red", normal); StyleConstants.setForeground(red, Color.RED); }
public JConsole() { super(); setBackground(new Color(70, 70, 70)); setForeground(Color.WHITE); text = new MyJTextPane(); text.setAutoscrolls(true); final Font lFont = new Font("Monospaced", Font.PLAIN, 15); text.setText(""); text.setFont(lFont); text.setMargin(new Insets(5, 3, 5, 3)); text.addKeyListener(new MyKeyListener()); setViewportView(text); contextMenu = new JPopupMenu(); final ActionListener lActionListener = new MyActionListener(); contextMenu.add(new JMenuItem(CMD_CUT)).addActionListener(lActionListener); contextMenu.add(new JMenuItem(CMD_COPY)).addActionListener(lActionListener); contextMenu.add(new JMenuItem(CMD_PASTE)).addActionListener(lActionListener); text.addMouseListener(new MyMouseListener()); MutableAttributeSet attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.BLACK); attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.WHITE); attrOut = attr; attr = new SimpleAttributeSet(); StyleConstants.setForeground(attr, Color.RED); StyleConstants.setItalic(attr, true); StyleConstants.setBold(attr, true); attrError = attr; try { fromConsoleStream = new PipedOutputStream(); in = new PipedInputStream((PipedOutputStream) fromConsoleStream); final PipedOutputStream lOutPipe = new PipedOutputStream(); out = new PrintStream(lOutPipe); final PipedOutputStream lErrPipe = new PipedOutputStream(); err = new PrintStream(lErrPipe); } catch (IOException e) { e.printStackTrace(); } requestFocus(); }
private void initializeStyles() { errorStyle = doc.addStyle( "errorStyle", StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE)); errorStyleRed = doc.addStyle("errorStyleRed", errorStyle); StyleConstants.setForeground(errorStyleRed, Color.RED); errorStyleMono = doc.addStyle("errorStyleMono", errorStyle); StyleConstants.setFontFamily(errorStyleMono, "Monospaced"); }
private void highlightArea(int pos, int len, String col) { SimpleAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setForeground(attrs, getColour(col)); document.setCharacterAttributes(pos, len, attrs, true); }