What's Here?
It occurred to me that I've written some useful code for the various projects on this page. However, people may not actually have any use whatsoever for my projects (for shame) and could miss some code that they need for an application they're working on. This page is a collection of classes and modules which are handy by themselves that I originally wrote for some project here. As usual, everything here is free and covered by the GNU General Public License.


Java Classes
MidiPlayer.java (9.04 kb) A simple class to play a single MIDI file or a list of files. It also supports looping the playlist, which is not as easy as it should be.

PathResolver.java (9.43 kb) This is an abstract class that contains two static methods for resolving absolute and relative paths. For example:

PathResolver.getRelativePath("c:\\folder1\\sub-folder1\\","c:\\folder2\\") --> "..\\..\\folder2\\"

PathResolver.getAbsolutePath("c:\\folder1\\sub-folder1\\","..\\..\\folder2\\") --> "c:\\folder2\\"

LaunchBrowser.java (7.98 kb) This is a class that launches the OS default web browser from a Java application. When I was working on Jail I wanted to be able to launch the help files from a menu. Since Java is platform independent there is no simple way to launch a web browser. My first idea was to write a lightweight HTML container to display the help files but what I came up with was so monstrous that I'd be embarrassed to post it. Although I consulted a number of articles and discussion forums on this topic, the resulting code for this class was original work.

IniFile.java (7.53 kb) This is a class to read/write old-school .ini files from Java. I first wrote this for Hapsby to store user preferences. I suppose this should be obsolete with the introduction of the Properties API in JDK 1.4. However, I've found the Properties API to be unnecessarily complicated so I'm sticking with .ini files.

NumberConverter (10.1 kb) There are three classes in here that at the end of the day create a JPanel that converts decimal<->ascii<->hex<->octal<->binary. Originally wrote this for Hapsby even though it only needed decimal<->hex conversions.

LogFile.java (6.46 kb) As the name implies this creates a simple log file. I mean a very, very simple log file. It really just opens a file and appends lines. I suppose this could be obsolete since JDK 1.4+ has a Logging API. However, much like the Properties class discussed above it is mildly inconvenient to use. First wrote this for Hapsby, but it's used in Jail too.

SplashScreen.java (6.84 kb) This is a fairly lightweight splash screen. Like LaunchBrowser, I looked at articles and discussion forums to figure out how to do this. The resulting code was all original work though. I first wrote this for Hapsby, but it's used in Jail too.

ZipCompressor.java/ZipDecompressor.java (7.84 kb) Nothing too advanced here. These are just two classes to make zipping and unzipping files easier. Wrote these for Hapsby as part of the autobackup feature.

FortuneCookie.java (8.54 kb) I think some versions of Linux have a feature like this. All it does is return a random fortune from a list. That's all. I never found a nice way to incorporate it into any of my projects.

ImageCropDemo.java (6.54 kb) A while ago I was contacted by someone who was working on a game in Java. The game map was going to be one giant gif and they wanted to be able to crop and scroll it to fit the visible field. For some reason they asked if I knew how to crop images in Java. I didn't, but figured it out in about an hour and sent this class back to them. Don't know what ever happened with the game though..


JavaScripts
ShowImageDialog (13.2 kb) This is a JavaScript to pop-up an image in a dialog and size the dialog to fit the image. Click on the image to the left for an example.

Currently only works correctly with Internet Explorer, the resize doesn't work in some versions of Netscape or Mozilla.


C# .NET Demos
Click for full size image
DirectoryEntryDemo (26.7 kb) This program demonstrates how to perform some simple, yet common, operations using the System.DirectoryServices.DirectoryEntry class. It loads a list of all available domains into a combo box, selecting a domain loads a list of all users in that domain, and selecting a user displays all their available properties.  

Note: if you try to use this code in an ASP.NET application it will fail because you can not anonymously query Active Directory for user information. You'll have to use impersonation and run the code under the identity of the user visiting the site. There's a guide to doing so at: http://support.microsoft.com/default.aspx?scid=KB;en-us;q306158


Support
Everything on this site is free. I'll never use pop-ups or randomly generated ads to support it. If you've found something here to be especially helpful or entertaining please consider making a small donation. This can be done through a secure PayPal transaction or by purchasing one of the related items below. Thanks for visiting my little web page! 
Make a secure donation for any amount via PayPal.







Legal Notes


Unless otherwise noted, all content is copyright (c) 2000-2006 Hugues Johnson and may not be redistributed in any form without express permission.

index
feedback