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

JDesktopPane paints internal frames over top of its border

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 1.3.0
    • client-libs



      Name: krT82822 Date: 03/15/2000


      15 Mar 2000, eval1127@eng -- see also 4318878.

      java version "1.3.0rc1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc1-T)
      Java HotSpot(TM) Client VM (build 1.3.0rc1-S, mixed mode)


      If you give a border to a JDesktopPane it will paint its child JInternlFrames
      over the top of the border. Obviously the frames should NOT be drawn on top of
      the desktop's border.

      The following test app clearly shows this. If you invoke with any command-line
      arg at all then a workaround is applied that forces the paint ordering of the
      desktop to be 1) component, 2) children then 3) border. This seems to fix the
      problem when using outline drag mode but not when using opaque dragging.

      Here's the code:

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

      public class JDesktopPanePaintBug extends JFrame {
         public static void main(String[] args) {
            try {
               
      UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            } catch (Exception x) {}
            new JDesktopPanePaintBug((args.length > 0));
         }

         public JDesktopPanePaintBug(boolean do_fix) {
            addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {
                  System.exit(0);
               }}
            );

            JDesktopPane desktop;
            if (do_fix) {
               //
               // THIS WORKAROUND ONLY SEEMS TO WORK WITH "OUTLINE" DRAG MODE
               //
               desktop = new JDesktopPane() {
                  public void paint(Graphics g) {
                     super.paintComponent(g);
                     super.paintChildren(g);
                     super.paintBorder(g);
                  }
               };
            }
            else {
               desktop = new JDesktopPane();
            }
            desktop.putClientProperty("JDesktopPane.dragMode", "outline");
            desktop.setBorder(BorderFactory.createLineBorder(Color.red, 3));
            setContentPane(desktop);

            JInternalFrame iframe = new JInternalFrame("Test Frame", true, false,
      true, true);
            iframe.setOpaque(true);
            iframe.setBackground(Color.white);
            iframe.setBounds(10,10,200,200);
            iframe.setVisible(true);
            desktop.add(iframe);

            pack();
            setBounds(300, 300, 300, 300);
            setVisible(true);
         }
      }
      (Review ID: 102403)
      ======================================================================

            hgajewsksunw Hania Gajewska (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: