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 2 of 2

Thread: Drag and drop scrolling problem

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Drag and drop scrolling problem

    Hi,

    I have a problem with drag and drop in swing. Im hoping i can get this question answered without actually showing any code as i think its just theory. Basically I have a JScrollPane which is made up of a JTable, JLabel (Just a black separtor line) and JTable. The pane is quite small so if the number of files in say the bottom JTable is so much that the user needs to scroll up to drag and drop into the top JTable I start to encounter problems. Basically, it loses 'focus' when it hits the JLabel and no longer scrolls up so the user can never hit the top JPanel target.

    Any ideas on how this can be resolved would be much appreciated as i have spent hours trying to fix this now.

    Thanks,
    Jack


  2. #2
    Member snowguy13's Avatar
    Join Date
    Nov 2011
    Location
    In Hyrule enjoying a chat with Demise and Ganondorf
    Posts
    339
    My Mood
    Happy
    Thanks
    31
    Thanked 48 Times in 42 Posts

    Default Re: Drag and drop scrolling problem

    Hmm... Well I haven't worked with JScrollPane much, but I'll try to offer some help.

    First of all, I may suggest making your JScrollPane bigger. This is my simplest solution, but also a rather volatile solution...

    If you don't like the first solution (I don't ), then maybe you could try using a FocusListener (documentation here). You could add it to the JLabel that is causing the problem, and tell one of the JTables to request the focus whenever the JLabel retrieves it.

    Maybe an alternate solution if you don't want to mess with FocusListeners: you could use two JScrollPanes, one for each JTable, instead of one. This way, both of your JTables would always be displayed no matter what, because they would each have their own individual JScrollPanes to navigate their contents.

    Here are some links if you want to do some rummaging around of your own:
    Focus Subsystem Tutorial
    JScrollPane Documentation (Java 7)
    JScrollPane Tutorial

    Good luck on your project!
    Use highlight tags to help others help you!

    [highlight=Java]Your prettily formatted code goes here[/highlight]

    Using these tags makes your code formatted, and helps everyone answer your questions more easily!




    Wanna hear something funny?

    Me too.

Similar Threads

  1. Drag and Drop in JTrees
    By helloworld922 in forum Java Swing Tutorials
    Replies: 4
    Last Post: March 21st, 2014, 11:16 AM
  2. [SOLVED] Question: Drag and drop tut.
    By PierreD in forum AWT / Java Swing
    Replies: 2
    Last Post: June 6th, 2011, 07:24 AM
  3. [SOLVED] Drag and drop in MVC
    By Alice in forum Object Oriented Programming
    Replies: 9
    Last Post: December 9th, 2010, 10:16 PM
  4. Drag and Drop in JTrees
    By helloworld922 in forum Java Code Snippets and Tutorials
    Replies: 2
    Last Post: February 20th, 2010, 03:52 PM
  5. Drag and Drop in JTrees
    By helloworld922 in forum AWT / Java Swing
    Replies: 2
    Last Post: January 19th, 2010, 11:51 PM