JOptionPane.showOptionDialog not able to use \n for text in button

42 views Asked by At

For some reason, JOptionPane.showOptionDialog does not accept \n on runtime. It aknowledges it by not displaying "\n" or giving any errors but it also does not create a new line for the text. I cannot use a text block as it is stored to an array. I don't understand how it happened but this is a very strange bug. To my knowledge, "\n" creates a new line that any text afterwards will be outputted there.

int intReportOption = 0;
String[] strReportOptions =
   {
      "Show tasks\nthat are done",
      "Show longest\ntask",
      "Search for task\nby task name",
      "Search for task by\nassigned person",
      "Delete\ntask",
      "Show\nreport",
      "Exit"
   };
      while (intReportOption != 6)
   {
      intReportOption = JOptionPane.showOptionDialog(null,
      "Pick an option",
      "EasyKanban",
      JOptionPane.DEFAULT_OPTION,
      JOptionPane.QUESTION_MESSAGE,
      null,
      strReportOptions,
      strReportOptions[0]);
}

Most searches on google say to use "\n" with some giving html syntax(for java?) which means my problem is special or stupid. Any help/suggestions would be greatly appreciated.

0

There are 0 answers