Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » AnchorLayout(a new layout manager designed by me)
AnchorLayout [message #897433] Tue, 24 July 2012 06:56 Go to next message
Ossama Nasser is currently offline Ossama NasserFriend
Messages: 10
Registered: July 2012
Junior Member
Hello this is my first post at eclipse forums so I hope you like it
I've been thinking a lot about java swing and how it's easy to build GUIs in other IDEs (like Delphi and Visual Studio) and how hard it is (for me at least) in NetBeans and eclipse .
So it hit me : why don't I design my own layout manager that acts like the other IDEs.
But dreaming is easy, I designed the anchor layout manager and I had few problems :
What's good about it :
It uses size and location to position a visible component on the container (like absolute layout) and it uses easily defined anchors to set the problem of resizing and repositioning when the container size changes , how ?
When you add a component to the container you add an instance of the class AnchorConstrains which in turn asks you to define the anchor (Top ,Left ,Right ,Bottom and it's combinations) along with location and size ,and based on the anchors the layout define resizing and/or repositioning
Despite the layout manager changes the size of components in some cases it cannot make components smaller than minimum size or bigger than maximum size
If we define minimum size with 0 (width and/or height) the layout manager doesn't use it ,so when we reach at resizing the case where component size can be zero or event negative the layout manager takes the previous size which in this case is positively positive
And to override max size lock you simply have to make the value of maximum size either big enough to never be reached by preferred size or simply 0
I do believe that some things sound mysterious to you because I'm not that good at explaining with words but the way the layout manager works is easy and simple and I doubt you will have a problem with it
What's bad about it :
Though I searched online a lot (but not enough apparently) to know how to define the layout manger to work with windowBuilder ,I failed , so here it is how the layout manager must operate in windowBuilder :
o Like absolute and Group layouts we must be able to drag and drop components on the container defining the constrains of the location and size (anchor is set default to TOP LEFT) with the ability to change them along with anchors as the user wishes
o Anchor layout cannot be shared : windowBuilder creates a JPanel and replaces the JFrame content pane with it ,checking the parents does not work properly because the layout manager needs the size of the container so when we pass the content pane as the target the size will be (0,0) so all the calculations will be wrong

So the bottom line is I have these to problems for now ,can I count on you to help ?
I have attached the source files with a simple demo and JavaDoc
  • Attachment: OSwing.rar
    (Size: 61.60KB, Downloaded 215 times)
Re: AnchorLayout [message #897666 is a reply to message #897433] Wed, 25 July 2012 03:31 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
I'm not quite sure what question you have.
You could look how Group layout or MigLayout are done to see how to add support for new layout manager.
Copy it, change ID's, clean up everything what you don't need and start adding specific support for your manager.
If you have any specific questions, ask them.


Konstantin Scheglov,
Google, Inc.
Re: AnchorLayout [message #898296 is a reply to message #897666] Thu, 26 July 2012 07:07 Go to previous messageGo to next message
Ossama Nasser is currently offline Ossama NasserFriend
Messages: 10
Registered: July 2012
Junior Member
I tried and I opened all sources I could find but I didn't find what I want,but thanks anyway I'll go back and see if I could find what I need
Thanks ,at least you took the time to download and see the layout
Re: AnchorLayout [message #898663 is a reply to message #898296] Fri, 27 July 2012 06:45 Go to previous messageGo to next message
Ossama Nasser is currently offline Ossama NasserFriend
Messages: 10
Registered: July 2012
Junior Member
Today I have 3 questions :
First I found this class called GroupEditPolicy in GroupLayout jars with a little help of DJ java Decompiler I decompiled it a found several imports like : org.eclipse.wb.core.gef.policy.PolicyUtils;
org.eclipse.wb.draw2d.geometry.Dimension;
org.eclipse.wb.gef.graphical.GraphicalEditPart;
... etc.
So the question :
A. Am I in the right direction ?
B. If I am in the right direction ,what references shall I read to know about these classes ?
C. If I am not in the right direction ,which direction it is ?


Re: AnchorLayout [message #898763 is a reply to message #898663] Fri, 27 July 2012 13:29 Go to previous messageGo to next message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
Why decompile when you can just download the actual source?

WB contains a large number of examples of implementing different types of layouts, so I would recommend downloading the WB source and learning directly from that. SWT FormLayout and Swing SpringLayout are both anchor-type layouts and would provide good examples. GroupLayout is quite a bit more complicated IMO.
Re: AnchorLayout [message #899240 is a reply to message #897433] Tue, 31 July 2012 08:15 Go to previous messageGo to next message
Ossama Nasser is currently offline Ossama NasserFriend
Messages: 10
Registered: July 2012
Junior Member
I forgot that windowBuilder is open source
thanks a lot for reminding me
downloading the source now
Re: AnchorLayout [message #915423 is a reply to message #899240] Mon, 17 September 2012 08:36 Go to previous messageGo to next message
Ossama Nasser is currently offline Ossama NasserFriend
Messages: 10
Registered: July 2012
Junior Member
Guys :
Is there a link where I can download windowbuilder source code in manner of compressed file ,because when I looked I found the svn link only ?
one more think are you planing to publish some kind of understandable tutorial about writing components for windowbuilder as well as documentation to know what to do ?

[Updated on: Mon, 17 September 2012 08:37]

Report message to a moderator

Re: AnchorLayout [message #932219 is a reply to message #915423] Wed, 03 October 2012 23:49 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
No, the SVN repository is the only place where we store source.
We don't have plans to publish additional tutorials.


Konstantin Scheglov,
Google, Inc.
Previous Topic:windowbuilder exception showing the gui with seaglass L&F
Next Topic:How to Get Externalized Property Keys from Expression
Goto Forum:
  


Current Time: Fri Apr 19 08:14:51 GMT 2024

Powered by FUDForum. Page generated in 0.02083 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top