Sunday, April 16, 2006

Two java tricks

I found two useful java tricks today.
  • Calculate the width of a string in pixels
Just use the following code:
Font currentFont = biggestFont;
Font currentFont = new Font(/* define your own font */);
FontMetrics currentMetrics = getFontMetrics(currentFont); // 1
String longString = "This is not a long string!";
Although getFontMetrics from Toolkit is deprecated, JComponent.getFontmetrics is not. More can be found in the java forums.


  • Recurring tasks to update the GUI
The Timer object allows you to schedule TimerTasks at a specified date or at regular intervals. It is very useful when you are polling data which will be later painted on your GUI components.

Saturday, April 15, 2006

Multiple boot on intel macs

I've hardly got time for writing here, but that's one of the advantages of not compromising yourself to writing regularly.

Today I'm going to write about Apple Bootcamp. Apple's move to intel has been really shocking, and bold moves such as the release of the Bootcamp beta create some uncertainty about the future at apple.

Although I myself don't reject the move to intel processors and windows running on a mac with apple's blessing, I am still skeptical. I fear apple might be jumping on the cheap hardware bandwagon and that would definitely be a step backwards. I already don't see whether the new MacBook Pros are superior to their PC counterparts in terms of weight and battery life.

An article at slashdot was what triggered my intention to write this blog entry. It seems that someone has figured out how to boot linux in addition to windows on a mac. Is hell freezing over? I confess I'm intrigued to see what the future holds...

Photo by Joseph Zollo.