I’m studying code that simply shows a full-screen color and cycles through other colors. There’s a line I’ve been staring at
getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false), "ESCAPE");
This allows you to press “Esc” and quit it( and getRootPane() is associated with JButton I think?). But Is there a more efficient way to code this? Can it be split up into multiple lines?
You mean something like this:
While this would appear more readable, I don’t think this would add anything in terms of efficiency to the current implementation.