Results 1 to 5 of 5
  1. #1
    Join Date
    May 2008
    Location
    India,Kolkatta
    Posts
    50
    Rep Power
    0

    Default Disable Drag mode of Jinternal Frame

    Hi all,

    I just need a code so that i can disable the drag mode of JinternalFrame.
    Please help..

    Thanks in advance..

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    Check the DesktopManager interface.

  3. #3
    Join Date
    May 2008
    Location
    India,Kolkatta
    Posts
    50
    Rep Power
    0

    Default

    Hi Hardwired,
    thanks for your reply.

    i checked the DestopManager interface but i haven't find any method to lock the drag mode of JinternalFrame..

  4. #4
    Niveditha's Avatar
    Niveditha is offline Senior Member
    Join Date
    May 2008
    Posts
    307
    Rep Power
    6

    Default Hi

    check the following code...

    it may help u out..

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

    public class InternalFrameUnMovable extends JFrame
    {
    JDesktopPane desktop;

    public InternalFrameUnMovable()
    {
    desktop = new JDesktopPane();
    getContentPane().add( desktop );

    desktop.add( createInternalFrame(1, Color.RED) );
    desktop.add( createInternalFrame(2, Color.GREEN) );
    desktop.add( createInternalFrame(3, Color.BLUE) );
    }

    private JInternalFrame createInternalFrame(int number, Color background)
    {
    JInternalFrame internal =
    new JInternalFrame( "Frame" + number, true, true, true, true );
    internal.setBackground( background );
    internal.setVisible( true );
    int location = 50 * number;
    internal.setBounds(location, location, 300, 300);
    return internal;
    }

    public static void main(String args[])
    {
    InternalFrameUnMovable frame = new InternalFrameUnMovable();
    frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.setSize(600, 600);
    frame.setLocationRelativeTo( null );
    frame.setVisible(true);

    // Activate first internal frame

    try
    {
    JInternalFrame[] frames = frame.desktop.getAllFrames();
    frames[0].setSelected(true);
    }
    catch (java.beans.PropertyVetoException e) {}

    // Make first internal frame unmovable

    JInternalFrame[] frames = frame.desktop.getAllFrames();
    JInternalFrame f = frames[0];
    BasicInternalFrameUI ui = (BasicInternalFrameUI)f.getUI();

    Component north = ui.getNorthPane();
    MouseMotionListener[] actions =
    (MouseMotionListener[])north.getListeners(MouseMotionListener.class);

    for (int i = 0; i < actions.length; i++)
    north.removeMouseMotionListener( actions[i] );

    }
    }
    To finish sooner, take your own time....
    Nivedithaaaa

  5. #5
    Join Date
    May 2008
    Location
    India,Kolkatta
    Posts
    50
    Rep Power
    0

    Default Wow, ITs Working..

    Hi Niveditha,

    Thanks alot. Its really work.

    Thankyou Niveditha..

Similar Threads

  1. Disable Radio button
    By AJG in forum New To Java
    Replies: 3
    Last Post: 05-10-2011, 11:09 AM
  2. Drag and drop
    By abhivenugopal in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-30-2008, 02:10 PM
  3. disable parent window
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-07-2008, 11:15 PM
  4. Disable BACK and CANCEL buttons in wizard
    By consutes in forum SWT / JFace
    Replies: 2
    Last Post: 11-12-2007, 09:37 PM
  5. Replies: 3
    Last Post: 06-07-2007, 05:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •