1 +-- 58 lines: package com.acmemail.judah.cartesian_plane.components;---------------------------------------------------------------------------------------
59 * in the configured font
60 * (the "feedback window").
61 * </li>
62 * </ul>
63 * <p>
64 * The user can obtain a JPanel
65 * displaying the componentsd
66 * in a default configuration
67 * (see {@linkplain #getPanel()},
68 * or individual components can be retrieved
69 * and configured however the user wishes
70 * (see {@linkplain #getBoldToggle()},
71 * {@linkplain #getNameCombo()},
72 +-- 7 lines: * etc.)--------------------------------------------------------------------------------------------------------------------------------------
79 * of the elements.
80 * </p>
81 * @author Jack Straub
82 */
83 public class FontEditor
84 {
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
85 /** Text to display in feedback area. */
86 private static final String sampleString =
87 "<html>1313 Mockingbird Lane, Wisdom NB 68101</html>";
88
89 /** Text to display when a configuration property is invalid. */
90 private static final String errorString = "--ERROR--";
91 +-- 14 lines: * Color of feedback text when a configuration property is invalid. --------------------------------------------------------------------------
105 };
106 /** Drop-down list of supported font names. */
107 private final JComboBox<String> fontList =
108 new JComboBox<>( fontNames );
109 /** Bold face toggle. */
110 private final JCheckBox boldToggle =
111 new JCheckBox( "Bold" );
112 /** Slope face toggle. */
113 private final JCheckBox italicToggle =
114 new JCheckBox( "Italic" );
115 /** Spinner model for size selector */
116 private final SpinnerNumberModel sizeModel =
117 new SpinnerNumberModel( 10, 1, 40, 1 );
118 /** Size selector. */
119 private final JSpinner sizeEditor =
120 new JSpinner( sizeModel );
121 +-- 21 lines: *--------------------------------------------------------------------------------------------------------------------------------------------
142 boldToggle.addActionListener( e -> feedback.update() );
143 italicToggle.addActionListener( e -> feedback.update() );
144 fontList.addActionListener( e -> feedback.update() );
145 colorEditor.addActionListener( e -> feedback.update() );
146 sizeEditor.addChangeListener( e -> feedback.update() );
147
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------
148 feedback.update();
149 }
150
151 /**
152 * Returns a JPanel that incorporates
153 * all the FontEditor components.
154 +--269 lines: * -------------------------------------------------------------------------------------------------------------------------------------------
423 JPanel panel = new JPanel();
424 panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
425 panel.add( fontList );
426 panel.add( boldToggle );
427 panel.add( italicToggle );
428
429 JLabel sizeLabel = new JLabel( "Size" );
430 sizeLabel.setAlignmentX( JComponent.CENTER_ALIGNMENT );
431 sizeEditor.setAlignmentX( JComponent.CENTER_ALIGNMENT );
-------------------------------------------------------------------------------------------------------------------------------------------------------
432
433 JPanel sizePanel = new JPanel();
434 sizePanel.setLayout( new GridLayout( 1, 2, 3, 0 ) );
435 sizePanel.add( sizeEditor );
436 sizePanel.add( sizeLabel );
437 panel.add( sizePanel );
438 +-- 78 lines: JPanel colorPanel = new JPanel();---------------------------------------------------------------------------------------------------------
|
1 +-- 58 lines: package com.acmemail.judah.cartesian_plane.components;---------------------------------------------------------------------------------------
59 * in the configured font
60 * (the "feedback window").
61 * </li>
62 * </ul>
63 * <p>
64 * The user can obtain a JPanel
65 * displaying the component
66 * in a default configuration
67 * (see {@linkplain #getPanel()},
68 * or individual components can be retrieved
69 * and configured however the user wishes
70 * (see {@linkplain #getBoldToggle()},
71 * {@linkplain #getNameCombo()},
72 +-- 7 lines: * etc.)--------------------------------------------------------------------------------------------------------------------------------------
79 * of the elements.
80 * </p>
81 * @author Jack Straub
82 */
83 public class FontEditor
84 {
85 /** Label on the bold check box. */
86 public static final String BOLD_LABEL = "Bold";
87 /** Label on the bold italic box. */
88 public static final String ITALIC_LABEL = "Italic";
89 /** Name of the font-name component. */
90 public static final String NAME_LABEL = "Name";
91 /** Label on the font-size component. */
92 public static final String SIZE_LABEL = "Size";
93 /** Name of the feedback component. */
94 public static final String FEEDBACK_LABEL = "Feedback";
95
96 /** Text to display in feedback area. */
97 private static final String sampleString =
98 "<html>1313 Mockingbird Lane, Wisdom NB 68101</html>";
99
100 /** Text to display when a configuration property is invalid. */
101 private static final String errorString = "--ERROR--";
102 +-- 14 lines: * Color of feedback text when a configuration property is invalid. --------------------------------------------------------------------------
116 };
117 /** Drop-down list of supported font names. */
118 private final JComboBox<String> fontList =
119 new JComboBox<>( fontNames );
120 /** Bold face toggle. */
121 private final JCheckBox boldToggle =
122 new JCheckBox( BOLD_LABEL );
123 /** Slope face toggle. */
124 private final JCheckBox italicToggle =
125 new JCheckBox( ITALIC_LABEL );
126 /** Spinner model for size selector */
127 private final SpinnerNumberModel sizeModel =
128 new SpinnerNumberModel( 10, 1, 40, 1 );
129 /** Size selector. */
130 private final JSpinner sizeEditor =
131 new JSpinner( sizeModel );
132 +-- 21 lines: *--------------------------------------------------------------------------------------------------------------------------------------------
153 boldToggle.addActionListener( e -> feedback.update() );
154 italicToggle.addActionListener( e -> feedback.update() );
155 fontList.addActionListener( e -> feedback.update() );
156 colorEditor.addActionListener( e -> feedback.update() );
157 sizeEditor.addChangeListener( e -> feedback.update() );
158
159 boldToggle.setName( BOLD_LABEL );
160 italicToggle.setName( ITALIC_LABEL );
161
162 feedback.update();
163 }
164
165 /**
166 * Returns a JPanel that incorporates
167 * all the FontEditor components.
168 +--269 lines: * -------------------------------------------------------------------------------------------------------------------------------------------
437 JPanel panel = new JPanel();
438 panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS ) );
439 panel.add( fontList );
440 panel.add( boldToggle );
441 panel.add( italicToggle );
442
443 JLabel sizeLabel = new JLabel( SIZE_LABEL );
444 sizeLabel.setAlignmentX( JComponent.CENTER_ALIGNMENT );
445 sizeEditor.setAlignmentX( JComponent.CENTER_ALIGNMENT );
446 sizeEditor.setName( SIZE_LABEL );
447
448 JPanel sizePanel = new JPanel();
449 sizePanel.setLayout( new GridLayout( 1, 2, 3, 0 ) );
450 sizePanel.add( sizeEditor );
451 sizePanel.add( sizeLabel );
452 panel.add( sizePanel );
453 +-- 78 lines: JPanel colorPanel = new JPanel();---------------------------------------------------------------------------------------------------------
|