It took a while, with lots of fiddling and lots of mistakes to get a working dialog going. I’m not sure what it is about java Jdialog / Joptionspane / Jframe but they just don’t add up at first. Even after trawling the net for examples and reading the netbeans swing getting started with dialogs guides, it still wasn’t apparent how I could construct a dialog that was not just a simple message, but was like a JFrame with standard OK / Cancel / etc. buttons that honoured the look and feel of the host UI.
I tried creating a JFrame and just adding buttons at the bottom, but these didn’t automatically get the standard UI OK cancel icons or did it have the default return=ok escape=cancel behavoir. I then tried adding an option pane aligned to the bottom of the frame, but that was a nightmare: it wouldn’t resize correctly and I just could not believe it was this difficult to do.
Then when trawling the net I noticed an example of a JOptionPane, that for some reason didn’t set the message parameter to be a String. It’s called message for God’s sake, so I always passed it a “string message” which it duly displayed. I never really noticed that it was declared as an Object.
So once I noticed this, I then tried to add a JFrame to it, which failed, and then I finally found out I can add a JPanel and the contents of the JPanel gets nicely formatted and aligned in the optionpanel as expected. Wahey
I was even more impressed when I set the JOptionPane messageType and it duly put the nice icon on the left and still formatted the dialog correctly.
So all I needed to do now was be able to add some validation mechanism to the panel so the Ok button was enabled and disabled. The result follows:
Read the rest of this entry »
Like the CompoundIcon class, the OverlayedIcon class that follows allows multiple images to be used wherever an Icon can be used. The difference is that the class overlays the icons on top of each other (in the order they are in the array or appended). Each image is rendered, centered to the maximum image size.
I use this class to display saved state for items in the VisualErlang solution. If an item needs saving, a save icon is overlayed in the bottom right of the nodes icon.
Read the rest of this entry »
Whilst building the Visual Erlang IDE, I came across the requirement to display more than one Icon against the nodes in a Jtree. After several hours /days of building custom TreeCellRenderers and TreeCellEditors, inspiration hit. The JLabel can only display one icon, so lets override Icon to display more than one icon, but pretend it’s just a single Icon still.
The following Java class implements a CompoundIcon. Simply create an instance of it passing in the array of Icons you wish to be displayed. Use setSpaceSize to change the space between the icons when the are rendered. Use add, to append new icons if needed after the class has been constructed.
The instance can then be used wherever and Icon is needed.
Read the rest of this entry »
I am working my way through the main IDE application at the moment. So far, you can create a new solution, and add new modules to it. The solution is shown in a hierarchy, with modules existing underneath in
the “File View”. Each Module can have a package name, e.g. org.visualerlang.framework, similar to a java package name. This defines the name space and controls the eventual output name of the erlang code module. The “Package View” shows the solution, broken down in a hierarchy of packages, eventually with the appropriate modules held against each package.
Eventually a module will have one or more functions associated with it, which can be marked as public or private, i.e. if the function is exported or not….
Want to know what Visual Erlang is all about ? Click What is it above
I’ve started building it in Mono, so it should hopefully be able to run on windows as well.
After a couple of weeks of Mono development without being able to debug, I’ve given up on mono (a shame really as I love c#) and have resorted to building a java version instead.
Why not bookmark our RSS feed and keep up to date with the progress.