Archive for the ‘Bugs’ Category

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.

VisualVM on Vista

I wanted to use VisualVM to track down a problem in a Java application running under Java 6u11, but it would not work. In the VisualVM local process list, all I could see was “<Unknown Application> (pid ###)”. When trying to connect, I’d see “not supported by this JVM”. This is on a Vista machine.

My domain username is “EBurke”, and Sun creates this directory:

%temp%\hsperfdata_eburke

In this directory, you’ll find one file for each Java process. The filenames are the PIDs.

The Fix

  1. Exit all Java apps
  2. Erase the hsperfdata_xxxx directory
  3. Create a new one, with correct capitalization.

In my case, the correct directory is:

%temp%\hsperfdata_EBurke

You can determine your username by typing “set” at the command prompt, and then finding the USERNAME setting.

Now when I run visualvm, I see the processes and I can connect to local Java apps successfully.

I submitted bug 236 for this issue.

Eclipse Leopard Glitches

I figured since the Android SDK comes with an Eclipse plugin, I should use Eclipse when learning Android. I think that’s probably a mistake.

Split Panes

Here is what split panes look like with Eclipse on Leopard:

I added the red box to indicate where you’d normally expect to drag the splitter up and down. While this works, the cursor does not change. So as you move your mouse over the splitter, it feels unresponsive. Even weirder, the cursor DOES change, but it is always about 15-30 pixels below the splitter. It’s as if they are adding some insets for a menu bar that does not exist.

Weird GUI Artifacts

Check out the glowing “Application Toggle” text on this screen:

GUI flaws like this seem to pop up all over the place with Eclipse on Leopard.

Android Plugin Weirdness

The screen above is from the Android Eclipse plugin. You should be able to click the Add… button to add additional activities. It worked for me once or twice (I think), but usually I see this:

Not only is the dialog blank, it is completely unresponsive. All I can do is hit Cancel.

Bring on IDEA

I guess I need to figure out what it takes to develop Android apps in IDEA. I do like that Eclipse automatically keeps R.java up-to-date, and I like that I can launch the emulator from the IDE. Hopefully those tasks are easy to do from the command-line so I can go back to IDEA.

Nimbus JTable Checkbox Rendering Bug

I ran across a Nimbus Look and Feel bug that affects the GUIs I work on. This is a known issue: see Bug ID 6723524 on the Bug Parade. It is marked Low priority, so I hope it is fixed before the Java 6u10 release. (unlike Bug 4795987, for example, which has been open since 2002 and is also affecting my GUIs).

Here is a standard JTable with Boolean values in the third column. Notice how the standard checkbox renderer fails to properly paint alternate row colors: (this is very subtle on some displays)

In this next picture, I clicked on “Jones” to demonstrate the standard Nimbus focus border:

In this next picture, I clicked on the checkbox. Notice how the border is not painted on the checkbox renderer:

Sample Code

Here is the demonstration program, it requires JDK 1.6u10 to run.

import javax.swing.*;
import static javax.swing.UIManager.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import java.awt.*;

/**
 * Demonstrates bug 6723524, checkboxes do not render properly in JTable.
 *
 * @author Eric M. Burke
 */
public class NimbusDemo extends JFrame {
    public static void main(String... args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                setNimbusLaf();
                new NimbusDemo().setVisible(true);
            }
        });
    }

    private static void setNimbusLaf() {
        try {
            for (LookAndFeelInfo lafInfo : getInstalledLookAndFeels()) {
                if ("Nimbus".equals(lafInfo.getName())) {
                    setLookAndFeel(lafInfo.getClassName());
                    return;
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        throw new RuntimeException("Unable to find Nimbus LAF.");
    }

    public NimbusDemo() {
        super("Bug 6723524");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Object[] columnNames = {
                "First Name", "Last Name", "Married"
        };
        Object[][] data = {
                {"Harry", "Smith", true},
                {"Sally", "Jones", false},
                {"Bob", "Clark", true},
                {"Eric", "Burke", true}
        };

        TableModel tm = new DefaultTableModel(data, columnNames) {
            public Class getColumnClass(int columnIndex) {
                return (columnIndex == 2) ? Boolean.class : String.class;
            }

            public boolean isCellEditable(int row, int column) {
                return false;
            }
        };
        add(new JScrollPane(new JTable(tm)), BorderLayout.CENTER);
        pack();
    }
}

JARs in JARs

I just voted for Bug 4648386: “Simplify deployment and versioning by embedding JAR files within each other”. This bug has been open since 2002 and has 145 votes.

One workaround is to unzip all of your JARs and then re-bundle into a single JAR. While this is easy enough, I would recommend using Jar Jar Links whenever you re-package classes into custom JARs.

A few years back, we had a case where a 3rd party library had embedded JDOM beta 8 into their JAR, but they did not change the package names. When we tried updating our applications to JDOM 1.0, we ran into conflicts because the old JDOM was embedded into one of the JAR files we needed. This is exactly the kind of problem that Jar Jar Links can eliminate.

NAVTEQ Update: Not Impressed

More than eight months ago, I enthusiastically blogged about NAVTEQ Map Reporter, a service that lets you submit updates to the NAVTEQ maps database. I finally heard back from them, here is their response in its entirety:

Thank you for your recent Map Report. We have completed our investigation of your Map Report.

For the NAVTEQ tracking number: 0056Q5WWIJ2VO2HB
Submitted on : 18, Oct 2007 20:31:10
Problem Description: This is my house. It shows up 1 block away from the correct location on every mapping service.

Our Resolution Outcome is: No Change Necessary – Database Reflects Reality
Details: It was verified that the database was recently updated by correcting the addressing along St Nicholas Ct in O’Fallon, MO. Specifically, it was confirmed that the address of 36 St Nicholas Ct is located to the west of St Agatha Ct. No further changes were necessary, and the information in this request was already corrected prior to the receipt of this inquiry.

NAVTEQ delivers regularly scheduled map updates to our business partners which include many database enhancements. The release dates for these products will vary depending on each individual business partner. If you are interested in an updated map for your navigation system, please contact your system provider or review this link for NAVTEQ’s distribution partners.

http://www.navteq.com/ProductFinder?Language=en&action=location&path=mapupdate

Please let us know if you find any additional areas that we need to review. Once again, thank you for contacting us and for visiting our website.

For more details, proceed to your Map Report at http://mapreporter.navteq.com

NAVTEQ delivers regularly scheduled map updates to our business partners which include database enhancements. The commercial release dates for these products will vary depending on each business partner’s product plans. If your Map Report did not result in a database change, please note that we track these items and evaluate them with our business partners on a regular basis to enhance navigation system performance.

Having the latest map in your system makes a difference to system performance with the latest roads, addresses and Points of Interest. If you are interested in an updated map for your navigation system, please contact your system provider or check our online store at http://store.navteq.com.

We welcome your feedback on the NAVTEQ Map. Thank you for helping to keep the NAVTEQ Map the most accurate and highest quality in the business.

Regards,
The NAVTEQ Map Reporter Team

This is also known as “blowing you off”. In fact, I know where my house is. As I reported last year, my house is NOT west of Saint Agatha Court, as they claim. In fact, their “updated” map is wrong, in precisely the same fashion as it was wrong last year.

They did not fix the bug, which means this flawed data will continue to be fed into all downstream mapping services and devices for the foreseeable future.

“Database reflects reality”??? Nope. “It was confirmed…”??? I’d sure like to know how they “confirmed” this.

JavaCrashX

This never makes a good first impression:

Unfortunately, the application, using the new Java Update 10 browser plug-in, kept crashing.

I Can’t Win

Holy balls. I had a Twitter account in the past, but I deleted it. (due to being boring and having nothing to write about) Now I decide I’d like to try Twitter again, so I just tried creating a new account.

First, they tell me my Email is already taken. Grr…

So then I click the “forgot” link, enter my Email…and they say:

Oh Snap! We couldn’t find you!

So let me get this straight:

  1. According to their database, my Email address is already taken.
  2. According to their database, they can’t find my Email address.

Impressive. I blame Rails. (not really, just seems like easy trolling these days…)

JavaOne Registration Bug

A coworker was informed (by a flawed web app) that his JavaOne registration could not be found. And he was unable to login because “his email address is invalid”. Apparently his email must end in something like .com, .edu, or perhaps even .cc to be considered “valid”. (at least according to the JavaOne registration system)

Guess what? .coop is a valid domain name extension. When writing data validators, make sure you don’t reject valid data.