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

JTree with lineStyle=Angled draws extraneous pixels

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.1
    • client-libs
    • generic, x86
    • generic, windows_95



      Name: boT120536 Date: 02/22/2001


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

      Create a JTree in the Java L&F, and set "JTree.lineStyle" to "Angled", to draw
      connecting lines. Expand the bottom-most parent node, and click around on some
      of its children. To the left of some of the clicked nodes, a single errant
      pixel is drawn. (It's hard to see, because it's a single light-purple pixel on
      a white background.)

      paintVerticalLine() is getting called with top > bottom, causing this extra
      pixel to appear. (It doesn't happen on the Windows L&F, because WindowsTreeUI
      overrides this method, and calls a different method that does nothing if top >
      bottom.)

      If you run the following program, one of the output lines will be something
      like:

      v: 7 92 63

      import java.awt.*;
      import javax.swing.*;
      import javax.swing.plaf.metal.*;

      public class TreeTest
      {
      public final static void main (String[] args)
      {
      try
      {
      JFrame f = new JFrame("hi");
      f.setBounds(100,100,400,600);

      JTree tree = new JTree();
      tree.putClientProperty("JTree.lineStyle", "Angled");
      tree.setUI(new MyTreeUI());
      f.getContentPane().add(tree);

      f.show();
      }
      catch(Exception ex)
      {
      ex.printStackTrace();
      }
      }

      private static class MyTreeUI extends MetalTreeUI
      {
      protected void paintVerticalLine( Graphics g,
      JComponent c, int x, int top, int bottom )
      {
      System.out.println("v: " + x + " " + top + " "
      + bottom);
      super.paintVerticalLine(g, c, x, top, bottom);
      }

      protected void paintHorizontalLine( Graphics g,
      JComponent c, int y, int left, int right )
      {
      System.out.println("h: " + y + " " + left + " "
      + right);
      super.paintHorizontalLine(g, c, y, left, right);
      }
      }
      }
      (Review ID: 117514)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: