Here you can find the source of stringToRectangle(String s, Rectangle defaultValue)
public static Rectangle stringToRectangle(String s, Rectangle defaultValue)
//package com.java2s; //License from project: Open Source License import java.awt.Rectangle; public class Main { public static Rectangle stringToRectangle(String s, Rectangle defaultValue) { if (s == null) return defaultValue; String[] sa = s.split(" +"); if (sa.length != 4) return defaultValue; int[] ia = new int[4]; for (int i = 0; i < 4; i++) try { ia[i] = Integer.parseInt(sa[i]); } catch (NumberFormatException e) { return defaultValue; }/* ww w . ja v a 2 s.c o m*/ return new Rectangle(ia[0], ia[1], ia[2], ia[3]); } }