Nimbus ToolTip Bug

I just submitted a bug report to Sun for this bug. With Nimbus on Java6u11, tool tips for disabled components have no border, and the tool tip background exactly matches the panel background color. Here is a sample program with the workaround commented out.

public class TooltipBug extends JFrame {     public static void main(String[] args) {         SwingUtilities.invokeLater(new Runnable() {             public void run() {                 try {                     UIManager.setLookAndFeel(                       "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");                 } catch (Exception e) {                     e.printStackTrace();                 }                 new TooltipBug().setVisible(true);             }         });     }      public TooltipBug() {         // un-comment these lines for the workaround         //UIManager.put("ToolTip[Disabled].backgroundPainter",         //        UIManager.get("ToolTip[Enabled].backgroundPainter"));          JButton b1 = new JButton("One");         b1.setToolTipText("Button 1");          JButton b2 = new JButton("One");         b2.setEnabled(false);         b2.setToolTipText("Button 2");          Container c = getContentPane();         c.setLayout(new FlowLayout());         c.add(b1);         c.add(b2);          pack();         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);     } }

*** UPDATE: They accepted my bug report. It is Bug ID 6789983.

Nimbus JToolBar Bug

I just submitted a workaround for this Nimbus bug: 6780500. I am unable to watch or vote for bugs…the bug tracking tool seems to have a bug.

The problem is, disabled items in JToolBar use a black font and don’t look any different than enabled items.

This example requires Java6u10 or later, and demonstrates the bug:

public class ToolbarBug extends JFrame {   public static void main(String[] args) {     SwingUtilities.invokeLater(new Runnable() {       public void run() {         try {           UIManager.setLookAndFeel(                "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");         } catch (Exception e) {           throw new RuntimeException(e);         }         new ToolbarBug().setVisible(true);       }     });   }    public ToolbarBug() {     /*     // un-comment these lines for the workaround     UIManager.put("ToolBar:Button[Disabled].textForeground",             UIManager.getColor("nimbusDisabledText"));     UIManager.put("ToolBar:ToggleButton[Disabled].textForeground",             UIManager.getColor("nimbusDisabledText"));     */      JToolBar tb = new JToolBar();     tb.add(new JButton("Enabled"));     JButton disabled = new JButton("Disabled");     disabled.setEnabled(false);     tb.add(disabled);      add(tb, BorderLayout.NORTH);      pack();     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   } }

With the fix, the example looks right:

Things I May Never Do

These are things I fantasize about doing, but probably won’t. They are either impossible, or are things I may not actually enjoy if I had the chance. For example, people turn abandoned missile silos into homes all the time, but in reality, the homes are isolated, cold, and awkward to live in.

  • Walk up (or down might be better) the Arch stairs. You can see the “forbidden stairs” as you ride the trams to the top. 630 feet is a long way, however. This would get really painful and boring. But I’m still annoyed that the best part of the Arch is off limits.
  • Visit the inside of a Google data center.
  • Live on a private island. Because I’m afraid of pirates. And too poor.
  • Turn an abandoned missile silo into my home.
  • Build a house with at least one hidden room and some secret passageways. This item seems attainable.

Death File

I think I need a death file. Some sort of document that lists all of my online accounts, insurance policies, bank accounts, important documents, etc.

If I were to die suddenly, I don’t know how the hell my wife would clean up the mess I’ve left online.

2008 Year in Review

This is the best year-end review I’ve ever written. I promise. 2008 was a year of contradictions. Around May/June, when gas prices spiked, we were told to expect sky-high oil and gas prices…”forever”. I don’t recall anybody predicting $1.35/gallon gas, yet that’s about what I paid this morning.

In 2008 we learned…with no advance warning…that the entire financial industry was suddenly frozen and we’d be thrown into an epic depression unless we instantly printed $700 billion within DAYS! If we didn’t see it coming, why was it so important to fix the problem quickly? Somehow the people who were blind-sided are the same people who now claim to know how bad things will be without bailouts. WTF.

2008 taught us that people will stop buying SUVs if gas prices go up enough. And as soon as prices drop, people will lose interest in the shitty economy cars, because tiny cars with wimpy engines and boring designs suck. GM sucks. Chrysler sucks. Ford sucks. Stupid tax policies on diesel fuels prevent Ford from selling their 65 MPG diesel car in the U.S.

