!747 m { p { JFrame jf = new JFrame("Courier?"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container cp = jf.getContentPane(); JTextPane pane = new JTextPane(); appendToTextPane(pane, Color.green, "Hello! \n"); appendToTextPane(pane, Color.blue, "World :)\n"); cp.add(new JScrollPane(pane), BorderLayout.CENTER); jf.setSize(400, 300); jf.setVisible(true); } static void appendToTextPane(JTextPane pane, Color color, S text) ctex { Document doc = pane.getStyledDocument(); SimpleAttributeSet set = new SimpleAttributeSet(); StyleConstants.setFontFamily(set, "Courier"); StyleConstants.setBackground(set, color); doc.insertString(doc.getLength(), text, set); } }