/[classpath]/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by rabbit78, Tue Oct 18 22:10:32 2005 UTC revision 1.28 by rabbit78, Tue Nov 22 15:16:44 2005 UTC
# Line 774  public class BasicOptionPaneUI extends O Line 774  public class BasicOptionPaneUI extends O
774          // it will create a box and burst the string.          // it will create a box and burst the string.
775          // otherwise, it will just create a label and re-call          // otherwise, it will just create a label and re-call
776          // this method with the label o.O          // this method with the label o.O
777          if (msg.toString().length() > maxll)          if (msg.toString().length() > maxll || msg.toString().contains("\n"))
778            {            {
779              Box tmp = new Box(BoxLayout.Y_AXIS);              Box tmp = new Box(BoxLayout.Y_AXIS);
780              burstStringInto(tmp, msg.toString(), maxll);              burstStringInto(tmp, msg.toString(), maxll);
# Line 796  public class BasicOptionPaneUI extends O Line 796  public class BasicOptionPaneUI extends O
796     */     */
797    protected void burstStringInto(Container c, String d, int maxll)    protected void burstStringInto(Container c, String d, int maxll)
798    {    {
     // FIXME: Verify that this is the correct behaviour.  
     // One interpretation of the spec is that this method  
     // should recursively call itself to create (and add)  
     // JLabels to the container if the length of the String d  
     // is greater than maxll.  
     // but in practice, even with a really long string, this is  
     // all that happens.  
799      if (d == null || c == null)      if (d == null || c == null)
800        return;        return;
801      JLabel label = new JLabel(d);  
802        int newlineIndex = d.indexOf('\n');
803        String line;
804        String remainder;
805        if (newlineIndex >= 0 && newlineIndex < maxll)
806          {
807            line = d.substring(0, newlineIndex);
808            remainder = d.substring(newlineIndex + 1);
809          }
810        else
811          {
812            line = d.substring(0, maxll);
813            remainder = d.substring(maxll);
814          }
815        JLabel label = new JLabel(line);
816      c.add(label);      c.add(label);
817    
818        // If there is nothing left to burst, then we can stop.
819        if (remainder.length() == 0)
820          return;
821    
822        // Recursivly call ourselves to burst the remainder of the string,
823        if ((remainder.length() > maxll || remainder.contains("\n")))
824          burstStringInto(c, remainder, maxll);
825        else
826          // Add the remainder to the container and be done.
827          c.add(new JLabel(remainder));
828    }    }
829    
830    /**    /**

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26