  • On Jan 3, 2008, Blu-ray and HD-DVD were still locked in a battle for supremacy. HD sucked for consumers because there were two competing standards. On Jan 4, 2008, however, the war abruptly ended with this announcement from Warner Bros. On Feb 15 Wal Mart announced it would no longer carry HD-DVD, and on Feb 16 Toshiba halted production of HD-DVD hardware. Game over. You barely even remember this stuff by now.
  • Best tweet of 2008: “Batman: EPIC BALE”.
  • Funniest tweet of 2008: “Gordon Ramsay: one bad puffin eating mofo.”
  • Best line in a technical article: “Along with the data processing framework, Doug Cutting also included a fault tolerant, replicated, distributed file system with Hadoop just because fuck you.”
  • 2008 was not the year of Linux on the Desktop.
  • 2009 might be the year of Android on the Netbook.
  • Scala caught a lot of buzz during Jan and Feb.
  • Python 3000 came out. Jython saw a resurgence. Sun even hired two high-profile Jython developers.
  • Programmer of the year: Charles Nutter. Follow him on Twitter, he’s a machine.
  • Apple kicked ass in 2008. MacBook Air, Apple TV 2.0, iPhone SDK in March, iPhone 3G in July, App Store, MobileMe, Solid Aluminum manufacturing process for new MacBooks, etc.
  • Vista is about to die. Within the last few days, we learned Windows 7 beta is complete, and expect to see it released in mid-2009.
  • Yahoo is dying. Back in June we heard a lot about programmers and management leaving the company. Yang is out. Microsoft failed to buy them.
  • Google kicked ass in 2008. GWT 1.5 came out. Chrome 1.0. The Open Handset Alliance now boasts 47 members. Android 1.0 came out. They held their first Google I/O conference. Their apps continue to improve.
  • In 2008, New York Governor Eliot Spitzer resigned after we found out he used a hooker.
  • IL Governor Rod Blagojevich is caught up in a big scandal but so far hasn’t resigned.
  • On March 12, a woman became fused to her toilet seat after sitting on it for two years.
  • On March 14, Discover told us how the heck a woman became fused to her toilet seat.
  • Jack Kevorkian was released from prison and ran for congress. He did not win.
  • XM and Sirius merged.
  • Expelled: No Intelligence Allowed, is the least intelligent movie of the year.
  • Grand Theft Auto 4.
  • Midwest floods. Southeast droughts.
  • Georgia Hillbillies invent another fake Bigfoot story, get front page coverage on CNN.com
  • On Sep 10, they activated the Large Hadron Collider (LHC). It swallowed the entire universe and produced an identical universe on the “other side”. We didn’t notice, although everything is backwards now.
  • A bunch of iPhone Killers came out in 2008. Expect more in 2009. So far they all suck. The G1 is a good phone but it lacks multitouch. That’s weak.
  • Word of the year: FAIL.
  • Phrase of the year: EPIC FAIL.
  • A man named HUSSEIN won. Scary shit. His middle name is HUSSEIN.

That’s about it. Nothing else interesting happened in 2008.

The Problem with Dell

At work, I have a brand new quad core Dell running Vista. The machine is super fast and rock solid…except for the video card and driver.

Dell sells this computer with a defective video driver. Icons sometimes vanish until you move your mouse over them, at which time they eventually paint. The screen shows frequent painting artifacts — sometimes the entire login screen is blank, but you can still type. Software updates from ATI crash and burn.

This is true for other people’s PCs as well, so I know it is not a fluke with my machine. I have first hand experience with Vista at home, and I know that some video cards work fine with Vista. This particular configuration — the one Dell chooses to sell — does not work properly.

Yes, Vista has a lot of problems. I get it.

In this case, however, Dell is the problem. They knowingly sell this particular video card with their own PCs. 20 minutes of basic usage reveals painting artifacts and bugs. If Dell cared about customers, they would reject shitty hardware like this. Dell is huge. They can very easily tell ATI: “Sorry, not good enough. We refuse to cheapen our PCs with your flaky hardware and drivers.”

Notebook Computer with Secondary Display

Would you be interested in an 11 pound notebook? That is a LOT of weight to lug around.

Here’s a thought. Why doesn’t someone manufacture a cheap, super-thin, lightweight mobile 15″ LCD display? You can buy a 17″ LCD for $99 on NewEgg. Why aren’t companies manufacturing cheap, thin, “mobile LCDs” that you can easily slide into a notebook bag to take on the road?

A normal notebook plus a mobile secondary display would offer these benefits over the Lenovo computer:

  • Cheaper
  • Lighter
  • Gives you the option to travel with or without the secondary display
  • You could choose a big or small secondary display

This seems like a completely untapped market.

Is This a Nimbus Bug?

This code uses Java 6u11 with the Nimbus Look and Feel. I know how to create and apply custom Painters, but I’d rather avoid any com.sun.* dependencies. Those package names will change in Java 7, so I’d rather keep my code “clean”.

Case 1: JButton Background Color

This works:

JButton btn = new JButton("red"); btn.setBackground(Color.RED);

As expected, the button paints with a red background. That’s because deep inside com.sun.java.swing.plaf.nimbus.ButtonPainter, they override getExtendedCacheKeys(JComponent c). In that method, the painter asks the component for its background, on line 398:

if ("background".equals(property)) {     color = c.getBackground(); }

Case 2: JButtons in a JToolBar

When you put buttons into a JToolBar, setBackground() no longer has any effect. That’s because ToolBarButtonPainter fails to override getExtendedCacheKeys(). ToolBarButtonPainter also has a private array named componentColors like ButtonPainter, but the array is not used.

As I see it, there is no way to set the background color on buttons in a JToolBar without introducing com.sun.* dependencies in our code.

Is this a bug, or a feature? It seems awfully convenient to simply call setBackground(...), even if we’re using Nimbus painters behind the scenes.