Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: JButton Help

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JButton Help

    See i have a frame and it contains multiple panels

    These panels contain buttons

    Now i want to add a feature in my frame that the user can change the position of the panels by dragging them anywhere in the frame like JTable columns can change their position

    So can anybody help me please


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JButton Help

    When you mention JTable, I'm thinking you just want to drag to change the panel size? If so, then a JSplitPane, or combination of several JSplitPanes, may work well for what you want. If you really want to be able to drag the panels and drop them elsewhere, then you need to code in drag and drop functionality, which is a lot more complicated

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JButton Help

    Thanks for ur reply but i am making a dock in that i have dock items stored in JPanel so now i want to add functionality to it that the user can drag and drop the panel as per his/her requirements.

    So if there is any way then guide me the approach toward this problem

    Thanks in advance

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JButton Help

    To do so is not trivial, so I will point you to Introduction to DnD (The Java™ Tutorials > Creating a GUI With JFC/Swing > Drag and Drop and Data Transfer). You could also google 'drag and drop java jpanel' (or something to that effect) and perhaps dig up some code that does something similar to what you want.

Similar Threads

  1. How to Add ActionListener to a JButton in Swing?
    By JavaPF in forum Java Swing Tutorials
    Replies: 17
    Last Post: April 24th, 2013, 05:14 PM
  2. Again Interesting JButton query
    By ravjot28 in forum AWT / Java Swing
    Replies: 0
    Last Post: January 14th, 2010, 11:22 AM
  3. [SOLVED] Interesing JButton Query
    By ravjot28 in forum AWT / Java Swing
    Replies: 2
    Last Post: January 14th, 2010, 11:19 AM
  4. JButton...
    By chronoz13 in forum AWT / Java Swing
    Replies: 1
    Last Post: November 27th, 2009, 11:39 AM
  5. need help with JButton and switch statements
    By jjoubert in forum AWT / Java Swing
    Replies: 5
    Last Post: October 28th, 2009, 09:13 AM