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

GTK L&F: JScrollPane corners

XMLWordPrintable

    • b07
    • x86
    • linux
    • Verified

      FULL PRODUCT VERSION :
      java version "1.6.0-beta2"
      Java(TM) SE Runtime Environment (build 1.6.0-beta2-b85)
      Java HotSpot(TM) 64-Bit Server VM (build 1.6.0-beta2-b85, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux helium 2.6.12-10-amd64-generic #1 Fri Apr 28 13:18:42 UTC 2006 x86_64 GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      The GTK LAF doesn't do anything to suppress the JScrollPane's upper-right corner, which doesn't exist in real GTK+ scrollable views. This means that tables have an unsightly hole in the upper-right corner when using the GTK LAF, compared to a native GTK+ application.

      An obvious work-around is to pull the vertical scroll bar out and place it next to the JScrollPane (rather than letting the JScrollPane's custom layout manager lay it out). This *almost* works, but there's a gap where the table has no border. The gap may be because of an assumption that there's a vertical scroll bar taking up that space.

      Compare the native GTK+ table and the Java GTK LAF table in the two pictures here:

        http://elliotth.blogspot.com/2006/04/gtk-laf-in-java-6.html

      Notice in particular the bounds of the vertical scroll bar are very different. I mention this in passing in 6417110, but I'm here reporting a different problem I found while trying to work around the original problem.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the attached class. Look at the table's border on its right-hand edge, and the top and bottom at the right-hand side. There's a gap of about a scroll bar's width.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Ideally, with the GTK LAF, a JScrollPane wouldn't have a visible upper-right corner unless the developer has put something in the gap. The vertical scroll bar would expand to the top of the header. (A similar feature could be useful on Mac OS; there the header should normally extend all the way to the right, over the top of the vertical scroll bar. I've written about working around that here: http://elliotth.blogspot.com/2006/05/making-jtable-look-more-at-home-on-mac.html).

      But it would be good in the Java 6 timeframe (assuming there's no time for the full solution described above) to at least have the border rendered correctly so developers who care enough can make their Java apps more GNOME-like.
      ACTUAL -
      Not only is the default JScrollPane(JTable) behavior wrong, it doesn't seem possible to correctly work around the default behavior. We're left with an unsightly gap where the right-hand side of the border ought to be.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static JComponent makeScrollable(JComponent c) {
              JScrollPane scrollPane = new JScrollPane(c, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
              if (c instanceof JTable) {
                  JPanel panel = new JPanel(new BorderLayout());
                  panel.add(scrollPane, BorderLayout.CENTER);
                  panel.add(scrollPane.getVerticalScrollBar(), BorderLayout.EAST);
                  panel.setBorder(BorderFactory.createLineBorder(Color.YELLOW, 1));
                  scrollPane.setBorder(BorderFactory.createLineBorder(Color.RED, 1));
                  return panel;
              }
              return scrollPane;
          }

      ---------- END SOURCE ----------

            campbell Christopher Campbell (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: