Search code examples
swtline-breaksdraw2dzesttextflow

How to add a force line-break in a draw2d TextFlow


How do I add a forced line-break within a draw2d TextFlow figure.

I build a IFigure by adding several different objects. Amongst other things I add a FlowPage containing a TextFlow. But I could not find an option to force line-breaks at specific locations.

Figure fig = new Figure();
fig.setLayoutManager(new FreeformLayout());

FlowPage flow = new FlowPage();
flow.setSize(100,100);

TextFlow text = new textFlow("A rather long text without any line-breaks. Lorem Ipsum dolor sit amet.");

flow.add(text);
fig.add(flow);
fig.setSite(100,100);

Solution

  • The common LineFeed character \n solved this problem. Inserted somewhere inside the String it forces a line-break.