@@ -456,51 +456,75 @@ protected void addMessageComponents(Container container,
456
456
} else if ((nl = s .indexOf ('\n' )) >= 0 ) {
457
457
nll = 1 ;
458
458
}
459
- if (nl >= 0 ) {
460
- // break up newlines
461
- if (nl == 0 ) {
462
- @ SuppressWarnings ("serial" ) // anonymous class
463
- JPanel breakPanel = new JPanel () {
464
- public Dimension getPreferredSize () {
465
- Font f = getFont ();
466
-
467
- if (f != null ) {
468
- return new Dimension (1 , f .getSize () + 2 );
469
- }
470
- return new Dimension (0 , 0 );
471
- }
472
- };
473
- breakPanel .setName ("OptionPane.break" );
474
- addMessageComponents (container , cons , breakPanel , maxll ,
475
- true );
476
- } else {
477
- addMessageComponents (container , cons , s .substring (0 , nl ),
478
- maxll , false );
479
- }
480
- // Prevent recursion of more than
481
- // 200 successive newlines in a message
482
- // and indicate message is truncated via ellipsis
483
- if (recursionCount ++ > 200 ) {
484
- recursionCount = 0 ;
485
- addMessageComponents (container , cons , new String ("..." ),
486
- maxll ,false );
487
- return ;
459
+ if (s .contains ("<html>" )) {
460
+ /* line break in html text is done by <br> tag
461
+ * and not by /n so it's incorrect to address newline
462
+ * same as non-html text.
463
+ * Text between <html> </html> tags are extracted
464
+ * and rendered as JLabel text
465
+ */
466
+ int index1 = s .indexOf ("<html>" );
467
+ int index2 = s .indexOf ("</html>" );
468
+ String str = "" ;
469
+ if (index2 >= 0 ) {
470
+ str = s .substring (index2 + "</html>" .length ());
471
+ s = s .substring (index1 , index2 + + "</html>" .length ());
488
472
}
489
- addMessageComponents (container , cons , s .substring (nl + nll ), maxll ,
490
- false );
491
-
492
- } else if (len > maxll ) {
493
- Container c = Box .createVerticalBox ();
494
- c .setName ("OptionPane.verticalBox" );
495
- burstStringInto (c , s , maxll );
496
- addMessageComponents (container , cons , c , maxll , true );
497
-
498
- } else {
499
473
JLabel label ;
500
- label = new JLabel ( s , JLabel .LEADING );
474
+ label = new JLabel (s , JLabel .LEADING );
501
475
label .setName ("OptionPane.label" );
502
476
configureMessageLabel (label );
503
477
addMessageComponents (container , cons , label , maxll , true );
478
+ if (!str .isEmpty ()) {
479
+ addMessageComponents (container , cons , str , maxll , false );
480
+ }
481
+ } else {
482
+ if (nl >= 0 ) {
483
+ // break up newlines
484
+ if (nl == 0 ) {
485
+ @ SuppressWarnings ("serial" ) // anonymous class
486
+ JPanel breakPanel = new JPanel () {
487
+ public Dimension getPreferredSize () {
488
+ Font f = getFont ();
489
+
490
+ if (f != null ) {
491
+ return new Dimension (1 , f .getSize () + 2 );
492
+ }
493
+ return new Dimension (0 , 0 );
494
+ }
495
+ };
496
+ breakPanel .setName ("OptionPane.break" );
497
+ addMessageComponents (container , cons , breakPanel , maxll ,
498
+ true );
499
+ } else {
500
+ addMessageComponents (container , cons , s .substring (0 , nl ),
501
+ maxll , false );
502
+ }
503
+ // Prevent recursion of more than
504
+ // 200 successive newlines in a message
505
+ // and indicate message is truncated via ellipsis
506
+ if (recursionCount ++ > 200 ) {
507
+ recursionCount = 0 ;
508
+ addMessageComponents (container , cons , new String ("..." ),
509
+ maxll , false );
510
+ return ;
511
+ }
512
+ addMessageComponents (container , cons , s .substring (nl + nll ), maxll ,
513
+ false );
514
+
515
+ } else if (len > maxll ) {
516
+ Container c = Box .createVerticalBox ();
517
+ c .setName ("OptionPane.verticalBox" );
518
+ burstStringInto (c , s , maxll );
519
+ addMessageComponents (container , cons , c , maxll , true );
520
+
521
+ } else {
522
+ JLabel label ;
523
+ label = new JLabel (s , JLabel .LEADING );
524
+ label .setName ("OptionPane.label" );
525
+ configureMessageLabel (label );
526
+ addMessageComponents (container , cons , label , maxll , true );
527
+ }
504
528
}
505
529
}
506
530
}
0 commit comments