Results 1 to 9 of 9
  1. #1
    indra00 is offline Member
    Join Date
    Jun 2010
    Location
    India
    Posts
    8
    Rep Power
    0

    Question Creating Sliding Panels

    The objective is to develop (using Java) a GUI component that acts like a multi-slider. The idea is to develop a GUI component (like a slider) which partitions a certain value (100 for example) into several partions where the borders in-between can be dragged to slide up/down to distribute the values of each compartment. The number of compartments should be flexible as well as text labels right-hand sided for each compartment. The numeric value for each compartment should also be visible.

    See the attached pic as an example that partitions the value 11 into the parts 3,3,1,4 as an example. The user can slide each compartment's boundary to increase a certain value while the other one(s) decreases accordingly. The initial state should be an equal distribution and the user can drag each boundary to adjust values.


    This Is What I want to create. But I dont have a lead.I am confused- should I look to create multiple panels based on input and then resize panels dynamically using mouse drag? Any kind of help will be greatful regarding this.. like how to approach the problem. Or if you have a class that can be helpful in this context.
    SEE ATTACHED PIC FOR BETTER understanding .
    Attached Thumbnails Attached Thumbnails Creating Sliding Panels-scribble.jpg  

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default

    Have a look at the JSplitPane component. You can nest a few of them.

    kind regards,

    Jos

  3. #3
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Default

    Emm...

    I dearly hope I got the question... Anyway...

    You mean something like a sliding panel? When you can see always the limited number of components?
    You can simply
    1) create a JPanel panel with FlowLayout manager.
    2) Put all panel components into a vector/List or something like that.
    2.1) Add these components onto your panel
    3) create two JButtons "Left" , "Right" or something
    4) with these buttons control the panel components visibility
    5) Then you can manipulate with components visibility

    For example a little schema:

    we have panel A which contains 10 components, visible components are limited with || we can see always 5 of them

    Step 1:

    panel A
    ===============
    A B |C D E F G| H I J
    =====visible======
    buttons |<<| |>>|

    Step 2 (Right button clicked):
    panel A
    ===============
    A B C|D E F G H|I J
    ===============
    buttons |<<| |>>|

    As you can see with this example we should make component C setVisible(false).

    It is not a common swing task I guess so you'll have to try much to program it. But the idea is clear I hope ;)
    Last edited by Webuser; 07-11-2010 at 12:06 PM.
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  4. #4
    indra00 is offline Member
    Join Date
    Jun 2010
    Location
    India
    Posts
    8
    Rep Power
    0

    Default

    @webuser srry u got it wrong.... I want the horizontal panels[how many is user given ]... now all panels can be resizable in the window using mouse to drag it by border. And when say one panel is expanding the other will automatically shrink to keep the total hieght of the panels same.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by indra00 View Post
    @webuser srry u got it wrong.... I want the horizontal panels[how many is user given ]... now all panels can be resizable in the window using mouse to drag it by border. And when say one panel is expanding the other will automatically shrink to keep the total hieght of the panels same.
    Try the nested JSplitPane option I suggested in reply #2.

    kind regards,

    Jos

  6. #6
    Webuser is offline Senior Member
    Join Date
    Dec 2008
    Posts
    526
    Rep Power
    0

    Lightbulb

    Quote Originally Posted by indra00 View Post
    @webuser srry u got it wrong.... I want the horizontal panels[how many is user given ]... now all panels can be resizable in the window using mouse to drag it by border. And when say one panel is expanding the other will automatically shrink to keep the total hieght of the panels same.
    Then I think it is OK with JSplitPane. But use JSplitPane.VERTICAL_SPLIT parameter to get your image effect :)
    Last edited by Webuser; 07-12-2010 at 11:11 AM.
    If my answer helped you. Please click my "REP" button and add a comment
    Have a Good Java Coding :)

  7. #7
    indra00 is offline Member
    Join Date
    Jun 2010
    Location
    India
    Posts
    8
    Rep Power
    0

    Default

    Thx man! I overlooked the JsplitPane..... I will try with that:D Never worked with this clas before though :p but thx for the info

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,524
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by indra00 View Post
    Thx man! I overlooked the JsplitPane..... I will try with that:D Never worked with this clas before though :p but thx for the info
    So you managed to miss both my reply #2 and reply #5? If you ask a question here you definitely should read the answers and suggestions.

    kind regards,

    Jos

  9. #9
    indra00 is offline Member
    Join Date
    Jun 2010
    Location
    India
    Posts
    8
    Rep Power
    0

    Default

    @ Jos Lol no... I missed the 2nd but read the 5th ... my last thx msg was actually for you :) peace ! :)

Similar Threads

  1. Not understanding panels and layout?
    By lost_soul in forum New To Java
    Replies: 3
    Last Post: 04-09-2010, 04:31 PM
  2. Creating a time sliding window..urgent
    By sm123 in forum New To Java
    Replies: 1
    Last Post: 03-12-2010, 03:12 AM
  3. resizeable panels
    By simo_mon in forum AWT / Swing
    Replies: 4
    Last Post: 07-29-2009, 01:45 AM
  4. Working with Labels on Panels.
    By vargihate in forum AWT / Swing
    Replies: 2
    Last Post: 01-04-2008, 04:09 AM
  5. Need a tutorial for Studying about Panels
    By ramachandran in forum New To Java
    Replies: 1
    Last Post: 10-25-2007, 09:05 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
  •