@@ -20,31 +20,28 @@ package processing.app
2020
2121import androidx .compose .foundation .layout .Column
2222import androidx .compose .foundation .layout .padding
23- import androidx .compose .material .icons .Icons
24- import androidx .compose .material .icons .filled .Error
25- import androidx .compose .material .icons .filled .Info
26- import androidx .compose .material .icons .filled .Warning
27- import androidx .compose .material3 .*
28- import androidx .compose .runtime .Composable
29- import androidx .compose .ui .ExperimentalComposeUiApi
23+ import androidx .compose .material3 .Button
24+ import androidx .compose .material3 .Text
3025import androidx .compose .ui .Modifier
31- import androidx .compose .ui .awt .ComposeDialog
32- import androidx .compose .ui .graphics .RectangleShape
33- import androidx .compose .ui .layout .onSizeChanged
34- import androidx .compose .ui .platform .LocalDensity
35- import androidx .compose .ui .text .font .FontWeight
3626import androidx .compose .ui .unit .DpSize
3727import androidx .compose .ui .unit .dp
3828import androidx .compose .ui .window .Window
3929import androidx .compose .ui .window .application
4030import androidx .compose .ui .window .rememberWindowState
4131import com .formdev .flatlaf .FlatLightLaf
32+ import androidx .compose .runtime .Composable
33+ import androidx .compose .ui .ExperimentalComposeUiApi
34+ import androidx .compose .ui .awt .ComposeDialog
35+ import androidx .compose .ui .layout .onSizeChanged
36+ import androidx .compose .ui .platform .LocalDensity
4237import processing .app .ui .Toolkit
4338import processing .app .ui .theme .PDETheme
39+ import java .awt .EventQueue
4440import java .awt .Dimension
4541import java .awt .Frame
4642import java .io .PrintWriter
4743import java .io .StringWriter
44+ import javax .swing .JFrame
4845import javax .swing .JOptionPane
4946import javax .swing .UIManager
5047
@@ -60,23 +57,10 @@ class Messages {
6057 if (Base .isCommandLine ()) {
6158 println ("$title: $message" )
6259 } else {
63- showDialog (title ) { modifier , dismiss ->
64- AlertDialog (
65- modifier = modifier ,
66- onDismissRequest = { },
67- shape = RectangleShape ,
68- icon = { Icon (Icons .Default .Info , contentDescription = "Info!" ) },
69- title = { Text (title ) },
70- text = { Text (message ) },
71- confirmButton = {
72- Button (
73- onClick = { dismiss () }
74- ) {
75- Text ("OK" )
76- }
77- }
78- )
79- }
60+ JOptionPane .showMessageDialog (
61+ Frame (), message , title ,
62+ JOptionPane .INFORMATION_MESSAGE
63+ )
8064 }
8165 }
8266
@@ -93,27 +77,10 @@ class Messages {
9377 if (Base .isCommandLine ()) {
9478 println ("$title: $message" )
9579 } else {
96- showDialog(title) { modifier, dismiss ->
97- AlertDialog(
98- modifier = modifier,
99- onDismissRequest = { },
100- shape = RectangleShape,
101- icon = { Icon(Icons.Default.Warning, contentDescription = " Alert !") },
102- iconContentColor = MaterialTheme.colorScheme.tertiary,
103- title = { Text(title) },
104- text = { Text(message) },
105- confirmButton = {
106- Button(
107- onClick = { dismiss() },
108- colors = ButtonDefaults.outlinedButtonColors(
109- contentColor = MaterialTheme.colorScheme.tertiary
110- )
111- ) {
112- Text(" OK ")
113- }
114- }
115- )
116- }
80+ JOptionPane .showMessageDialog (
81+ Frame (), message , title ,
82+ JOptionPane .WARNING_MESSAGE
83+ )
11784 }
11885 e ?.printStackTrace ()
11986 }
@@ -133,30 +100,11 @@ class Messages {
133100 // proper parsing on the command line. Many have \n in them.
134101 println ("$title: $primary\n $secondary" )
135102 } else {
136- showDialog(title) { modifier, dismiss ->
137- AlertDialog(
138- modifier = modifier,
139- onDismissRequest = { },
140- shape = RectangleShape,
141- icon = { Icon(Icons.Default.Warning, contentDescription = " Alert !") },
142- iconContentColor = MaterialTheme.colorScheme.tertiary,
143- title = { Text(title) },
144- text = {
145- Column {
146- Text(primary, fontWeight = FontWeight.Bold)
147- Text(secondary)
148- }
149- },
150- confirmButton = {
151- Button(
152- onClick = { dismiss() },
153- colors = ButtonDefaults.outlinedButtonColors(
154- contentColor = MaterialTheme.colorScheme.tertiary
155- )
156- ) {
157- Text(" OK ")
158- }
159- }
103+ EventQueue .invokeLater {
104+ JOptionPane .showMessageDialog (
105+ JFrame (),
106+ Toolkit .formatMessage (primary , secondary ),
107+ title , JOptionPane .WARNING_MESSAGE
160108 )
161109 }
162110 }
@@ -174,28 +122,10 @@ class Messages {
174122 if (Base .isCommandLine ()) {
175123 System .err .println ("$title: $message" )
176124 } else {
177- showDialog(title) { modifier, dismiss ->
178- AlertDialog(
179- modifier = modifier,
180- onDismissRequest = { },
181- shape = RectangleShape,
182- icon = { Icon(Icons.Default.Error, contentDescription = " Alert !") },
183- iconContentColor = MaterialTheme.colorScheme.error,
184- title = { Text(title) },
185- text = { Text(message) },
186- confirmButton = {
187- Button(
188- onClick = { dismiss() },
189- colors = ButtonDefaults.buttonColors(
190- containerColor = MaterialTheme.colorScheme.error,
191- contentColor = MaterialTheme.colorScheme.onError
192- )
193- ) {
194- Text(" OK ")
195- }
196- }
197- )
198- }
125+ JOptionPane .showMessageDialog (
126+ Frame (), message , title ,
127+ JOptionPane .ERROR_MESSAGE
128+ )
199129 }
200130 e ?.printStackTrace ()
201131 System .exit (1 )
@@ -229,8 +159,6 @@ class Messages {
229159 if (fatal ) JOptionPane .ERROR_MESSAGE else JOptionPane .WARNING_MESSAGE
230160 )
231161
232-
233-
234162 if (fatal ) {
235163 System .exit (1 )
236164 }
0 commit comments