Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1001526 // Swing: Courier New?

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (88L/1K/4K).

1  
!747
2  
3  
m {
4  
  p {
5  
    JFrame jf = new JFrame("Courier New?");
6  
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
7  
    Container cp = jf.getContentPane();
8  
9  
    JTextPane pane = new JTextPane();
10  
    
11  
    appendToTextPane(pane, Color.green, "Hello! \n");
12  
    appendToTextPane(pane, Color.blue, "World :)\n");
13  
    
14  
    cp.add(new JScrollPane(pane), BorderLayout.CENTER);
15  
16  
    jf.setSize(400, 300);
17  
    jf.setVisible(true);
18  
  }
19  
  
20  
  static void appendToTextPane(JTextPane pane, Color color, S text) ctex {
21  
    Document doc = pane.getStyledDocument();
22  
    SimpleAttributeSet set = new SimpleAttributeSet();
23  
    StyleConstants.setFontFamily(set, "Courier New");
24  
    StyleConstants.setBold(set, true);
25  
    StyleConstants.setFontSize(set, 14);
26  
    StyleConstants.setBackground(set, color);
27  
    doc.insertString(doc.getLength(), text, set);
28  
  }
29  
}

Author comment

Began life as a copy of #1001522

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, teubizvjbppd, tslmcundralx, tvejysmllsmz, vouqrxazstgt

Comments [hide]

ID Author/Program Comment Date
1136 stefan ...nnnope. Not on Linux anyway. Where's our pretty font? 2015-10-21 20:40:35

add comment

Snippet ID: #1001526
Snippet name: Swing: Courier New?
Eternal ID of this version: #1001526/1
Text MD5: f9d55af124e9eb2e024350354ceb14bc
Transpilation MD5: e16dd8bd24cf9e3a744c1b574a509cdb
Author: stefan
Category: javax
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-10-21 20:39:41
Source code size: 865 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 689 / 697
Referenced in: [show references]