eric aro

+ Follow
since Dec 04, 2009
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by eric aro

java events are good, but writing listeners is always very painful !

I used to do that:

And now I can just do that :

The trick is that the last "ActionListener" is in fact the Class
That simply forward every calls to the annotated method of "this".

Of course, I have implemented (generated) the 70 listener available in all J2SE standard packages.

I've just finished it, I would like to have some people testing/feedbacks and information about the Listeners I am missing.

I would need some help doing exactly the same job but using ASM and on the fly generation (to handle every possible listeners).
and also to write "adapter" for the most used Listeners that are not in the J2SE, but I don't know where to start from !

Someone interested ?

here is the project page, a 1.0.0 version is already available.



14 years ago
You must think different.

A UI builder is nothing but an application like the others. Instead of handling, let say, bank account, you'll handle "beans".

java provides a wide set of generic tools to handle beans. That's you model.

To handle a "Bean" you must put it into a "handler box". Something like a panel, with layeredpane and an opaque glasspane ( with transparent color). This will enable you to generically display beans, but catch all the click, and drag gesture, and even draw overlay.

It's the same for a Container. Except that you'll have to handle the drag and drop based on the actual layout for it. I've never seen a visual builder that can handle "generic" layouts. There is always a Handler class for every LayoutManager. Most of the difference between UI builder comes from the quality of their LayoutManager HandlerSSS

Then, at last, when you have a tree of beans, you can generate code, or XML description, to makes it possible to access the actual view at runtime.
14 years ago
1/ use a main vbox or VBOxLayout, then a gridbaglayout for the buttons (with an vertical and horizontal spacing)

2/ unless this is a teaching lesson (in witch case by hand is much better), otherwise use a visual builder, you'll have found all your answers in a matter of hours. Such a layout takes 10 minutes with a visual builder.

14 years ago
for small programs, using maven, (or by hand) you can package all your classes, and all dependencies classes into a single jar.

then you use launch4j with the option "embed jar", and you'll get an independent exe, that works right out of the box.

This solution is nice, but not scalable for big programs (with megas of dependencies )

14 years ago
here for the official website

and for their forum :

their doc :

they've got very good pdf with very well documented examples.

14 years ago
here is my cookbook:

of course make a heavy use of MVC (and don't forget that there are THREE stuff in MVC)

design the view in a visual builder, and DO NOT use code generation. (like glide does, of jofrmdesigner or netbeans). Not generating code its important. These tools generates an XML UI file.

create a controller class, and use injection ( with annotation in my case) to get the necessary widgets from the XML UI file, and "mark" the callbacks (signals in glide, event in jfromdesigner).

As a rule of thumb, controllers should not store anything. There are two kind of controller ( for me) single and collection (that's my own private naming convention, do not expect to see it ini the outside world).

single controllers controls a single model and a single view.
collection controller handles a collection of models. Therefore the main algorithm for a dynamic controller is to find the right static controller for the given model object. ( using either class name, or any other information ).

When you're gui starts growing, you'll find necessary to share some graphical features among controllers. For instance, an error displayer (something that make a panel visible in the north, with the error message), a tab appender/manager (like in firefox) etc. .
Design it as controller service. (a service to display an error, a service to ask for a file etc.)
Creates interfaces for each of these services, and use injection to get those services.

Whatever the injection service you use ( spring, iOsgi, or your own, it's easy to do) this structure is quite robust :

widgets layouting in an XML UI
controllers that focus on there job
shared "services" among the gui, that is passed through the code using injection.

You can start writing useful components.

14 years ago

It's not very clear to me, but as far as I've understand, you should just consider settings the "contentType" attribute of you editorPane to "text/html" and that will do it.

But, as far as I know, editorpane is a little buggy, with respect to copy paste, and lists... (it add useless extraneous space).

But, again, this might not be your question.

14 years ago
not at all.

I've been looking at the docking "extracting" from netbeans but I don't what has happened to the project but nothing was working. That's why I selected DockingFrames.

But you still can use any visual builder with any docking framework.

I use JFormDesigner along with DockingFrames, and everything works just fine.

14 years ago
that seems nice.

Jtable can auto generate header sorter, so that you can sort you pizzas as you want ( order # or due time )
14 years ago
that it is called a docking framework, and I'm a happy user of DockingFrames ... A bit weird at first, but very efficient, and well designed ( switzerland quality ... ;-) )
14 years ago

Theresa Marlin wrote:I have to create an applet, and I was wondering if there is any way to create a triangle and fill it in with a different color than background color. I know you would use drawLine for the three lines in the triangle, but is there some way to fill it in, different from the rest of the background?

Also, is there any way to insert text into an applet?

Thanks for your help!

The best way to do is to use polygon, graphics2D. The Graphics you usually get in the paint() method is a graphics2D just cast it as graphics2D and enjoy the full list of methods, and Shape in particular.
14 years ago

Rob Camick wrote:

Or you could have just used a visualBuilder...

Completely disagree.

When you learn the proper method in Java you learn something that will work anywhere you write Java code.

When you learn how to do it in an IDE you don't learn anything about Java and you won't know how to to solve the problem when you switch IDE's.

Its better to spend the time learning Java and the proper coding techniques, instead of depending on an IDE to generate the code for you.

JavaBeans are pretty clear:
JLabel has an attribute called "opaque", and you just have to turn it on. And that's the actual lesson he got.

Where the hell did you see any "IDE dependent way to do" ?

But the most interesting part is the "learning curve" :
I had several trainees, and without visual builders, they almost all get "stuck" on this classic pitfall. On the other hand, with a visual builder, they all give this attribute "opaque" a shot, and learn by themselves this trick.

Therefore, IMHO, It's not fair to let newbies believe that visual building is evil. They will loose so much time, and code visual interface with so much fear !! Instead drawing a GUI, can be/should be fun !

I know that's a kind of religion war. I was in the "no visual builder" side, long time ago. But I've experimented both (that's what trainees are for, aren' they?) , and, bottom line, it's pretty clear.

I don't want to convince you, but just leave the message for the newcomers to java: learn MVC, and draw you V in a visual builder.

14 years ago

Will Barbee wrote:Just another note of thanks to Pete Stein.

Those createXXX methods are really good. I added ComboBox and CheckBox.

They really keep the mainline code clean.


Or you could have just used a visualBuilder , and when looking at the JLabel bean attributes see that "opaque" one, and just give it a try ( yes, in a developer mind, opaque is somehow related to color, isn't it ? )

with a visual Builder you get the feedback in a matter of seconds, whereas, posting to a forum (even a nice one) is matter of hours, or days.

14 years ago
here is my best solution :

Override GradientPaint (easy part) to HSVGradientPaint
copy paste/ GradientPaintContext into HSVGradientPaint (easy part)

there is an ugly code from sun that I can't get rid of (if someone has a deep knowledge on how to work on raster ...)

and replace the interp array filling (in the construcor) with one that matches HSV color.

here is the master piece, use this function to fill the "interp" array instead of the original code.

and BTW I would realllllllly like to find a better solution.


(ps: attachement does not work, here is a copy paste of the whole solution )
14 years ago