Skip navigation

Since I have been going after some low hanging fruits in fixing some Python support related issues in NetBeans, strictly over weekends (without the knowledge of my wife who prefers my MacBook Pro being 2000 miles away from me on weekends), I ran into an interesting issue where I had to display the NetBeans font chooser instead of a custom font chooser being used in the code. Unable to find the proper API (perhaps I am dumb), I waded into the NetBeans sources, and found the way out. Blogging about this here to save some poor soul some time when the need arises.

PropertyEditor pe = PropertyEditorManager.findEditor (Font.class);
DialogDescriptor dd = new DialogDescriptor (
    "Some Title"  // NOI18N

DialogDisplayer.getDefault ().createDialog (dd).setVisible (true);
if (dd.getValue () == DialogDescriptor.OK_OPTION) {
    font = (Font) pe.getValue ();

It just boils down to getting a property editor for Font and then wrapping the panel inside a dialog box using the NetBeans DialogDisplayer API.


One Comment

  1. Interesting Tip.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: