diff --git a/app/src/processing/app/AbstractTextMonitor.java b/app/src/processing/app/AbstractTextMonitor.java index 9e4f7413a..4e35d4e44 100644 --- a/app/src/processing/app/AbstractTextMonitor.java +++ b/app/src/processing/app/AbstractTextMonitor.java @@ -136,7 +136,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor { minimumSize.setSize(minimumSize.getWidth() / 3, minimumSize.getHeight()); noLineEndingAlert.setMinimumSize(minimumSize); - lineEndings = new JComboBox(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")}); + lineEndings = new JComboBox<>(new String[]{tr("No line ending"), tr("Newline"), tr("Carriage return"), tr("Both NL & CR")}); lineEndings.addActionListener((ActionEvent event) -> { PreferencesData.setInteger("serial.line_ending", lineEndings.getSelectedIndex()); noLineEndingAlert.setForeground(pane.getBackground()); @@ -146,7 +146,7 @@ public abstract class AbstractTextMonitor extends AbstractMonitor { lineEndings.setMaximumSize(lineEndings.getMinimumSize()); - serialRates = new JComboBox(); + serialRates = new JComboBox<>(); for (String rate : serialRateStrings) { serialRates.addItem(rate + " " + tr("baud")); } diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index ee26332ef..a28d29fa9 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1880,9 +1880,6 @@ public class Base { getEditors().forEach(Editor::applyPreferences); } - private MouseWheelListener editorFontResizeMouseWheelListener = null; - private KeyListener editorFontResizeKeyListener = null; - /** * Adds a {@link MouseWheelListener} and {@link KeyListener} to the given * component that will make "CTRL scroll" and "CTRL +/-" @@ -1894,8 +1891,8 @@ public class Base { * @param comp - The component to add the listener to. */ public void addEditorFontResizeListeners(Component comp) { - this.addEditorFontResizeMouseWheelListener(comp); - this.addEditorFontResizeKeyListener(comp); + addEditorFontResizeMouseWheelListener(comp); + addEditorFontResizeKeyListener(comp); } /** @@ -1907,20 +1904,17 @@ public class Base { * @param comp - The component to add the listener to. */ public void addEditorFontResizeMouseWheelListener(Component comp) { - if (this.editorFontResizeMouseWheelListener == null) { - this.editorFontResizeMouseWheelListener = (MouseWheelEvent e) -> { - if (e.isControlDown()) { - if (e.getWheelRotation() < 0) { - this.handleFontSizeChange(1); - } else { - this.handleFontSizeChange(-1); - } + comp.addMouseWheelListener(e -> { + if (e.isControlDown()) { + if (e.getWheelRotation() < 0) { + this.handleFontSizeChange(1); } else { - e.getComponent().getParent().dispatchEvent(e); + this.handleFontSizeChange(-1); } - }; - } - comp.addMouseWheelListener(this.editorFontResizeMouseWheelListener); + } else { + e.getComponent().getParent().dispatchEvent(e); + } + }); } /** @@ -1930,29 +1924,26 @@ public class Base { * @param comp - The component to add the listener to. */ public void addEditorFontResizeKeyListener(Component comp) { - if (this.editorFontResizeKeyListener == null) { - this.editorFontResizeKeyListener = new KeyAdapter() { - @Override - public void keyPressed(KeyEvent e) { - if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK - || e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK - | KeyEvent.SHIFT_DOWN_MASK)) { - switch (e.getKeyCode()) { - case KeyEvent.VK_PLUS: - case KeyEvent.VK_EQUALS: - Base.this.handleFontSizeChange(1); - break; - case KeyEvent.VK_MINUS: - if (!e.isShiftDown()) { - Base.this.handleFontSizeChange(-1); - } - break; + comp.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK + || e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK + | KeyEvent.SHIFT_DOWN_MASK)) { + switch (e.getKeyCode()) { + case KeyEvent.VK_PLUS: + case KeyEvent.VK_EQUALS: + Base.this.handleFontSizeChange(1); + break; + case KeyEvent.VK_MINUS: + if (!e.isShiftDown()) { + Base.this.handleFontSizeChange(-1); } + break; } } - }; - } - comp.addKeyListener(this.editorFontResizeKeyListener); + } + }); } public List getBoardsCustomMenus() {