JOptionPane.showConfirmDialog(this,
message,
"title",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
A message can be 10 lines, and a message can be 500 lines. It changes dynamically. I want to implement a scrollbar if the message exceeds the height of the screen.
So I tried:
JTextArea textArea = new JTextArea (message);
JscrollPane scrollPane = new JScrollPane(textArea,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JOptionPane.showConfirmDialog(this,
scrollPane,
"title",
JOptionPane.YES_NO_OPTION,
JOptionPane.WARNING_MESSAGE);
This will open the dialog box and the scroll bar in the windows and it will work fine, but on mac os the dialog goes off the screen.
Can anyone help me?
source
share