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

TabStop not working in 1.2, does in 1.1

XMLWordPrintable

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



      Name: skT88420 Date: 05/27/99


      I thought I reported this but can't find it.

      The following program works fine under JDK 1.1.7 but not under JDK 1.2. Under 1.2, the tab stops are ignored and everything is left-justified. [Just tried 1.2.2T and still a problem.]


      import javax.swing.*;
      import javax.swing.text.*;
      import javax.swing.event.*;
      import java.awt.*;

      public class TabSample {
        public static void main(String args[]) {
          JFrame frame = new JFrame("Tab Attributes");
          Container content = frame.getContentPane();

          StyledDocument document = new DefaultStyledDocument();

          int positions[] = {TabStop.ALIGN_BAR, TabStop.ALIGN_CENTER, TabStop.ALIGN_DECIMAL,
            TabStop.ALIGN_LEFT, TabStop.ALIGN_RIGHT};
          String strings[] = {"\tBAR\n", "\tCENTER\n", "\t3.14159265\n", "\tLEFT\n", "\tRIGHT\n"};

          SimpleAttributeSet attributes = new SimpleAttributeSet();

          for (int i=0, n=positions.length; i<n; i++) {
            TabStop tabstop = new TabStop(150, positions[i], TabStop.LEAD_NONE);
            try {
              int position = document.getLength();
              document.insertString(position, strings[i], null);
              TabSet tabset = new TabSet(new TabStop[] {tabstop});
              StyleConstants.setTabSet(attributes, tabset);
              document.setParagraphAttributes(position, 1, attributes, false);
            } catch (BadLocationException badLocationException) {
              System.err.println("Oops");
            }
          }

         JTextPane textPane = new JTextPane(document);
          textPane.setEditable(false);
          JScrollPane scrollPane = new JScrollPane(textPane);
          content.add(scrollPane, BorderLayout.CENTER);

          frame.setSize(300, 150);
          frame.setVisible(true);
        }
      }
      (Review ID: 83535)
      ======================================================================

            tprinzing Tim Prinzing (Inactive)
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: