| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -98,8 +98,6 @@ public PreferencesFrame(Base base) { | |||
| 98 | 98 | ||
| 99 | 99 | pain.setLayout(layout); | |
| 100 | 100 | ||
| 101 | - final int BORDER = Toolkit.zoom(Platform.isMacOS() ? 20 : 13); | ||
| 102 | - | ||
| 103 | 101 | JLabel sketchbookLocationLabel; | |
| 104 | 102 | JLabel languageRestartLabel; | |
| 105 | 103 | JLabel zoomRestartLabel; | |
@@ -127,7 +125,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 127 | 125 | // Language: [ English ] (requires restart of Processing) | |
| 128 | 126 | ||
| 129 | 127 | JLabel languageLabel = new JLabel(Language.text("preferences.language")+": "); | |
| 130 | - languageSelectionBox = new JComboBox<String>(); | ||
| 128 | + languageSelectionBox = new JComboBox<>(); | ||
| 131 | 129 | ||
| 132 | 130 | Map<String, String> languages = Language.getLanguages(); | |
| 133 | 131 | String[] languageSelection = new String[languages.size()]; | |
@@ -138,7 +136,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 138 | 136 | languageSelection[i++] = lang.getValue(); | |
| 139 | 137 | } | |
| 140 | 138 | } | |
| 141 | - languageSelectionBox.setModel(new DefaultComboBoxModel<String>(languageSelection)); | ||
| 139 | + languageSelectionBox.setModel(new DefaultComboBoxModel<>(languageSelection)); | ||
| 142 | 140 | languageRestartLabel = new JLabel(" (" + Language.text("preferences.requires_restart") + ")"); | |
| 143 | 141 | ||
| 144 | 142 | ||
@@ -148,18 +146,18 @@ public void actionPerformed(ActionEvent e) { | |||
| 148 | 146 | final String fontTip = "<html>" + Language.text("preferences.editor_and_console_font.tip"); | |
| 149 | 147 | fontLabel.setToolTipText(fontTip); | |
| 150 | 148 | // get a wide name in there before getPreferredSize() is called | |
| 151 | - fontSelectionBox = new JComboBox<String>(new String[] { Toolkit.getMonoFontName() }); | ||
| 149 | + fontSelectionBox = new JComboBox<>(new String[] { Toolkit.getMonoFontName() }); | ||
| 152 | 150 | fontSelectionBox.setToolTipText(fontTip); | |
| 153 | 151 | fontSelectionBox.setEnabled(false); // don't enable until fonts are loaded | |
| 154 | 152 | ||
| 155 | 153 | ||
| 156 | 154 | // Editor font size [ 12 ] Console font size [ 10 ] | |
| 157 | 155 | ||
| 158 | 156 | JLabel fontSizelabel = new JLabel(Language.text("preferences.editor_font_size")+": "); | |
| 159 | - fontSizeField = new JComboBox<Integer>(FONT_SIZES); | ||
| 157 | + fontSizeField = new JComboBox<>(FONT_SIZES); | ||
| 160 | 158 | ||
| 161 | 159 | JLabel consoleFontSizeLabel = new JLabel(Language.text("preferences.console_font_size")+": "); | |
| 162 | - consoleFontSizeField = new JComboBox<Integer>(FONT_SIZES); | ||
| 160 | + consoleFontSizeField = new JComboBox<>(FONT_SIZES); | ||
| 163 | 161 | fontSizeField.setSelectedItem(Preferences.getFont("editor.font.size")); | |
| 164 | 162 | ||
| 165 | 163 | ||
@@ -175,8 +173,8 @@ public void stateChanged(ChangeEvent e) { | |||
| 175 | 173 | } | |
| 176 | 174 | }); | |
| 177 | 175 | ||
| 178 | - zoomSelectionBox = new JComboBox<String>(); | ||
| 179 | - zoomSelectionBox.setModel(new DefaultComboBoxModel<String>(Toolkit.zoomOptions.array())); | ||
| 176 | + zoomSelectionBox = new JComboBox<>(); | ||
| 177 | + zoomSelectionBox.setModel(new DefaultComboBoxModel<>(Toolkit.zoomOptions.array())); | ||
| 180 | 178 | zoomRestartLabel = new JLabel(" (" + Language.text("preferences.requires_restart") + ")"); | |
| 181 | 179 | ||
| 182 | 180 | // | |
@@ -349,7 +347,7 @@ public void stateChanged(ChangeEvent e) { | |||
| 349 | 347 | JLabel displayLabel = new JLabel(Language.text("preferences.run_sketches_on_display") + ": "); | |
| 350 | 348 | final String tip = "<html>" + Language.text("preferences.run_sketches_on_display.tip"); | |
| 351 | 349 | displayLabel.setToolTipText(tip); | |
| 352 | - displaySelectionBox = new JComboBox<String>(); | ||
| 350 | + displaySelectionBox = new JComboBox<>(); | ||
| 353 | 351 | updateDisplayList(); // needs to happen here for getPreferredSize() | |
| 354 | 352 | ||
| 355 | 353 | ||
@@ -406,7 +404,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 406 | 404 | ||
| 407 | 405 | final int buttonWidth = Toolkit.getButtonWidth(); | |
| 408 | 406 | layout.setHorizontalGroup(layout.createSequentialGroup() // sequential group for border + mainContent + border | |
| 409 | - .addGap(BORDER) | ||
| 407 | + .addGap(Toolkit.BORDER) | ||
| 410 | 408 | .addGroup(layout.createParallelGroup() // parallel group for rest of the components | |
| 411 | 409 | .addComponent(sketchbookLocationLabel) | |
| 412 | 410 | .addGroup(layout.createSequentialGroup() | |
@@ -468,11 +466,11 @@ public void actionPerformed(ActionEvent e) { | |||
| 468 | 466 | .addComponent(okButton, buttonWidth, GroupLayout.DEFAULT_SIZE, buttonWidth) // Ok and Cancel buttton are now of size BUTTON_WIDTH | |
| 469 | 467 | .addComponent(cancelButton, buttonWidth, GroupLayout.DEFAULT_SIZE, buttonWidth) | |
| 470 | 468 | )) | |
| 471 | - .addGap(BORDER) | ||
| 469 | + .addGap(Toolkit.BORDER) | ||
| 472 | 470 | ); | |
| 473 | 471 | ||
| 474 | 472 | layout.setVerticalGroup(layout.createSequentialGroup() // sequential group for border + mainContent + border | |
| 475 | - .addGap(BORDER) | ||
| 473 | + .addGap(Toolkit.BORDER) | ||
| 476 | 474 | .addComponent(sketchbookLocationLabel) | |
| 477 | 475 | .addGroup(layout.createParallelGroup() | |
| 478 | 476 | .addComponent(sketchbookLocationField) | |
@@ -524,7 +522,7 @@ public void actionPerformed(ActionEvent e) { | |||
| 524 | 522 | .addGroup(layout.createParallelGroup(GroupLayout.Alignment.CENTER) | |
| 525 | 523 | .addComponent(okButton) | |
| 526 | 524 | .addComponent(cancelButton)) | |
| 527 | - .addGap(BORDER) | ||
| 525 | + .addGap(Toolkit.BORDER) | ||
| 528 | 526 | ); | |
| 529 | 527 | ||
| 530 | 528 | if (Platform.isWindows()){ | |
@@ -802,7 +800,7 @@ void initFontList() { | |||
| 802 | 800 | EventQueue.invokeLater(new Runnable() { | |
| 803 | 801 | @Override | |
| 804 | 802 | public void run() { | |
| 805 | - fontSelectionBox.setModel(new DefaultComboBoxModel<String>(monoFontFamilies)); | ||
| 803 | + fontSelectionBox.setModel(new DefaultComboBoxModel<>(monoFontFamilies)); | ||
| 806 | 804 | String family = Preferences.get("editor.font.family"); | |
| 807 | 805 | ||
| 808 | 806 | // Set a reasonable default, in case selecting the family fails | |
@@ -837,7 +835,7 @@ int updateDisplayList() { | |||
| 837 | 835 | } | |
| 838 | 836 | items[i] = title; | |
| 839 | 837 | } | |
| 840 | - displaySelectionBox.setModel(new DefaultComboBoxModel<String>(items)); | ||
| 838 | + displaySelectionBox.setModel(new DefaultComboBoxModel<>(items)); | ||
| 841 | 839 | ||
| 842 | 840 | // Disable it if you can't actually change the default display | |
| 843 | 841 | displaySelectionBox.setEnabled(displayCount != 1); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -787,6 +787,15 @@ static public Dimension zoom(int w, int h) { | |||
| 787 | 787 | } | |
| 788 | 788 | ||
| 789 | 789 | ||
| 790 | + static public final int BORDER = | ||
| 791 | + Toolkit.zoom(Platform.isMacOS() ? 20 : 13); | ||
| 792 | + | ||
| 793 | + | ||
| 794 | + static public void setBorder(JComponent comp) { | ||
| 795 | + setBorder(comp, BORDER, BORDER, BORDER, BORDER); | ||
| 796 | + } | ||
| 797 | + | ||
| 798 | + | ||
| 790 | 799 | static public void setBorder(JComponent comp, | |
| 791 | 800 | int top, int left, int bottom, int right) { | |
| 792 | 801 | comp.setBorder(new EmptyBorder(Toolkit.zoom(top), Toolkit.zoom(left), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,6 @@ | |||
| 1 | 1 | package processing.mode.java.pdex; | |
| 2 | 2 | ||
| 3 | + import java.awt.Dimension; | ||
| 3 | 4 | import java.awt.EventQueue; | |
| 4 | 5 | import java.awt.event.ActionEvent; | |
| 5 | 6 | import java.awt.event.ActionListener; | |
@@ -14,14 +15,13 @@ | |||
| 14 | 15 | import java.util.stream.Collectors; | |
| 15 | 16 | ||
| 16 | 17 | import javax.swing.Box; | |
| 17 | - import javax.swing.BoxLayout; | ||
| 18 | 18 | import javax.swing.JButton; | |
| 19 | 19 | import javax.swing.JDialog; | |
| 20 | 20 | import javax.swing.JFrame; | |
| 21 | 21 | import javax.swing.JLabel; | |
| 22 | 22 | import javax.swing.JMenuItem; | |
| 23 | 23 | import javax.swing.JOptionPane; | |
| 24 | - import javax.swing.JPanel; | ||
| 24 | + import javax.swing.JRootPane; | ||
| 25 | 25 | import javax.swing.JTextField; | |
| 26 | 26 | import javax.swing.text.BadLocationException; | |
| 27 | 27 | ||
@@ -33,6 +33,7 @@ | |||
| 33 | 33 | import org.eclipse.jdt.core.dom.SimpleName; | |
| 34 | 34 | ||
| 35 | 35 | import processing.app.Language; | |
| 36 | + import processing.app.Platform; | ||
| 36 | 37 | import processing.app.Sketch; | |
| 37 | 38 | import processing.app.SketchCode; | |
| 38 | 39 | import processing.app.syntax.SyntaxDocument; | |
@@ -70,15 +71,16 @@ class Rename { | |||
| 70 | 71 | editor.getTextArea().getRightClickPopup().add(renameItem); | |
| 71 | 72 | ||
| 72 | 73 | window = new JDialog(editor); | |
| 73 | - window.setTitle("Enter new name:"); | ||
| 74 | + JRootPane rootPane = window.getRootPane(); | ||
| 75 | + window.setTitle("Rename"); | ||
| 74 | 76 | window.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); | |
| 75 | - Toolkit.registerWindowCloseKeys(window.getRootPane(), new ActionListener() { | ||
| 76 | - | ||
| 77 | + Toolkit.registerWindowCloseKeys(rootPane, new ActionListener() { | ||
| 77 | 78 | @Override | |
| 78 | 79 | public void actionPerformed(ActionEvent e) { | |
| 79 | 80 | window.setVisible(false); | |
| 80 | 81 | } | |
| 81 | 82 | }); | |
| 83 | + Toolkit.setIcon(window); | ||
| 82 | 84 | ||
| 83 | 85 | window.setModal(true); | |
| 84 | 86 | window.setResizable(false); | |
@@ -89,31 +91,33 @@ public void componentHidden(ComponentEvent e) { | |||
| 89 | 91 | ps = null; | |
| 90 | 92 | } | |
| 91 | 93 | }); | |
| 92 | - window.setSize(Toolkit.zoom(250, 130)); | ||
| 93 | - window.setLayout(new BoxLayout(window.getContentPane(), BoxLayout.Y_AXIS)); | ||
| 94 | - Toolkit.setIcon(window); | ||
| 95 | - | ||
| 96 | - { // Top panel | ||
| 97 | - | ||
| 98 | - // Text field | ||
| 99 | - textField = new JTextField(40); | ||
| 100 | - //textField.setPreferredSize(Toolkit.zoom(150, 60)); | ||
| 101 | - | ||
| 102 | - // Old name label | ||
| 103 | - oldNameLabel = new JLabel(); | ||
| 104 | - oldNameLabel.setText("Current Name: "); | ||
| 94 | + //window.setSize(Toolkit.zoom(250, 130)); | ||
| 95 | + //window.setLayout(new BoxLayout(window.getContentPane(), BoxLayout.Y_AXIS)); | ||
| 96 | + Box windowBox = Box.createVerticalBox(); | ||
| 97 | + Toolkit.setBorder(windowBox); | ||
| 98 | + final int GAP = Toolkit.zoom(5); | ||
| 99 | + | ||
| 100 | + { // old name | ||
| 101 | + Box oldBox = Box.createHorizontalBox(); | ||
| 102 | + oldNameLabel = new JLabel("Current Name: "); | ||
| 103 | + oldBox.add(oldNameLabel); | ||
| 104 | + //oldBox.add(Box.createHorizontalStrut(10)); | ||
| 105 | + oldBox.add(Box.createHorizontalGlue()); | ||
| 106 | + windowBox.add(oldBox); | ||
| 107 | + windowBox.add(Box.createVerticalStrut(GAP)); | ||
| 108 | + } | ||
| 105 | 109 | ||
| 106 | - // Top panel | ||
| 107 | - JPanel panelTop = new JPanel(); | ||
| 108 | - panelTop.setLayout(new BoxLayout(panelTop, BoxLayout.Y_AXIS)); | ||
| 109 | - Toolkit.setBorder(panelTop, 5, 5, 5, 5); | ||
| 110 | - panelTop.add(textField); | ||
| 111 | - panelTop.add(Box.createRigidArea(Toolkit.zoom(0, 10))); | ||
| 112 | - panelTop.add(oldNameLabel); | ||
| 113 | - window.add(panelTop); | ||
| 110 | + { // new name | ||
| 111 | + Box newBox = Box.createHorizontalBox(); | ||
| 112 | + JLabel newNameLabel = new JLabel("New Name: "); | ||
| 113 | + newBox.add(newNameLabel); | ||
| 114 | + newBox.add(textField = new JTextField(20)); | ||
| 115 | + newBox.add(Box.createHorizontalGlue()); | ||
| 116 | + windowBox.add(newBox); | ||
| 117 | + windowBox.add(Box.createVerticalStrut(GAP*2)); | ||
| 114 | 118 | } | |
| 115 | 119 | ||
| 116 | - { // Bottom panel | ||
| 120 | + { // button panel | ||
| 117 | 121 | JButton showUsageButton = new JButton("Show Usage"); | |
| 118 | 122 | showUsageButton.addActionListener(e -> { | |
| 119 | 123 | showUsage.findUsageAndUpdateTree(ps, binding); | |
@@ -137,17 +141,33 @@ public void componentHidden(ComponentEvent e) { | |||
| 137 | 141 | } | |
| 138 | 142 | }); | |
| 139 | 143 | ||
| 140 | - JPanel panelBottom = new JPanel(); | ||
| 141 | - panelBottom.setLayout(new BoxLayout(panelBottom, BoxLayout.X_AXIS)); | ||
| 142 | - Toolkit.setBorder(panelBottom, 5, 5, 5, 5); | ||
| 144 | + //JPanel panelBottom = new JPanel(); | ||
| 145 | + //panelBottom.setLayout(new BoxLayout(panelBottom, BoxLayout.X_AXIS)); | ||
| 146 | + Box panelBottom = Box.createHorizontalBox(); | ||
| 147 | + //Toolkit.setBorder(panelBottom, 5, 5, 5, 5); | ||
| 148 | + | ||
| 143 | 149 | panelBottom.add(Box.createHorizontalGlue()); | |
| 144 | 150 | panelBottom.add(showUsageButton); | |
| 145 | - panelBottom.add(Box.createRigidArea(Toolkit.zoom(15, 0))); | ||
| 151 | + if (!Platform.isMacOS()) { | ||
| 152 | + panelBottom.add(Box.createHorizontalStrut(GAP)); | ||
| 153 | + } | ||
| 146 | 154 | panelBottom.add(renameButton); | |
| 147 | - window.add(panelBottom); | ||
| 148 | - } | ||
| 155 | + panelBottom.add(Box.createHorizontalGlue()); | ||
| 149 | 156 | ||
| 150 | - window.setMinimumSize(window.getSize()); | ||
| 157 | + Dimension showDim = showUsageButton.getPreferredSize(); | ||
| 158 | + Dimension renameDim = renameButton.getPreferredSize(); | ||
| 159 | + final int niceSize = Math.max(showDim.width, renameDim.width) + GAP; | ||
| 160 | + final Dimension buttonDim = new Dimension(niceSize, showDim.height); | ||
| 161 | + showUsageButton.setPreferredSize(buttonDim); | ||
| 162 | + renameButton.setPreferredSize(buttonDim); | ||
| 163 | + | ||
| 164 | + windowBox.add(panelBottom); | ||
| 165 | + | ||
| 166 | + //window.add(panelBottom); | ||
| 167 | + } | ||
| 168 | + window.add(windowBox); | ||
| 169 | + window.pack(); | ||
| 170 | + //window.setMinimumSize(window.getSize()); | ||
| 151 | 171 | } | |
| 152 | 172 | ||
| 153 | 173 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments