Results 1 to 4 of 4
  1. #1
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Exclamation How to create a Draggable environment inside JFrame

    Greetings,

    I am developing a mapping feature in my system.
    Inside the mapping feauture are only JPanel, wherein I can drag those JPanel where I want and lock them after I seen my proposed map.

    My question is, what Class in the javax.swing package am I going to use and what methods am I going to utilize then?

    Feel free to ask questions to further detail the thread.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Certainly you'll use a MouseListener as well as a MouseMotionListener which can be combined in a class that extends MouseAdapter. There are many ways to solve this but one possible way is to use a JLayeredPane to hold all, to place any background in the background layer and anything being dragged in the layered pane's drag layer. An example of this in a simple chess demo is here: questions about events in differents layers

  3. #3
    chyrl is offline Senior Member
    Join Date
    Mar 2010
    Location
    Manila, Philippines
    Posts
    257
    Rep Power
    5

    Default

    Thanks, I let you know if I have implemented it in a different approach.
    Every project, package, class, method, variable, syntax, algorithm, etc.
    are registered in my memory bank. Thanks to this thread.

  4. #4
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

Similar Threads

  1. Launch native app inside a JFrame???
    By benedums in forum Advanced Java
    Replies: 6
    Last Post: 02-25-2011, 03:23 PM
  2. Switching JPanels inside JFrame attempt
    By frenk_castle in forum AWT / Swing
    Replies: 7
    Last Post: 03-31-2010, 08:39 AM
  3. How to add JFrame inside JPanel
    By niteshwar.bhardwaj in forum Java 2D
    Replies: 8
    Last Post: 12-13-2009, 08:41 PM
  4. Centering inside a JFrame
    By kahaj in forum AWT / Swing
    Replies: 9
    Last Post: 09-23-2009, 07:23 PM
  5. how to create environment variables
    By elizabeth in forum Advanced Java
    Replies: 4
    Last Post: 08-02-2007, 04:53 AM

Posting Permissions

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