private void initPanel(){
  if (sensorType.getSelectedItem() == "TileSensor") {
    clearSensorPanel();
    setTitle("Add a tile sensor");
    currentSensorPanel=new TileSensorPanel(entity);
    mainPanel.add(currentSensorPanel);
  }
 else   if (sensorType.getSelectedItem() == "SmellSensor") {
    clearSensorPanel();
    setTitle("Add a smell sensor");
    currentSensorPanel=new SmellSensorPanel(entity);
    mainPanel.add(currentSensorPanel);
  }
 else   if (sensorType.getSelectedItem() == "Tile Set") {
    clearSensorPanel();
    setTitle("Add a grid of tile sensors");
    currentSensorPanel=new TileSetPanel(entity);
    mainPanel.add(currentSensorPanel);
  }
 else   if (sensorType.getSelectedItem() == "Hearing") {
    clearSensorPanel();
    setTitle("Add a hearing sensor");
    currentSensorPanel=new HearingSensorPanel(entity);
    mainPanel.add(currentSensorPanel);
  }
  pack();
  setLocationRelativeTo(null);
}

private void initPanel ( ) { if ( sensorType . getSelectedItem ( ) == "TileSensor" ) { clearSensorPanel ( ) ; setTitle ( "Add a tile sensor" ) ; currentSensorPanel = new TileSensorPanel ( entity ) ; mainPanel . add ( currentSensorPanel ) ; } else if ( sensorType . getSelectedItem ( ) == "SmellSensor" ) { clearSensorPanel ( ) ; setTitle ( "Add a smell sensor" ) ; currentSensorPanel = new SmellSensorPanel ( entity ) ; mainPanel . add ( currentSensorPanel ) ; } else if ( sensorType . getSelectedItem ( ) == "Tile Set" ) { clearSensorPanel ( ) ; setTitle ( "Add a grid of tile sensors" ) ; currentSensorPanel = new TileSetPanel ( entity ) ; mainPanel . add ( currentSensorPanel ) ; } else if ( sensorType . getSelectedItem ( ) == "Hearing" ) { clearSensorPanel ( ) ; setTitle ( "Add a hearing sensor" ) ; currentSensorPanel = new HearingSensorPanel ( entity ) ; mainPanel . add ( currentSensorPanel ) ; } pack ( ) ; setLocationRelativeTo ( null ) ; }
initialize the sensor dialog panel based upon the current sensor type .
