Re: [Java-gnome-developer] Creating custom container
Brought to you by:
afcowie
From: Jacek F. <ja...@gm...> - 2008-12-18 12:57:53
|
Andrew, thanks for your response. If I subclass a different class than container, how do I override its default layout management logic so that I can do it myself? Let me maybe explain what I want to do: my end goal is to port the amazing Swing/SWT MigLayout layout manager to run on GTK+ (java-gnome actually, since it's a pure Java library). MigLayout is UI toolkit agnostic and needs only 3 classes to implement the toolkit-specific logic. http://www.miglayout.com So, since GTK+ does not have the concept of a layout manager, but just specialized containers with hardcoded layout management logic, I want to create something like a MigLayoutContainer, e.g. MigLayoutContainer c = new MigLayoutContainer("wrap 4","[pref] [grow] [pref] [pref]"); c.add(new Button(), "sg 1"); c.add(new Button(), "sg 1"); This code above would create a container that automatically wraps to the next row every 4 controls that are added. Columns 0, 2, 4 have the preffered control width, while column 1 resizes as the window resizes. The two buttons that were added would automatically have the same size (width/height) because they belong to the same size group. So, if I subclass a different GTK+ component, what do I need to do to override its layout management logic and implement my own from scratch? This is what I am trying to do. Don't get me wrong, GTK+ is an impressive toolkit, but their approach to layout management (Vbox. HBox, Table) is rather outdated compared to the best alternatives in both the Java and .Net world. Thanks, Jacek P.S. Some more info about me: I am the creator of the Java SwingBuilder and SWTBuilder, two libraries that aim to maximize Java UI development productivity by allowing declarative UI building in YAML: http://javabuilders.org My end goal is to port my library to run on top of java-gnome as well to bring the same productivity enhancements to creating native GTK+ apps in Java (since I am an avid Linux user and am saddened by the lack of Java apps on Linux...I think we're getting beaten badly in this area by Python and even Mono these days). Thanks for any assistance or guidance you may give me, much appreciated in advance. |