From 167f17ad14d8af29b4b5cda11b4ffa9ebc7944a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaqu=C3=ADn=20Magneres?= Date: Sun, 9 Dec 2012 21:12:56 -0200 Subject: [PATCH] Fixed bug Exception launched when it had no fields Check if numFields is 0, set the fieldWidth to 0 instead of making a division with that number. This way it avoids a division by zero. --- .../JustifiedEvenlySpacedHorizontalFieldManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Advanced UI/src/com/samples/toolkit/ui/container/JustifiedEvenlySpacedHorizontalFieldManager.java b/Advanced UI/src/com/samples/toolkit/ui/container/JustifiedEvenlySpacedHorizontalFieldManager.java index f2f7639..35903e0 100644 --- a/Advanced UI/src/com/samples/toolkit/ui/container/JustifiedEvenlySpacedHorizontalFieldManager.java +++ b/Advanced UI/src/com/samples/toolkit/ui/container/JustifiedEvenlySpacedHorizontalFieldManager.java @@ -46,7 +46,13 @@ protected void sublayout( int width, int height ) // There may be a few remaining pixels after dividing up the space // we must split up the space between the first and last buttons - int fieldWidth = width / numFields; + + //if there are no fields the current fieldWidth should be 0 + final int fieldWidth; + if (numFields == 0) + fieldWidth = 0; + else + fieldWidth = width / numFields; int firstFieldExtra = 0; int lastFieldExtra = 0;