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

StrikeThrough and Underline text in JTextPane does not show StrikeThrough

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.2
    • 1.4.1
    • client-libs
    • mantis
    • x86
    • windows_2000



      Name: jk109818 Date: 08/19/2002


      FULL PRODUCT VERSION :
      java version "1.3.1_04"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_04-b02)
      Java HotSpot(TM) Client VM (build 1.3.1_04-b02, mixed mode)

      AND

      java version "1.4.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
      Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)

      AND

      java version "1.4.1-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b14)
      Java HotSpot(TM) Client VM (build 1.4.1-beta-b14, mixed mode)

      FULL OPERATING SYSTEM VERSION :Microsoft Windows 2000
      [Version 5.00.2195]


      A DESCRIPTION OF THE PROBLEM :
      Insert a text with "Strike Through" and "Underline" both
      attributes set in a JTextPane. Only the underline is seen,
      the horizontal "Strike Through line" is not seen.

      There is no visible difference between these two categories
      of text in a JTextPane -
      a) the text with only the underline
      b) the text with Underline and StrikeThrough

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.Compile the pasted code.
      2.execute the same with "java MyFrame".
      3.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Strike through effect should also be visible. There should
      be two horizontal lines to the text. One at the bottom,
      another at approx half the height of the text.


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.*;
      import javax.swing.text.*;
      import java.awt.*;

      class MyFrame extends JFrame
      {
      StyleContext sc = new StyleContext();
      DefaultStyledDocument doc = new DefaultStyledDocument( sc );

      public MyFrame()
      {
      setSize( 800, 250 );
      getContentPane().setLayout( new BorderLayout() );

      JPanel p = new JPanel(new BorderLayout());
      p.add(new JTextPane(doc), BorderLayout.CENTER);

      getContentPane().add( p, "Center" );

      Style s = null;
      s = sc.addStyle("underlined", null);
      StyleConstants.setFontFamily( s, "Dialog" );
      StyleConstants.setFontSize( s, 24 );
      StyleConstants.setBold( s, false );
      StyleConstants.setItalic( s, false );
      StyleConstants.setUnderline( s, true );
      StyleConstants.setStrikeThrough( s, false );
      try
      {
      doc.insertString( 0, "The text has underline
      only.\n\n", s);
      }catch (Exception e)
      {
      }


      s = sc.addStyle("onlySriked", null);
      StyleConstants.setFontFamily( s, "Dialog" );
      StyleConstants.setFontSize( s, 24 );
      StyleConstants.setBold( s, false );
      StyleConstants.setItalic( s, false );
      StyleConstants.setUnderline( s, false );
      StyleConstants.setStrikeThrough( s, true );
      try
      {
      doc.insertString( doc.getLength(), "This text has
      strike through effect only.\n\n", s);
      }catch (Exception e)
      {
      }

      s = sc.addStyle("both", null);
      StyleConstants.setFontFamily( s, "Dialog" );
      StyleConstants.setFontSize( s, 24 );
      StyleConstants.setBold( s, false );
      StyleConstants.setItalic( s, false );
      StyleConstants.setUnderline( s, true );
      StyleConstants.setStrikeThrough( s, true );
      try
      {
      doc.insertString( doc.getLength(), "This text has
      underline and strike through both, but only underline is seen!!.", s);
      }catch (Exception e)
      {
      }

      show();
      }

      public static void main(String s[])
      {
      new MyFrame();
      }
      }
      ---------- END SOURCE ----------
      (Review ID: 160117)
      ======================================================================

            idk Igor Kushnirskiy (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: