Here you can find the source of formatRectangle(Rectangle rect)
public static String formatRectangle(Rectangle rect)
//package com.java2s; /*//www. j av a 2 s. c om * Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" * which accompanies this distribution, and is available * at the URL "http://www.eclipse.org/legal/epl-v10.html". * * Initial Contributors: * Nokia Corporation - initial contribution. * * Contributors: * * Description: * */ import java.awt.Rectangle; import java.text.MessageFormat; public class Main { private static final MessageFormat RECTANGLE_FORMAT = new MessageFormat( "{0},{1},{2},{3}"); public static String formatRectangle(Rectangle rect) { if (rect == null) { return ""; } return RECTANGLE_FORMAT.format(new Object[] { rect.x, rect.y, rect.width, rect.height }); } }