Frame for selecting which characters will be included with the font.
| 397 | * Frame for selecting which characters will be included with the font. |
| 398 | */ |
| 399 | class CharacterSelector extends JFrame { |
| 400 | JRadioButton defaultCharsButton; |
| 401 | JRadioButton allCharsButton; |
| 402 | JRadioButton unicodeCharsButton; |
| 403 | JScrollPane unicodeBlockScroller; |
| 404 | JList<JCheckBox> charsetList; |
| 405 | |
| 406 | |
| 407 | public CharacterSelector() { |
| 408 | super(Language.text("create_font.character_selector")); |
| 409 | |
| 410 | charsetList = new CheckBoxList(); |
| 411 | DefaultListModel<JCheckBox> model = new DefaultListModel<>(); |
| 412 | charsetList.setModel(model); |
| 413 | for (String item : blockNames) { |
| 414 | model.addElement(new JCheckBox(item)); |
| 415 | } |
| 416 | |
| 417 | unicodeBlockScroller = |
| 418 | new JScrollPane(charsetList, |
| 419 | ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, |
| 420 | ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); |
| 421 | |
| 422 | Container outer = getContentPane(); |
| 423 | outer.setLayout(new BorderLayout()); |
| 424 | |
| 425 | JPanel pain = new JPanel(); |
| 426 | pain.setBorder(new EmptyBorder(13, 13, 13, 13)); |
| 427 | outer.add(pain, BorderLayout.CENTER); |
| 428 | |
| 429 | pain.setLayout(new BoxLayout(pain, BoxLayout.Y_AXIS)); |
| 430 | |
| 431 | String labelText = Language.text("create_font.character_selector.label"); |
| 432 | JTextArea textarea = new JTextArea(labelText); |
| 433 | textarea.setBorder(new EmptyBorder(13, 8, 13, 8)); |
| 434 | textarea.setBackground(null); |
| 435 | textarea.setEditable(false); |
| 436 | textarea.setHighlighter(null); |
| 437 | textarea.setFont(new Font("Dialog", Font.PLAIN, 12)); |
| 438 | pain.add(textarea); |
| 439 | |
| 440 | ActionListener listener = |
| 441 | e -> charsetList.setEnabled(unicodeCharsButton.isSelected()); |
| 442 | defaultCharsButton = |
| 443 | new JRadioButton(Language.text("create_font.default_characters")); |
| 444 | allCharsButton = |
| 445 | new JRadioButton(Language.text("create_font.all_characters")); |
| 446 | unicodeCharsButton = |
| 447 | new JRadioButton(Language.text("create_font.specific_unicode")); |
| 448 | |
| 449 | defaultCharsButton.addActionListener(listener); |
| 450 | allCharsButton.addActionListener(listener); |
| 451 | unicodeCharsButton.addActionListener(listener); |
| 452 | |
| 453 | ButtonGroup group = new ButtonGroup(); |
| 454 | group.add(defaultCharsButton); |
| 455 | group.add(allCharsButton); |
| 456 | group.add(unicodeCharsButton); |