Geertjan's Blog

  • September 26, 2011

Place the quicksearch component anywhere you like (Part 2)

Geertjan Wielenga
Product Manager

The NetBeans Platform comes with a pluggable filter component. Nicklas Löf explained in his blog sometime ago how to place that component anywhere you like. Today I wondered if the Matisse GUI Builder could be used to layout the location of the component.

I came up with a simple trick. Drag and drop a JPanel from the Palette onto your TopComponent:

Then use the code from Nicklas' blog, linked above, to retrieve the component via your layer entry (which is also explained by Nicklas)... but add the component to the JPanel that you have just put into your TopComponent:

Action action = Utilities.actionsForPath("QuickSearchShadow").get(0);
Component quickSearchToolbarItem = ((Presenter.Toolbar) action).getToolbarPresenter();
myPanel.add(quickSearchToolbarItem, BorderLayout.CENTER);

The above code is in the constructor of my TopComponent. Now you can drag the JPanel around in your TopComponent in the Matisse GUI Builder, thus being able to layout the exact design of your TopComponent, treating the filter component like any other Swing component, which of course is exactly what it is, with this result, for example:

Then plug your own filters into the component, using its API. Simple solution, right?

Join the discussion

Comments ( 3 )
  • Jesse Glick Monday, September 26, 2011

    The first line should rather be:

    Action action = (Action) FileUtil.getConfigObject("Actions/Edit/org-netbeans-modules-quicksearch-QuickSearchAction.instance");

  • guest Monday, September 26, 2011

    Yes, but "FileUtil.getConfigObject" is from 7.1 onwards.

  • Geertjan Tuesday, February 11, 2014

    Actions.forID("Edit", "org.netbeans.modules.quicksearch.QuickSearchAction");

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha