• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to create resizable swing components as in Netbeans Swings (GUI), drag and drop?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi every one,

How to create resizable swing components as in Netbeans Swings (GUI), drag and drop?

I have a requirement where in i have to create resizable swing components (JTextfield, JLabel....) with drag and drop functionality...
Also i need to set some custom properties to each component.....(through JPopupMenu)

need help
thanks
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check this out
http://www.jroller.com/santhosh/entry/resizable_components
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply.........

i tried and succeeded.........but failed to get the scrollbar in the panel.
how to display the scrollbar when a component is dragged beyond the panel dimensions?

 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Scrollbars appear automatically when the "preferred size" of the component added to the scrollpane is greater than the "size" of the scrollpane.

So, if you are dragging components around a panel you need to dynamically recalculate the preferred size of the panel every time you move a component.
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to dynamically recalculate the preferred size of the panel every time you move a component ?

I have added the ComponentListener to the dragged component and set the preferred size, but nothing happened

Note:
actually i dont know how to calculate the preferred size, instead i have harcoded the values for verification......but nothing happened..
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply...
Note: Here the panel layout is set to null
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have added the ComponentListener to the dragged component and set the preferred size, but nothing happened



You need to set the preferred size of the panel, which means you need to loop through "all" the components on the panel to find the greatest x/y values because they could belong to different components.
 
Abhishek Reddy
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply.......

iam facing the following problems...

1.Unable to get the scrollbar when the component is created at the borders of the panel........but, upon dragging the component scrollbar is displayed.

2.How to display scrollbar, when components are moved towards South and West directions? (or) how to stop moving the components, when they reaches South and West borders?
Note: Succeeded in displaying the scrollbar, when components are moved towards East and South directions


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic