Geertjan's Blog

  • September 24, 2012

Deploy from NetBeans IDE by Twisting an External Dial

Geertjan Wielenga
Product Manager
Via this code in a NetBeans module, i.e., a registered NetBeans ModuleInstall class, you can twist the Tinkerforge Rotary Poti Bricklet to deploy the current application in the IDE:
import com.tinkerforge.BrickMaster;
import com.tinkerforge.BrickletLCD20x4;
import com.tinkerforge.BrickletRotaryPoti;
import com.tinkerforge.IPConnection;
import javax.swing.Action;
import javax.swing.JMenuItem;
import org.netbeans.api.project.Project;
import org.netbeans.api.project.ProjectUtils;
import org.openide.awt.Actions;
import org.openide.modules.ModuleInstall;
import org.openide.util.Utilities;
public class Installer extends ModuleInstall {
private static final String HOST = "localhost";
private static final int PORT = 4223;
private static final String MASTERBRICKUID = "abc";
private static final String LCDUID = "abc";
private static final String ROTIUID = "abc";
private static IPConnection ipc;
private static BrickMaster master = new BrickMaster(MASTERBRICKUID);
private static BrickletLCD20x4 lcd = new BrickletLCD20x4(LCDUID);
private static BrickletRotaryPoti poti = new BrickletRotaryPoti(ROTIUID);
public void restored() {
try {
ipc = new IPConnection(HOST, PORT);
poti.addListener(new BrickletRotaryPoti.PositionListener() {
public void position(final short position) {
final Action runAction =
//The action must be invoked from menu item or toolbar button,
//see line 147 in org.netbeans.modules.project.ui.actions.LookupSensitiveAction:
JMenuItem jmi = new JMenuItem(runAction);
//When position is 100 (range is -150 to 150), deploy the app
//and print info about the project to the LCD display:
if (position == 100) {
Project p = Utilities.actionsGlobalContext().lookup(Project.class);
lcd.writeLine((short) 0, (short) 0, "Deployed:");
lcd.writeLine((short) 1, (short) 0, ProjectUtils.getInformation(p).getDisplayName());
} else {
lcd.writeLine((short) 0, (short) 0, "Position: " + position);
} catch (Exception e) {

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.