Package net.xoetrope.swing.util

Examples of net.xoetrope.swing.util.XGradientHeaderPanel


        } );

        b.setPreferredSize( new Dimension( BUTTON_SIZE, BUTTON_SIZE ));

        if ( ! hideFrame ) {
          titlePanel = new XGradientHeaderPanel();
          titlePanel.setLayout( new BorderLayout());
          titlePanel.setText( title );
          JPanel closePanel = new JPanel( new BorderLayout( 0, 0 ));
          closePanel.setPreferredSize( new Dimension( BUTTON_SIZE + 4, BUTTON_SIZE + 4 ));
          closePanel.setBackground( SystemColor.activeCaption );
          closePanel.add( b, BorderLayout.CENTER );

          titlePanel.setBackground( SystemColor.activeCaption );
          titlePanel.setForeground( SystemColor.activeCaptionText );

          titlePanel.add( closePanel, BorderLayout.EAST );
          add( titlePanel, BorderLayout.NORTH ); // 'this' identifier is needed for Ant compilation
        }
       
        if ( !bUseNativeHeaders ) {
          ((JComponent)getContentPane()).setBorder( new XGradientBorder());
          ((JComponent)getContentPane()).setBackground( Color.cyan );
          setBackground( new Color( 255, 255, 255, 0 ));
        }
       
        //pack(); // LOC 22-3-2007 Commented out dur to problems sizing the dialog bug 1677371
        doLayout();
        titlePanel.doLayout();
      }
     
      public void cleanup()
      {
        removeMouseListener( this );
        removeMouseMotionListener( this );
        b.removeActionListener( al );
        b.removeKeyListener( kl );
        al = null;
        kl = null;
        b = null;
      }

      public void setVisible( boolean show )
      {
        if ( show )
          dialogWindow.doLayout();
        super.setVisible( show );
        if ( !show ) {
          clientFrame.setEnabled( true );
          appWindow.setEnabled( true );
          clientFrame.toFront();

        }
        else {
          toFront();
          b.requestFocus();
        }
      }

