JetBrains/intellij-community · error · UnexpectedFormElementException

unexpected position: {position}

Error message

unexpected position: {position}

What it means

Thrown by LwSplitPane.readConstraintsForChild when reading a child's split-pane constraints: the required 'position' attribute under <constraints><splitpane> is neither 'left' nor 'right'. A JSplitPane child must declare which pane it occupies; any other value is rejected with UnexpectedFormElementException.

Source

Thrown at java/compiler/forms-compiler/src/com/intellij/uiDesigner/lw/LwSplitPane.java:39

  @Override
  public void read(final Element element, final PropertiesProvider provider) throws Exception {
    readNoLayout(element, provider);
  }

  @Override
  protected void readConstraintsForChild(final Element element, final LwComponent component) {
    final Element constraintsElement = LwXmlReader.getRequiredChild(element, "constraints");
    final Element splitterChild = LwXmlReader.getRequiredChild(constraintsElement, "splitpane");
    final String position = LwXmlReader.getRequiredString(splitterChild, "position");
    if ("left".equals(position)) {
      component.setCustomLayoutConstraints(POSITION_LEFT);
    }
    else if ("right".equals(position)) {
      component.setCustomLayoutConstraints(POSITION_RIGHT);
    }
    else {
      throw new UnexpectedFormElementException("unexpected position: " + position);
    }
  }
}

View on GitHub (pinned to be881553f2)

Solutions

  1. Set the position attribute to exactly 'left' or 'right' in the child's <constraints><splitpane> element.
  2. Re-open the split pane in the GUI designer and re-drop the component into the correct pane, then save.

Example fix

<!-- before -->
<constraints><splitpane position="LEFT"/></constraints>

<!-- after -->
<constraints><splitpane position="left"/></constraints>
Defensive patterns

Strategy: validation

Validate before calling

// When writing split-pane constraints, normalize the position value
if (!"left".equals(position) && !"right".equals(position)) throw new IllegalArgumentException("position must be 'left' or 'right', got: " + position);

Try / catch

try { splitPane.readConstraintsForChild(element, component); } catch (UnexpectedFormElementException e) { /* set position to exactly 'left' or 'right' (lowercase) */ }

Prevention

When it happens

Trigger: A split-pane child's constraints XML reads <splitpane position="top"/> (or "LEFT", "center", etc.). Only exact lowercase 'left' and 'right' are accepted; anything else, including case variants, throws.

Common situations: Hand-editing form XML and typing a wrong or capitalized position value; code that programmatically generates form XML using Swing constants (TOP/BOTTOM) instead of the designer's left/right vocabulary.

Related errors


AI-assisted analysis of JetBrains/intellij-community@be881553f2 (2026-08-14). Data as JSON: /api/errors/26ab6fd4aa2e7c53. Report an issue: GitHub.