Enabling tooltips on a JTree

Thinks i keep forgetting. Today: Enabling a JTree in J2SE to show different tooltips on his nodes:

1. Create a custom tree renderer like so:

import java.awt.Component;
 
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeCellRenderer;
 
public class TooltipTreeRenderer  extends DefaultTreeCellRenderer  {	
  @Override
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    final Component rc = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);		
    String tooltip = "Compute some arbitrary text depending on the node (which is hidden behind 'value')";
    this.setToolTipText(tooltip);
    return rc;
  }
}

2. Set this renderer

aTree.setCellRenderer(new TooltipTreeRenderer());

3. Keep wondering, why the tooltip doesn’t show…

4. Register the tree with the ToolTipManager (which isn’t necessary for nearly all other Swing Components…)

javax.swing.ToolTipManager.sharedInstance().registerComponent(aTree);

5. Enjoy 🙂

| Comments (3) »

12-Aug-08


Absurdistan (2)

Behold, here comes the iPhone app all retards have been waiting for:

I Am Rich.

Actually, i think it’s kinda funny, although i guess some people won’t get the joke.

Edit:

Oh and by the way, it seems, you’re never alone as the iPhone keeps iphoning ihome.

ipuke, iguess.

| Comments (0) »

07-Aug-08


Sony Ericsson C702: Show received and send traffic

Once again, a quick reminder for myself: Howto display the internet traffic on your Sony Ericsson C702:

Menü, #, 4th Tab, 5

(On a german phone: “Einstellungen / Anrufe / Zeit und Kosten”)

I guess that works with other SEs like K800i and K850i.

I remember an old SE that i had which always displayed the traffic after ending an internet session, i wonder why they changed it.

| Comments (0) »

28-Jul-08


Make XQuartz more usable

This post is an update to Make Gimp.app usable on a mac:

The “Click through” property on both Apples X11 and the X11 provided by XQuartz is not set. This leads to the fact, that you have to click on each X11 window twice: First activating it, 2nd pushing a button or whatever else. I hate this, i really do.

With Apples X11, open a terminal and enter:

defaults write com.apple.X11 wm_click_through -bool true

With XQuartz X11 enter:

defaults write org.x.X11 wm_click_through -bool true

This will help you with all X11 apps, like Gimp, Inkscape, Open Office and the likes.

| Comments (2) »

28-Jul-08