Geertjan is a DZone Zone Leader and has posted 453 posts at DZone. You can read more from them at their website. View Full User Profile

Lingen on the NetBeans Platform

02.24.2011
| 4411 views |
  • submit to reddit

A group of students at the Fachhochschule (technical college) Osnabrück in Lingen, Germany, are currently taking a NetBeans Platform course. We're using NetBeans IDE 7.0 Beta 2 and so far, as far as I am aware, there have been no problems (just much much faster than before, plus nice TopComponent annotations, hurray) that have arisen as a result of using this beta release.

The day started with an overview of what NetBeans is, where it comes from, and what the main features of the NetBeans Platform are. Then we deep dived into the module system. Dream team member Aljoscha Rittner is delivering the course together with me, he's currently introducing the class to the window system.

Here's a snapshot:

We've created a few small applications so far, such as this pluggable text editor. Each of the tools shown in the combobox below comes from a different plugin, while the window shown below doesn't know anything about them. Instead, the Lookup.getDefault construction is used to load implementations from the META-INF/services folder:

The interesting code, in the constructor of the window:

final DefaultComboBoxModel dcbm = new DefaultComboBoxModel();

Collection<? extends WordFilterInterface> allFilters = Lookup.getDefault().lookupAll(WordFilterInterface.class);

for (WordFilterInterface filter : allFilters) {
dcbm.addElement(filter);
}

jButton1.addActionListener(new ActionListener() {

@Override
public void actionPerformed(ActionEvent e) {

String myPlainText = jTextField1.getText();

WordFilterInterface wfi = (WordFilterInterface) dcbm.getSelectedItem();

String myProcessedText = wfi.process(myPlainText);

jTextArea1.setText(myProcessedText);

}

});

jComboBox1.setModel(dcbm);

The question you might have is how, if the filter is added to the combo box, is a string displayed in it? Well, the combo box has a default renderer that uses the toString() method of the object it displays to create the label displayed within it:

@ServiceProvider(position=10,service=WordFilterInterface.class)
public class LowercaseFilter implements WordFilterInterface {

@Override
public String name() {
return "Lowercase";
}

@Override
public String definition() {
return "Turns the word to lowercase";
}

@Override
public String process(String word) {
return word.toLowerCase();
}

@Override
public String toString() {
return name();
}

}

Interested in a NetBeans Platform training too? Go here for all the details.

 

Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Tushar Joshi replied on Fri, 2011/02/25 - 5:56am

All the best for the rest of the session to all the participants from NUG Nagpur.  We had this session on Skype+Webex from Geertjan and it was fantastic experience.

with regards

Tushar Joshi
NUG Nagpur
http://nugnagpur.wikispaces.com

Matt Coleman replied on Tue, 2011/11/15 - 12:48am

 this explains it all

 

web designer buffalo

Mateo Gomez replied on Fri, 2012/02/03 - 12:40am

i can see from the photo a very busy group of people chicken burrito recipe

Cata Nic replied on Mon, 2013/09/02 - 4:15pm

 The entire team looks like is really ready to obtain better solutions for their clients. That's explains a lot of things...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.