java

recent posts related to java, jdbc, spring, etc.

An Easy Rules example (a Java "rules engine")

I’m considering using Easy Rules as a simple “rules engine” in my Android Football Game application, primarily because (a) there are a ton of “rules” involved in having the computer call offensive and defensive plays, and (b) I’m trying to find a way to simplify that code and make it more maintainable.

The Easy Rules website has a Hello, world demo you can look at to get started, but after that, here is my example.

AlPad - A simple "scratchpad" editor

Over the course of a few hours this past week I created a little “scratchpad” text editor I named AlPad. It’s gone through several names, but since I’m just writing it for me, the name seems appropriate.

It’s not really correct to call AlPad an “editor”; it’s really just an app where I can keep a collection of miscellaneous notes I usually make when I’m working. It has very few features, just some ones I want and can implement easily:

How to get the default system font in a Java/Swing application

I haven’t tested this with other Java components, but if you want/need to get the “system font”, this code gets the default system font from a JEditorPane component:

val outputArea = new JEditorPane
val fontFamily = outputArea.getFont.getFamily

That code is written in Scala, but as you can see, it converts easily to Java. On Mac OS X 10.10, fontFamily ends up being “Lucida Grande”.

How to display an image in a JEditorPane using HTML

If you ever need to display an image in a Java JEditorPane, where that JEditorPane contains HTML content, this solution should work:

books i've written

new