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

Clicking on close box of JInternalFrame doesn't consume the event

XMLWordPrintable

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



      Name: rmT116609 Date: 10/17/2001


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

      This bug is only present in 1.4.0-beta2, not in 1.3

      1. Compile and run the code below
      2. If there is no active caret, place it at the start of the text field
      3. Click "Show Palette"
      4. Close the frame by clicking on its close box.
      5. Observe the caret move to the location of the mouse click

      In my application, I use JInternalFrame as a floating palette that shows
      properties of the underlying selected text. Because of this problem, when the
      user closes the palette, the current selection disappears.

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

      public class test1 extends JPanel
      {
         JEditorPane pane = new JEditorPane();
         JInternalFrame iFrame = new JInternalFrame("iTest");
         
         public static void main( String[] args )
         {
            JFrame f = new JFrame("Test2");
            f.setContentPane(new test1());
            f.setBounds( 10,10,300,200);
            f.show();
         }

         public test1()
         {
            JButton b = new JButton("Show Palette");
            setLayout( new BorderLayout() );

            iFrame.setDefaultCloseOperation(iFrame.HIDE_ON_CLOSE);
            iFrame.setResizable(true);
            iFrame.setClosable(true);

            add( new Desktop(), BorderLayout.CENTER );
      add( b, BorderLayout.SOUTH );
            
            b.addActionListener( new ActionListener() {
               public void actionPerformed( ActionEvent ev )
               {
                  iFrame.show();
               }
            });
         }
         
         private class Desktop extends JDesktopPane
         {
            public Desktop()
            {
               pane.setText( "this is a test this is a test this is a test this is a test this is a test this is a test "
                            + "this is a test this is a test this is a test this is a test this is a test this is a test "
                            + "this is a test this is a test this is a test this is a test this is a test this is a test ");
               
               
          add( pane, new Integer(1) );
          add( iFrame, this.PALETTE_LAYER );
         
          iFrame.setBounds(150, 25, 100,100 );
          }
         }
         
      public Dimension getPreferredSize()
      {
      return pane.getPreferredSize();
      }

      public Dimension getMinimumSize()
      {
      return pane.getMinimumSize();
      }

         public void setBounds( int x, int y, int w, int h )
         {
            Insets insets = getInsets();

            super.setBounds( x, y, w, h );

            if( (w==0) || (h==0) ) return;
            
            pane.setBounds( x+insets.left, y+insets.top, w-(insets.left+insets.right), h-(insets.top+insets.bottom) );
         }

      }
      (Review ID: 133946)
      ======================================================================

            joutwatesunw Joshua Outwater (Inactive)
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: