| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,10 +38,10 @@ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | 40 | /** | |
| 41 | - * Window for modifying preferences. | ||
| 41 | + * Creates the window for modifying preferences. | ||
| 42 | 42 | */ | |
| 43 | 43 | public class PreferencesFrame { | |
| 44 | - JFrame dialog; | ||
| 44 | + JFrame frame; | ||
| 45 | 45 | GroupLayout layout; | |
| 46 | 46 | ||
| 47 | 47 | static final Integer[] FONT_SIZES = { 10, 12, 14, 18, 24, 36, 48 }; | |
@@ -83,18 +83,15 @@ public class PreferencesFrame { | |||
| 83 | 83 | ||
| 84 | 84 | public PreferencesFrame(Base base) { | |
| 85 | 85 | this.base = base; | |
| 86 | - //dialog = new JDialog(editor, "Preferences", true); | ||
| 87 | - dialog = new JFrame(Language.text("preferences")); | ||
| 88 | - Container pain = dialog.getContentPane(); | ||
| 86 | + | ||
| 87 | + frame = new JFrame(Language.text("preferences")); | ||
| 88 | + Container pain = frame.getContentPane(); | ||
| 89 | 89 | layout = new GroupLayout(pain); | |
| 90 | 90 | layout.setAutoCreateGaps(true); | |
| 91 | 91 | layout.setAutoCreateContainerGaps(true); | |
| 92 | 92 | ||
| 93 | 93 | pain.setLayout(layout); | |
| 94 | 94 | ||
| 95 | - // final int GUI_BETWEEN = Preferences.GUI_BETWEEN; | ||
| 96 | - // final int GUI_BIG = Preferences.GUI_BIG; | ||
| 97 | - // final int GUI_SMALL = Preferences.GUI_SMALL; | ||
| 98 | 95 | final int BUTTON_WIDTH = Preferences.BUTTON_WIDTH; | |
| 99 | 96 | final int BORDER = Base.isMacOS() ? 20 : 13; | |
| 100 | 97 | ||
@@ -115,13 +112,12 @@ public void actionPerformed(ActionEvent e) { | |||
| 115 | 112 | File dflt = new File(sketchbookLocationField.getText()); | |
| 116 | 113 | PApplet.selectFolder(Language.text("preferences.sketchbook_location.popup"), | |
| 117 | 114 | "sketchbookCallback", dflt, | |
| 118 | - PreferencesFrame.this, dialog); | ||
| 115 | + PreferencesFrame.this, frame); | ||
| 119 | 116 | } | |
| 120 | 117 | }); | |
| 121 | 118 | ||
| 122 | - // Language: [ English ] (requires restart of Processing) | ||
| 123 | - | ||
| 124 | 119 | ||
| 120 | + // Language: [ English ] (requires restart of Processing) | ||
| 125 | 121 | ||
| 126 | 122 | JLabel languageLabel = new JLabel(Language.text("preferences.language")+": "); | |
| 127 | 123 | languageSelectionBox = new JComboBox<String>(); | |
@@ -136,17 +132,10 @@ public void actionPerformed(ActionEvent e) { | |||
| 136 | 132 | } | |
| 137 | 133 | } | |
| 138 | 134 | languageSelectionBox.setModel(new DefaultComboBoxModel<String>(languageSelection)); | |
| 139 | - restartProcessingLabel = new JLabel(" ("+Language.text("preferences.requires_restart")+")"); | ||
| 135 | + restartProcessingLabel = new JLabel(" (" + Language.text("preferences.requires_restart") + ")"); | ||
| 140 | 136 | ||
| 141 | - // Editor and console font [ Source Code Pro ] | ||
| 142 | 137 | ||
| 143 | - // Nevermind on this for now.. Java doesn't seem to have a method for | ||
| 144 | - // enumerating only the fixed-width (monospaced) fonts. To do this | ||
| 145 | - // properly, we'd need to list the fonts, and compare the metrics of | ||
| 146 | - // i and M for each. When they're identical (and not degenerate), | ||
| 147 | - // we'd call that font fixed width. That's all a very expensive set of | ||
| 148 | - // operations, so it should also probably be cached between runs and | ||
| 149 | - // updated in the background. | ||
| 138 | + // Editor and console font [ Source Code Pro ] | ||
| 150 | 139 | ||
| 151 | 140 | JLabel fontLabel = new JLabel(Language.text("preferences.editor_and_console_font")+": "); | |
| 152 | 141 | final String fontTip = "<html>" + Language.text("preferences.editor_and_console_font.tip"); | |
@@ -157,6 +146,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 157 | 146 | //updateDisplayList(); | |
| 158 | 147 | fontSelectionBox.setEnabled(false); // don't enable until fonts are loaded | |
| 159 | 148 | ||
| 149 | + | ||
| 160 | 150 | // Editor font size [ 12 ] Console font size [ 10 ] | |
| 161 | 151 | ||
| 162 | 152 | JLabel fontSizelabel = new JLabel(Language.text("preferences.editor_font_size")+": "); | |
@@ -228,7 +218,7 @@ public void run() { | |||
| 228 | 218 | @Override public void changedUpdate(DocumentEvent e) {} | |
| 229 | 219 | }); | |
| 230 | 220 | ||
| 231 | - selector = new ColorChooser(dialog, false, | ||
| 221 | + selector = new ColorChooser(frame, false, | ||
| 232 | 222 | Preferences.getColor("run.present.bgcolor"), Language.text("prompt.ok"), | |
| 233 | 223 | new ActionListener() { | |
| 234 | 224 | @Override | |
@@ -244,12 +234,12 @@ public void actionPerformed(ActionEvent e) { | |||
| 244 | 234 | ||
| 245 | 235 | @Override | |
| 246 | 236 | public void mouseExited(MouseEvent e) { | |
| 247 | - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); | ||
| 237 | + frame.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); | ||
| 248 | 238 | } | |
| 249 | 239 | ||
| 250 | 240 | @Override | |
| 251 | 241 | public void mouseEntered(MouseEvent e) { | |
| 252 | - dialog.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); | ||
| 242 | + frame.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); | ||
| 253 | 243 | } | |
| 254 | 244 | ||
| 255 | 245 | @Override | |
@@ -260,57 +250,45 @@ public void mouseClicked(MouseEvent e) { | |||
| 260 | 250 | ||
| 261 | 251 | JLabel hashLabel = new JLabel("#"); | |
| 262 | 252 | ||
| 253 | + | ||
| 263 | 254 | // [ ] Use smooth text in editor window | |
| 264 | 255 | ||
| 265 | 256 | editorAntialiasBox = new JCheckBox(Language.text("preferences.use_smooth_text")); | |
| 266 | 257 | ||
| 258 | + | ||
| 267 | 259 | // [ ] Enable complex text input (for Japanese et al, requires restart) | |
| 268 | 260 | ||
| 269 | 261 | inputMethodBox = | |
| 270 | 262 | new JCheckBox(Language.text("preferences.enable_complex_text_input")+ | |
| 271 | 263 | " ("+Language.text("preferences.enable_complex_text_input_example")+ | |
| 272 | 264 | ", "+Language.text("preferences.requires_restart")+")"); | |
| 273 | 265 | ||
| 266 | + | ||
| 274 | 267 | // [ ] Continuously check for errors - PDE X | |
| 275 | 268 | ||
| 276 | 269 | errorCheckerBox = | |
| 277 | 270 | new JCheckBox(Language.text("preferences.continuously_check")); | |
| 278 | 271 | ||
| 272 | + | ||
| 279 | 273 | // [ ] Show Warnings - PDE X | |
| 280 | 274 | ||
| 281 | 275 | warningsCheckerBox = | |
| 282 | 276 | new JCheckBox(Language.text("preferences.show_warnings")); | |
| 283 | 277 | ||
| 278 | + | ||
| 284 | 279 | // [ ] Enable Code Completion - PDE X | |
| 285 | 280 | ||
| 286 | 281 | codeCompletionBox = | |
| 287 | 282 | new JCheckBox(Language.text("preferences.code_completion") + | |
| 288 | 283 | " Ctrl-" + Language.text("preferences.cmd_space")); | |
| 289 | - //// codeCompletionBox.addActionListener(new ActionListener() { | ||
| 290 | - //// | ||
| 291 | - //// @Override | ||
| 292 | - //// public void actionPerformed(ActionEvent e) { | ||
| 293 | - //// // Disble code completion trigger option if completion is disabled | ||
| 294 | - //// codeCompletionTriggerBox.setEnabled(codeCompletionBox.isSelected()); | ||
| 295 | - //// } | ||
| 296 | - //// }); | ||
| 297 | - | ||
| 298 | - //// int toggleLeft = left + d.width; | ||
| 299 | - | ||
| 300 | - //// [ ] Toggle Code Completion Trigger - PDE X. No longer needed (Manindra) | ||
| 301 | - | ||
| 302 | - //// codeCompletionTriggerBox = | ||
| 303 | - //// new JCheckBox(Language.text("preferences.trigger_with")+" Ctrl-"+Language.text("preferences.cmd_space")); | ||
| 304 | - //// pain.add(codeCompletionTriggerBox); | ||
| 305 | - //// d = codeCompletionTriggerBox.getPreferredSize(); | ||
| 306 | - //// codeCompletionTriggerBox.setBounds(toggleLeft, top, d.width + 10, d.height); | ||
| 307 | - //// right = Math.max(right, toggleLeft + d.width); | ||
| 284 | + | ||
| 308 | 285 | ||
| 309 | 286 | // [ ] Show import suggestions - PDE X | |
| 310 | 287 | ||
| 311 | 288 | importSuggestionsBox = | |
| 312 | 289 | new JCheckBox(Language.text("preferences.suggest_imports")); | |
| 313 | 290 | ||
| 291 | + | ||
| 314 | 292 | // [ ] Increase maximum available memory to [______] MB | |
| 315 | 293 | ||
| 316 | 294 | memoryOverrideBox = new JCheckBox(Language.text("preferences.increase_max_memory")+": "); | |
@@ -323,16 +301,19 @@ public void stateChanged(ChangeEvent e) { | |||
| 323 | 301 | }); | |
| 324 | 302 | JLabel mbLabel = new JLabel("MB"); | |
| 325 | 303 | ||
| 304 | + | ||
| 326 | 305 | // [ ] Delete previous application folder on export | |
| 327 | 306 | ||
| 328 | 307 | deletePreviousBox = | |
| 329 | 308 | new JCheckBox(Language.text("preferences.delete_previous_folder_on_export")); | |
| 330 | 309 | ||
| 310 | + | ||
| 331 | 311 | // [ ] Check for updates on startup | |
| 332 | 312 | ||
| 333 | 313 | checkUpdatesBox = | |
| 334 | 314 | new JCheckBox(Language.text("preferences.check_for_updates_on_startup")); | |
| 335 | 315 | ||
| 316 | + | ||
| 336 | 317 | // Run sketches on display [ 1 ] | |
| 337 | 318 | ||
| 338 | 319 | JLabel displayLabel = new JLabel(Language.text("preferences.run_sketches_on_display")+": "); | |
@@ -347,6 +328,7 @@ public void stateChanged(ChangeEvent e) { | |||
| 347 | 328 | new JCheckBox(Language.text("preferences.automatically_associate_pde_files")); | |
| 348 | 329 | autoAssociateBox.setVisible(false); | |
| 349 | 330 | ||
| 331 | + | ||
| 350 | 332 | // More preferences are in the ... | |
| 351 | 333 | ||
| 352 | 334 | JLabel morePreferenceLabel = new JLabel(Language.text("preferences.file") + ":"); | |
@@ -373,6 +355,7 @@ public void mouseExited(MouseEvent e) { | |||
| 373 | 355 | JLabel preferenceHintLabel = new JLabel("(" + Language.text("preferences.file.hint") + ")"); | |
| 374 | 356 | preferenceHintLabel.setForeground(Color.gray); | |
| 375 | 357 | ||
| 358 | + | ||
| 376 | 359 | // [ OK ] [ Cancel ] | |
| 377 | 360 | ||
| 378 | 361 | okButton = new JButton(Preferences.PROMPT_OK); | |
@@ -506,7 +489,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 506 | 489 | } | |
| 507 | 490 | // closing the window is same as hitting cancel button | |
| 508 | 491 | ||
| 509 | - dialog.addWindowListener(new WindowAdapter() { | ||
| 492 | + frame.addWindowListener(new WindowAdapter() { | ||
| 510 | 493 | public void windowClosing(WindowEvent e) { | |
| 511 | 494 | disposeFrame(); | |
| 512 | 495 | } | |
@@ -519,11 +502,11 @@ public void actionPerformed(ActionEvent actionEvent) { | |||
| 519 | 502 | }; | |
| 520 | 503 | // finish up | |
| 521 | 504 | ||
| 522 | - Toolkit.registerWindowCloseKeys(dialog.getRootPane(), disposer); | ||
| 523 | - Toolkit.setIcon(dialog); | ||
| 524 | - dialog.setResizable(false); | ||
| 525 | - dialog.pack(); | ||
| 526 | - dialog.setLocationRelativeTo(null); | ||
| 505 | + Toolkit.registerWindowCloseKeys(frame.getRootPane(), disposer); | ||
| 506 | + Toolkit.setIcon(frame); | ||
| 507 | + frame.setResizable(false); | ||
| 508 | + frame.pack(); | ||
| 509 | + frame.setLocationRelativeTo(null); | ||
| 527 | 510 | ||
| 528 | 511 | // Workaround for OS X, which breaks the layout when these are set earlier | |
| 529 | 512 | // https://github.com/processing/processing/issues/3212 | |
@@ -545,26 +528,17 @@ public void keyPressed(KeyEvent e) { | |||
| 545 | 528 | } | |
| 546 | 529 | ||
| 547 | 530 | ||
| 531 | + /** Callback for the folder selector. */ | ||
| 548 | 532 | public void sketchbookCallback(File file) { | |
| 549 | - if (file != null) { | ||
| 533 | + if (file != null) { // null if cancel or closed | ||
| 550 | 534 | sketchbookLocationField.setText(file.getAbsolutePath()); | |
| 551 | 535 | } | |
| 552 | 536 | } | |
| 553 | 537 | ||
| 554 | 538 | ||
| 555 | - // public Dimension getPreferredSize() { | ||
| 556 | - // return new Dimension(wide, high); | ||
| 557 | - // } | ||
| 558 | - | ||
| 559 | - | ||
| 560 | - // ................................................................. | ||
| 561 | - | ||
| 562 | - | ||
| 563 | - /** | ||
| 564 | - * Close the window after an OK or Cancel. | ||
| 565 | - */ | ||
| 539 | + /** Close the window after an OK or Cancel. */ | ||
| 566 | 540 | protected void disposeFrame() { | |
| 567 | - dialog.dispose(); | ||
| 541 | + frame.dispose(); | ||
| 568 | 542 | } | |
| 569 | 543 | ||
| 570 | 544 | ||
@@ -726,21 +700,21 @@ public void run() { | |||
| 726 | 700 | } | |
| 727 | 701 | // The OK Button has to be set as the default button every time the | |
| 728 | 702 | // PrefWindow is to be displayed | |
| 729 | - dialog.getRootPane().setDefaultButton(okButton); | ||
| 703 | + frame.getRootPane().setDefaultButton(okButton); | ||
| 730 | 704 | ||
| 731 | 705 | // The pack is called again here second time to fix layout bugs | |
| 732 | 706 | // the bugs are not due to groupLayout but due to HTML rendering of components | |
| 733 | 707 | // more info can be found here -> https://netbeans.org/bugzilla/show_bug.cgi?id=79967 | |
| 734 | - dialog.pack(); | ||
| 708 | + frame.pack(); | ||
| 735 | 709 | ||
| 736 | - dialog.setVisible(true); | ||
| 710 | + frame.setVisible(true); | ||
| 737 | 711 | } | |
| 738 | 712 | ||
| 739 | 713 | ||
| 740 | 714 | /** | |
| 741 | 715 | * I have some ideas on how we could make Swing even more obtuse for the | |
| 742 | 716 | * most basic usage scenarios. Is there someone on the team I can contact? | |
| 743 | - * Oracle staffer, are you reading this? This could be your meal ticket. | ||
| 717 | + * Are you an Oracle staffer reading this? This could be your meal ticket. | ||
| 744 | 718 | */ | |
| 745 | 719 | static class FontNamer extends JLabel implements ListCellRenderer<Font> { | |
| 746 | 720 | public Component getListCellRendererComponent(JList<? extends Font> list, | |
@@ -776,15 +750,25 @@ public void run() { | |||
| 776 | 750 | ||
| 777 | 751 | void updateDisplayList() { | |
| 778 | 752 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); | |
| 779 | - displayCount = ge.getScreenDevices().length; | ||
| 780 | - // displaySelectionBox.removeAll(); | ||
| 753 | + GraphicsDevice defaultDevice = ge.getDefaultScreenDevice(); | ||
| 754 | + GraphicsDevice[] devices = ge.getScreenDevices(); | ||
| 755 | + | ||
| 756 | + displayCount = devices.length; | ||
| 781 | 757 | String[] items = new String[displayCount]; | |
| 782 | 758 | for (int i = 0; i < displayCount; i++) { | |
| 783 | - items[i] = String.valueOf(i + 1); | ||
| 784 | - // displaySelectionBox.add(String.valueOf(i + 1)); | ||
| 759 | + DisplayMode mode = devices[i].getDisplayMode(); | ||
| 760 | + String title = String.format("%d (%d \u2715 %d)", // or \u00d7? | ||
| 761 | + i + 1, mode.getWidth(), mode.getHeight()); | ||
| 762 | + if (devices[i] == defaultDevice) { | ||
| 763 | + title += " default"; | ||
| 764 | + } | ||
| 765 | + items[i] = title; | ||
| 785 | 766 | } | |
| 786 | - // PApplet.println(items); | ||
| 787 | 767 | displaySelectionBox.setModel(new DefaultComboBoxModel<String>(items)); | |
| 788 | - // displaySelectionBox = new JComboBox(items); | ||
| 768 | + | ||
| 769 | + // Disable it if you can't actually change the default display | ||
| 770 | + if (displayCount == 1) { | ||
| 771 | + displaySelectionBox.setEnabled(false); | ||
| 772 | + } | ||
| 789 | 773 | } | |
| 790 | 774 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> | |
| 2 | 2 | <classpath> | |
| 3 | 3 | <classpathentry kind="src" path="generated"/> | |
| 4 | - <classpathentry excluding="processing/mode/java/PresentMode.java" kind="src" path="src"/> | ||
| 4 | + <classpathentry kind="src" path="src"/> | ||
| 5 | 5 | <classpathentry kind="lib" path="mode/antlr.jar"/> | |
| 6 | 6 | <classpathentry kind="lib" path="mode/classpath-explorer-1.0.jar"/> | |
| 7 | 7 | <classpathentry kind="lib" path="mode/com.ibm.icu.jar"/> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments