@@ -39,13 +39,22 @@ object Dialog:
3939 null , question, title, JOptionPane .OK_CANCEL_OPTION
4040 ) == JOptionPane .OK_OPTION
4141
42- /** Show a selection dialog with `buttons`. Return a string with the chosen button text. */
42+ /**
43+ * Show a selection dialog with `buttons`. Return a `String` with the chosen button text.
44+ *
45+ * @param message text describing the choice to be made by the user
46+ * @param buttons the sequence of buttons to be displayed in this dialog
47+ * @param title the title of this dialog
48+ * @return a `String` with the chosen button text
49+ */
4350 def select (message : String , buttons : Seq [String ], title : String = " Select" ): String =
4451 scala.util.Try {
4552 val chosenIndex =
46- JOptionPane .showOptionDialog(null , message, title, JOptionPane .DEFAULT_OPTION ,
47- JOptionPane .QUESTION_MESSAGE , null , buttons.reverse.toArray, null )
48- buttons(buttons.length - 1 - chosenIndex)
53+ JOptionPane .showOptionDialog(
54+ null , message, title, JOptionPane .DEFAULT_OPTION ,
55+ JOptionPane .QUESTION_MESSAGE , null , buttons.toArray, null
56+ )
57+ buttons(chosenIndex)
4958 }.getOrElse(" " )
5059
5160 /** Show a color selection dialog and return the color that the user selected. */
0 commit comments