//      public void paint( Graphics g )
//      {
//        paintHeaders( this, g );
//
//        super.paint( g );
//      }
//
      // Start of mouse methods-----------------------------------------------------
      public void mouseClicked( MouseEvent e )
      {}

      public void mouseEntered( MouseEvent e )
      {}

      public void mouseExited( MouseEvent e )
      {}

      public void mouseMoved( MouseEvent e )
      {
        if ( bResizable ) {
          Point p = e.getPoint();
          if (( p.x > ( dialogWindow.getWidth() - 15 )) && ( p.y > ( dialogWindow.getHeight() - 15 )))
            setCursor( Cursor.getPredefinedCursor( Cursor.SE_RESIZE_CURSOR ));       
          else
            setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ));       
        }
      }

      public void mousePressed( MouseEvent e )
      {
        startPoint = e.getPoint();
        if (( startPoint.x > ( dialogWindow.getWidth() - 15 )) && ( startPoint.y > ( dialogWindow.getHeight() - 15 ))) {
          doResize = bResizable;       
          if ( !bResizable )
            startPoint = null;
        }
        else if ( startPoint.y > titlePanel.getHeight())
          startPoint = null;
      }

      public void mouseReleased( MouseEvent e )
      {
        Point endPoint = e.getPoint();
        Point oldPos = getLocation();
        if ( startPoint != null ) {
          if ( doResize ) {
            Dimension size = getSize();
            resizeDialog( size.width + endPoint.x - startPoint.x, size.height + endPoint.y - startPoint.y );
            startPoint = endPoint;
            repaint();
          }
          else {
            setLocation( oldPos.x + endPoint.x - startPoint.x, oldPos.y + endPoint.y - startPoint.y );
            repaint();
          }
        }
        doResize = false;
        startPoint = null;
      }

      public void mouseDragged( MouseEvent e )
      {
        Point endPoint = e.getPoint();
        Point oldPos = getLocation();
        if ( startPoint != null ) {
          if ( doResize ) {
            Dimension size = getSize();
            resizeDialog( size.width + endPoint.x - startPoint.x, size.height + endPoint.y - startPoint.y );
            startPoint = endPoint;
            repaint();
          }
          else {
            setLocation( oldPos.x + endPoint.x - startPoint.x, oldPos.y + endPoint.y - startPoint.y );
            mouseDragged = true;
            repaint();
          }
        }
      }
      // End of mouse methods-------------------------------------------------------

      private void resizeDialog( int width, int height )
      {
        setSize( width, height );
        doLayout();
        if ( !hideFrame ) {
          titlePanel.getParent().layout();
          titlePanel.layout();
        }
        getRootPane().layout();
        contentPanel.getParent().doLayout();
        contentPanel.doLayout();
      }
    };

    class HidingDialog extends JDialog implements Cleanup, MouseListener, MouseMotionListener
    {
      Point startPoint;
      XImageButton b = new XImageButton();
      ActionListener al;
      KeyListener kl;
      WindowListener wl;

      public HidingDialog( Frame frame )
      {
        super( frame, bIsModal );
        setResizable( bResizable );
        //getRootPane().getLayeredPane().setLayout( new BorderLayout());

        b.setImage( getCloseImage( 0 ));
        b.setPressedImage( getCloseImage( 1 ));
        b.setRolloverImage( getCloseImage( 2 ));
        b.setBackground( SystemColor.activeCaption );
        b.setOpaque( true );
        addMouseListener( this );
        addMouseMotionListener( this );
        dialogWindow = this;
        if ( !bUseNativeHeaders ) {
          setBackground( SystemColor.control );
          this.getContentPane().setLayout( new BorderLayout() ); // 'this' identifier is needed for Ant compilation

          callDecorationMethod( this, true );

          b.addActionListener( al = new ActionListener()
          {
            public void actionPerformed( ActionEvent e )
            {
              closeButtonID = CLOSE_CLICKED;
              closeDlg();
            }
          } );

          b.addKeyListener( kl = new KeyListener()
          {
            public void keyPressed( KeyEvent e )
            {
              if ( e.getKeyCode() == e.VK_ESCAPE ) {
                closeButtonID = CANCEL_CLICKED;
                closeDlg(); //setVisible( false );
              }
            }

            public void keyReleased( KeyEvent e )
            {}

            public void keyTyped( KeyEvent e )
            {}
          } );

          b.setPreferredSize( new Dimension( BUTTON_SIZE, BUTTON_SIZE ));

          if ( !hideFrame ) {
            titlePanel = new XGradientHeaderPanel();
            titlePanel.setText( title );
            JPanel closePanel = new JPanel( new BorderLayout( 0, 0 ));
            closePanel.setBackground( SystemColor.activeCaption );
            closePanel.setPreferredSize( new Dimension( BUTTON_SIZE + 4, BUTTON_SIZE + 4 ));
            closePanel.add( b, BorderLayout.CENTER );
View Full Code Here


        } );

        b.setPreferredSize( new Dimension( BUTTON_SIZE, BUTTON_SIZE ));

        if ( ! hideFrame ) {
          titlePanel = new XGradientHeaderPanel();
          titlePanel.setLayout( new BorderLayout());
          titlePanel.setText( title );
          JPanel closePanel = new JPanel( new BorderLayout( 0, 0 ));
          closePanel.setPreferredSize( new Dimension( BUTTON_SIZE + 4, BUTTON_SIZE + 4 ));
          closePanel.setBackground( SystemColor.activeCaption );
View Full Code Here

          } );

          b.setPreferredSize( new Dimension( BUTTON_SIZE, BUTTON_SIZE ));

          if ( !hideFrame ) {
            titlePanel = new XGradientHeaderPanel();
            titlePanel.setText( title );
            JPanel closePanel = new JPanel( new BorderLayout( 0, 0 ));
            closePanel.setBackground( SystemColor.activeCaption );
            closePanel.setPreferredSize( new Dimension( BUTTON_SIZE + 4, BUTTON_SIZE + 4 ));
            closePanel.add( b, BorderLayout.CENTER );
View Full Code Here

TOP

Related Classes of net.xoetrope.swing.util.XGradientHeaderPanel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.