Tuesday, August 11, 2009

Code Formatting Test

Just testing the syntax highlighting:

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
setOpaque(true);
Color original = g.getColor();

switch (status) {
case INACTIVE:
g.setColor(Color.WHITE);
break;
case WARNING:
g.setColor(Color.YELLOW);
break;
case ERROR:
g.setColor(Color.RED);
break;
default:
g.setColor(Color.GREEN);
}
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(original);
}

Hopefully this will work....

Well, this looks good. I don't like the little toolbar covering the code, but if you click the "View Source" (first item in the toolbar), you get a nice pop-up with the source displayed - great for copying the code too. Overall, it looks really good (even though it mucked up my spaces a bit - we'll see how bad this is when the code is larger and spans more than one method).

To achieve this, I simply followed the instructions here and performed HTML encoding of my code here (which wasn't needed for the code I used, but an important step nonetheless). I wish Blogger handled code better by default, but this works. Next post, we will finally get to code for the simplistic Swing app.


NOTE: I will try and limit the characters-per-line in my code to avoid excessive line wrapping. This will not be totally avoidable since my blog template has such a limited width. I may have to modify my template at some point if this is an issue.

No comments:

Post a Comment