Skip to content

Commit 0b8e792

Browse files
author
Federico Fissore
committed
GUIUserNotifier uses active editor as parent component
1 parent 1783719 commit 0b8e792

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Diff for: app/src/processing/app/Base.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,6 @@ static public void guardedMain(String args[]) throws Exception {
142142
BaseNoGui.initLogger();
143143

144144
initLogger();
145-
146-
BaseNoGui.notifier = new GUIUserNotifier();
147145

148146
BaseNoGui.initPlatform();
149147

@@ -270,6 +268,8 @@ static public File absoluteFile(String path) {
270268
}
271269

272270
public Base(String[] args) throws Exception {
271+
BaseNoGui.notifier = new GUIUserNotifier(this);
272+
273273
String sketchbookPath = BaseNoGui.getSketchbookPath();
274274

275275
// If no path is set, get the default sketchbook folder for this platform

Diff for: app/src/processing/app/helpers/GUIUserNotifier.java

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package processing.app.helpers;
22

3+
import processing.app.Base;
4+
35
import static processing.app.I18n._;
46

57
import java.awt.Frame;
@@ -8,6 +10,12 @@
810

911
public class GUIUserNotifier extends UserNotifier {
1012

13+
private final Base base;
14+
15+
public GUIUserNotifier(Base base) {
16+
this.base = base;
17+
}
18+
1119
/**
1220
* Show an error message that's actually fatal to the program.
1321
* This is an error that can't be recovered. Use showWarning()
@@ -16,7 +24,7 @@ public class GUIUserNotifier extends UserNotifier {
1624
public void showError(String title, String message, Throwable e, int exit_code) {
1725
if (title == null) title = _("Error");
1826

19-
JOptionPane.showMessageDialog(new Frame(), message, title,
27+
JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
2028
JOptionPane.ERROR_MESSAGE);
2129

2230
if (e != null) e.printStackTrace();
@@ -30,7 +38,7 @@ public void showError(String title, String message, Throwable e, int exit_code)
3038
public void showMessage(String title, String message) {
3139
if (title == null) title = _("Message");
3240

33-
JOptionPane.showMessageDialog(new Frame(), message, title,
41+
JOptionPane.showMessageDialog(base.getActiveEditor(), message, title,
3442
JOptionPane.INFORMATION_MESSAGE);
3543
}
3644

0 commit comments

Comments
 (0)