code: private static int drawJustifiedSpaceSeparatedSubstrings(Font font,
  			final String s, final int x, final int y,
  			final int justifiedSpaceWidth) {
  		int curpos = 0;
  		int endpos = 0;
  		int resultingXCoordinate = x;
  		while (curpos < s.length()) {
  			endpos = s.indexOf(' ', curpos); // find space
  			if (endpos == -1) {
  				endpos = s.length(); // no space, draw all string directly
  			}
  			String substring = s.substring(curpos, endpos);
  
  			font.drawString(resultingXCoordinate, y, substring);
  
  			resultingXCoordinate += font.getWidth(substring)
  					+ justifiedSpaceWidth; // increase
  			// x-coordinate
  			curpos = endpos + 1;
  		}
  
  		return resultingXCoordinate;
  	}
docs: Draws justified-space separated substrings based on the given
  {@link String} and the given starting x and y coordinates to the given
  {@link Graphics2D} instance.
  
  @param font
  The font to draw with
  @param s
  The non-null {@link String} to draw as space-separated
  substrings.
  @param x
  The given starting x-coordinate position to use to draw the
  {@link String}.
  @param y
  The given starting y-coordinate position to use to draw the
  {@link String}.
  @param justifiedSpaceWidth
  The integer specifying the width of a justified space
  {@link String}, in pixels.
  @return The resulting x-coordinate of the current cursor after the
  drawing operation completes.
  @throws NullPointerException
  Throws a {@link NullPointerException} if any of the given
  arguments are null.