Java Programming Tips and Tricks

This document contains miscellaneous "magic formulas" and other useful stuff I've had to invent because I couldn't find it already on the web (or got tired of hunting for after the fifteenth attempt). The material is presented in the form of comments which you can just copy and paste to your source files. If you have better solutions I'd love to see them.


/*  // HEXADECIMAL "HTML COLOURS" <-> java.awt.Color
    
    // Get java.awt.Color from hex string for display in applet
    String s = "FF00FF";
    Color c = new Color(Integer.parseInt(s.trim(), 16));

    // Get six-digit hex string from java.awt.Color for use in html output file
    Color c = Color.blue;
    String s = Integer.toHexString(c.getRGB());
    s = s.substring(s.length() - 6);
*/