Example usage for java.lang IllegalArgumentException IllegalArgumentException

List of usage examples for java.lang IllegalArgumentException IllegalArgumentException

Introduction

In this page you can find the example usage for java.lang IllegalArgumentException IllegalArgumentException.

Prototype

public IllegalArgumentException() 

Source Link

Document

Constructs an IllegalArgumentException with no detail message.

Usage

From source file:Main.java

public static int bitSetOfByte(byte b) {
    if (b == 1) {
        return 1;
    } else if (b == 2) {
        return 2;
    } else if (b == 4) {
        return 3;
    } else if (b == 8) {
        return 4;
    } else if (b == 0x10) {
        return 5;
    } else if (b == 0x20) {
        return 6;
    } else if (b == 0x40) {
        return 7;
    } else if (b == (byte) 0x80) {
        return 8;
    } else {//from  w w  w.j  a  v  a 2 s. com
        throw new IllegalArgumentException();
    }
}

From source file:Main.java

public static int[] copyOfRange(int[] original, int start, int end) {
    if (start <= end) {
        if (original.length >= start && 0 <= start) {
            int length = end - start;
            int copyLength = Math.min(length, original.length - start);
            int[] copy = new int[length];
            System.arraycopy(original, start, copy, 0, copyLength);
            return copy;
        }//  ww  w.  ja  va  2 s.  c o  m
        throw new ArrayIndexOutOfBoundsException();
    }
    throw new IllegalArgumentException();
}

From source file:Main.java

private static Date parseDate(String d) throws IllegalArgumentException {
    if (!d.startsWith("@"))
        throw new IllegalArgumentException();
    return new Date(Long.parseLong(d.substring(1)));
}

From source file:Main.java

public static void setJButtonSizesTheSame(final JButton[] btns) {
    if (btns == null) {
        throw new IllegalArgumentException();
    }/*from   ww w . j  a  v a 2  s  . c o  m*/

    final Dimension maxSize = new Dimension(0, 0);
    for (int i = 0; i < btns.length; ++i) {
        final JButton btn = btns[i];
        final FontMetrics fm = btn.getFontMetrics(btn.getFont());
        final Rectangle2D bounds = fm.getStringBounds(btn.getText(), btn.getGraphics());
        final int boundsHeight = (int) bounds.getHeight();
        final int boundsWidth = (int) bounds.getWidth();
        maxSize.width = boundsWidth > maxSize.width ? boundsWidth : maxSize.width;
        maxSize.height = boundsHeight > maxSize.height ? boundsHeight : maxSize.height;
    }

    final Insets insets = btns[0].getInsets();
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;

    for (int i = 0; i < btns.length; ++i) {
        final JButton btn = btns[i];
        btn.setPreferredSize(maxSize);
    }

    initComponentHeight(btns);
}