diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java index 01254aa..a3fc058 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/app/TimeCalcKeyAdapter.java @@ -187,8 +187,6 @@ public class TimeCalcKeyAdapter extends KeyAdapter { ioException.printStackTrace(); } int profileNumber = 0; - Toaster toaster = new Toaster(); - toaster.setDisplayTime(5000); switch(e.getKeyCode()) { case KeyEvent.VK_0: profileNumber = 0;break; case KeyEvent.VK_1: profileNumber = 1;break; @@ -205,25 +203,25 @@ public class TimeCalcKeyAdapter extends KeyAdapter { if(properties.containsKey(key)) { String profileName = (String) properties.get(key); if(profileName.equals( timeCalcConfiguration.profileNameProperty)) { - toaster.showToaster("Profile \"" + profileName + "\" is already active. Nothing to do"); + Utils.showNotification("Profile \"" + profileName + "\" is already active. Nothing to do", 5000); } else { - toaster.showToaster("Info: Changing profile to: " + (( + Utils.showNotification("Info: Changing profile to: " + (( profileName.isEmpty() ? "{Default profile}" : - profileName))); + profileName)), 5000); TimeCalcProperties.getInstance().loadProfile(profileName); timeCalcConfiguration.loadFromTimeCalcProperties( TimeCalcProperties.getInstance()); } } else { - JOptionPane.showMessageDialog(null, "Warning: There is no profile assigned to Key " + profileNumber, "Warning", JOptionPane.WARNING_MESSAGE); + Utils.showNotification("Warning: There is no profile assigned to Key " + profileNumber, 5000); } } if (e.getKeyCode() == KeyEvent.VK_F) { if(FileConstants.TIME_CALC_PROFILES_TXT_FILE.exists()) { try { - Utils.showNotification(Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE), 200); + Utils.showNotification(Utils.readTextFromFile(FileConstants.TIME_CALC_PROFILES_TXT_FILE), 15000, 200); } catch (IOException ioException) { ioException.printStackTrace(); Utils.showNotification("Error: " + ioException.getMessage()); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java index 207b6b6..5c967de 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/swing/common/HelpWindow.java @@ -34,8 +34,8 @@ public class HelpWindow extends TWindow { this.setLayout(null); JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBounds(1, 1, - getWidth() - SwingUtils.MARGIN, - getHeight() - SwingUtils.MARGIN); + getWidth() - 2 * SwingUtils.MARGIN, + getHeight() - 4 * SwingUtils.MARGIN); add(scrollPane); JEditorPane editor = new JEditorPane(); diff --git a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java index ccba3db..2d99156 100644 --- a/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java +++ b/modules/time-calc-app/src/main/java/org/nanoboot/utils/timecalc/utils/common/Utils.java @@ -144,9 +144,12 @@ public class Utils { public static void showNotification(String message) { showNotification(message, 0); } - public static void showNotification(String message, int height) { + public static void showNotification(String message, int displayTime) { + showNotification(message, displayTime, 0); + } + public static void showNotification(String message, int displayTime, int height) { Toaster toaster = new Toaster(); - toaster.setDisplayTime(15000); + toaster.setDisplayTime(displayTime == 0 ? 15000 : displayTime); if(height != 0) { toaster.setToasterHeight(height); }