Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

From IconView to BetterIconView

DZone's Guide to

From IconView to BetterIconView

· Java Zone
Free Resource

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

As a trainer in the NetBeans Certified Training I regularly deliver the Nodes & Explorer Views (German pdf) session.  During that session, I introduce students to the different explorer views. And, especially for this session, I wrote a small demo program that shows not only the advantages of the views, but also the problems with their representations. Especially the "IconView" stands out with its less than beautiful appearance. So, I made a virtue out of necessity and prepared, especially for the training, my own better  implementation of this view. Thus I can easily show students how to create custom explorer views for the Nodes API.

Toni Epple likes my implementation view and he showed it last December to Jaroslav Tulach. Yesterday Jaroslav had the time to take my few lines of code to replace the old IconView implementation with mine, in the NetBeans sources.

As you can see from the screenshot below, the old "IconView" isn't optimal. The focus is missing, the size calculation of the height amount is too large, and the nodes overlap with long texts:

My new implementation is pretty simple and not perfect in every detail, but certainly a lot better than the old version in the NetBeans Platform.

Here is a screenshot with three selected nodes and a proper focus border behavior:

The source code can be seen here. It is very simple to extend a "ListView" to create a new "IconView".

You should bear in mind that you do not work in explorer views with real world nodes, but with optimized wrappers. In a renderer I convert the given object value to a node with the helper class "Visualizer":

Node node = Visualizer.findNode(value);

Once you have overcome that hurdle, you can realize everything that Swing offers. Your creativity is the only limit. I would like to refer to Geertjans blog where he uses the Visual Library to create an Explorer View.

best regards,
Josh.

Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.

Topics:

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}