title: JIRA development - creating a screen (FieldScreen) programmatically
body: <p>I'm pretty new to JIRA and I'm currently working on integrating my JIRA plugin with the JIRA issue tracking system. My plan is to create a couple of custom fields and then create a custom screen (FieldScreen) that will contain these fields. I've created one custom field but I'm having trouble with creating the screen.</p>
  
  <pre><code>// Create issue type:
  IssueType myIssueType = this.issueTypeManager.createIssueType("FOO", "FOOBAR", "/images/icons/issuetypes/genericissue.png");
  
  // Create custom field:
  // Create a list of issue types for which the custom field needs to be available    
  List&lt;GenericValue&gt; issueTypes = new ArrayList&lt;GenericValue&gt;();
  issueTypes.add(myIssueType.getGenericValue());
  
  // Create a list of project contexts for which the custom field needs to be available
  List&lt;JiraContextNode&gt; contexts = new ArrayList&lt;JiraContextNode&gt;();
  contexts.add(GlobalIssueContext.getInstance());
  
  CustomFieldType fieldType = this.customFieldManager.getCustomFieldType("com.atlassian.jira.plugin.system.customfieldtypes:textfield");
  CustomFieldSearcher fieldSearcher = this.customFieldManager.getCustomFieldSearcher("com.atlassian.jira.plugin.system.customfieldtypes:textsearcher");
  CustomField cField = this.customFieldManager.createCustomField("Basic Text Field", "This is a basic text field", fieldType, fieldSearcher, contexts, issueTypes);
  
  /* 
      Change this next part, instead of adding to the default screen:
      1) Create a new screen (FieldScreen)
      2) Add the custom field (cField) to that screen
  */
  
  // Add field to default Screen
  FieldScreen defaultScreen = fieldScreenManager.getFieldScreen(FieldScreen.DEFAULT_SCREEN_ID);
  if (!defaultScreen.containsField(cField.getId())) {
      FieldScreenTab firstTab = defaultScreen.getTab(0);
      firstTab.addFieldScreenLayoutItem(cField.getId());
  }
  </code></pre>