Java Rectangle Create Parse stringToRectangle(String value)

Here you can find the source of stringToRectangle(String value)

Description

string To Rectangle

License

Open Source License

Declaration

public static Rectangle stringToRectangle(String value) 

Method Source Code

//package com.java2s;
/*//from w  w w  .jav a  2 s  . co  m
 *  PrefsUtil.java
 *  Eisenkraut
 *
 *  Copyright (c) 2004-2015 Hanns Holger Rutz. All rights reserved.
 *
 *  This software is published under the GNU General Public License v3+
 *
 *
 *   For further information, please contact Hanns Holger Rutz at
 *   contact@sciss.de
 *
 *
 *  Changelog:
 *      25-Jan-05   created from de.sciss.meloncillo.util.PrefsUtil
 *      13-May-05   updated from Meloncillo
 *      22-Jul-05   suggests 57109 as default scsynth port ; no longer
 *               uses 'Built-in Audio' device on Mac (sc will use
 *               default system output instead) ; TEMPDIR refers to IOUtil
 */

import java.awt.Rectangle;

import java.util.NoSuchElementException;
import java.util.StringTokenizer;

public class Main {
    public static Rectangle stringToRectangle(String value) {
        Rectangle rect = null;
        final StringTokenizer tok;

        if (value != null) {
            try {
                tok = new StringTokenizer(value);
                rect = new Rectangle(Integer.parseInt(tok.nextToken()), Integer.parseInt(tok.nextToken()),
                        Integer.parseInt(tok.nextToken()), Integer.parseInt(tok.nextToken()));
            } catch (NoSuchElementException e1) {
                e1.printStackTrace();
            } catch (NumberFormatException e2) {
                e2.printStackTrace();
            }
        }
        return rect;
    }
}

Related

  1. stringToBounds(String str, Rectangle defaultRect)
  2. stringToRectangle(String s)
  3. stringToRectangle(String s, Rectangle defaultValue)
  4. stringToRectangle(String str)
  5. stringToRectangle(String string, Rectangle defaultValue)