Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4230425

HTML rendered content size too big in labels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • client-libs



      Name: clC74495 Date: 04/16/99


      Swing 1.1.1, beta2

      The HTML rendered with the "<html>...." text property of components thinks
      it is too wide.

      For instance, if I have a JLabel that is right-aligned, there is a huge gap when
      the text property is <html>'ed, that isn't present when not. center-aligned is
      bad too.

      import javax.swing.*;
      import javax.swing.border.*;
      import java.awt.*;

      public class LabelAlign {

        public static void main(String args[]) {
          JFrame frame = new JFrame("Label Align");

          Border border = LineBorder.createGrayLineBorder();

          Container content = frame.getContentPane();
          content.setLayout(new GridLayout(2, 2));

          JLabel label1 = new JLabel("<html>Bottom<BR>Left");
          label1.setHorizontalAlignment(JLabel.LEFT);
          label1.setVerticalAlignment(JLabel.BOTTOM);
          label1.setBorder(border);
          content.add(label1);

          JLabel label2 = new JLabel("<html>Top<BR>Right");
          label2.setHorizontalAlignment(JLabel.RIGHT);
          label2.setVerticalAlignment(JLabel.TOP);
          label2.setBorder(border);
          content.add(label2);

          JLabel label3 = new JLabel("<html>Top<BR>Center");
          label3.setHorizontalAlignment(JLabel.CENTER);
          label3.setVerticalAlignment(JLabel.TOP);
          label3.setBorder(border);
          content.add(label3);

          JLabel label4 = new JLabel("<html>Bottom<BR>Center");
          label4.setHorizontalAlignment(JLabel.CENTER);
          label4.setVerticalAlignment(JLabel.BOTTOM);
          label4.setBorder(border);
          content.add(label4);

          frame.setSize(300, 200);
          frame.setVisible(true);
        }
      }
      (Review ID: 57075)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: