Skip to content

Commit d9912d4

Browse files
Applying dispose before frame is displayable
Moved the undecorated setup to the very beginning of the Editor constructor before any operations that could make the frame displayable happened.
1 parent 30fa33e commit d9912d4

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

app/src/processing/app/ui/Editor.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ public abstract class Editor extends JFrame implements RunnerListener {
148148
protected Editor(final Base base, String path, final EditorState state,
149149
final Mode mode) throws EditorException {
150150
super("Processing", state.getConfig());
151+
if (Platform.isLinux()) {
152+
// If the frame is already displayable, dispose it to allow undecorated change
153+
if (isDisplayable()) {
154+
dispose();
155+
}
156+
try {
157+
setUndecorated(true);
158+
} catch (IllegalComponentStateException e) {
159+
System.err.println("Could not set undecorated: " + e.getMessage());
160+
}
161+
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
162+
}
151163
this.base = base;
152164
this.state = state;
153165
this.mode = mode;
@@ -211,10 +223,7 @@ public void windowDeactivated(WindowEvent e) {
211223
spacer.setAlignmentX(Component.LEFT_ALIGNMENT);
212224
box.add(spacer);
213225
}
214-
if (Platform.isLinux()) {
215-
if (!isDisplayable()) setUndecorated(true);
216-
getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
217-
}
226+
218227

219228
rebuildModePopup();
220229
toolbar = createToolbar();

0 commit comments

Comments
 (0)