From 475fa8e64f1d161c61a18f6d4376da00f60678fe Mon Sep 17 00:00:00 2001 From: Nikki Date: Tue, 30 Sep 2014 13:03:14 -0400 Subject: [PATCH] Fix compiler error introduced when cleaning up --- README.md | 4 ++++ .../java/org/nikkii/alertify4j/Alertify.java | 4 ++-- .../org/nikkii/alertify4j/ui/AlertifyWindow.java | 16 ++++++++++++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index bc7ceb7..238cd8d 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,7 @@ Example with callback: // Callback code }) .build()); + +What the result looks like +======== +![Example](http://i.imgur.com/TM5PjL6.png) \ No newline at end of file diff --git a/src/main/java/org/nikkii/alertify4j/Alertify.java b/src/main/java/org/nikkii/alertify4j/Alertify.java index 491ddbd..437563f 100644 --- a/src/main/java/org/nikkii/alertify4j/Alertify.java +++ b/src/main/java/org/nikkii/alertify4j/Alertify.java @@ -123,7 +123,7 @@ public Alertify showAlert(final AlertifyConfig config) { int baseY = screen.height; for (AlertifyWindow window : windows) { - baseY -= window.getHeight() + 10; + baseY -= window.getActualHeight() + 10; } if (baseY < 0) { @@ -269,7 +269,7 @@ private void consolidateWindows() { int newY = screen.height; for (AlertifyWindow w : windows) { - newY -= w.getHeight() + 10; // 10px spacing + newY -= w.getActualHeight() + 10; // 10px spacing if (w.getY() != newY) { moveWindow(w, newY); } diff --git a/src/main/java/org/nikkii/alertify4j/ui/AlertifyWindow.java b/src/main/java/org/nikkii/alertify4j/ui/AlertifyWindow.java index 061a8f2..2ae134f 100644 --- a/src/main/java/org/nikkii/alertify4j/ui/AlertifyWindow.java +++ b/src/main/java/org/nikkii/alertify4j/ui/AlertifyWindow.java @@ -23,6 +23,9 @@ */ public class AlertifyWindow extends JWindow { + private int actualWidth; + private int actualHeight; + /** * Flag for whether we're 'hidden'. */ @@ -59,8 +62,8 @@ public AlertifyWindow(AlertifyTheme theme, AlertifyType type, JLabel label) { Dimension contentSize = content.getPreferredSize(); - int actualWidth = Math.max(contentSize.width, 300); - int actualHeight = Math.max(contentSize.height, 64); + actualWidth = Math.max(contentSize.width, 300); + actualHeight = Math.max(contentSize.height, 64); setAlwaysOnTop(true); setPreferredSize(new Dimension(actualWidth, actualHeight)); @@ -102,4 +105,13 @@ public boolean isHidden() { public void setCloseFuture(ScheduledFuture closeFuture) { this.closeFuture = closeFuture; } + + + public int getActualWidth() { + return actualWidth; + } + + public int getActualHeight() { + return actualHeight; + } }