containable frame: fix parsing version strings with only a major number

This commit is contained in:
Adam
2021-04-13 11:24:52 -04:00
parent c2fa0a8857
commit 0914d5df90
2 changed files with 17 additions and 2 deletions

View File

@@ -75,10 +75,22 @@ public class ContainableFrame extends JFrame
javaVersion = javaVersion.substring(0, idx); javaVersion = javaVersion.substring(0, idx);
} }
String[] s = javaVersion.split("\\."); String[] s = javaVersion.split("\\.");
int major = Integer.parseInt(s[0]), minor = Integer.parseInt(s[1]), patch = Integer.parseInt(s[2]); int major, minor, patch;
if (s.length == 3)
{
major = Integer.parseInt(s[0]);
minor = Integer.parseInt(s[1]);
patch = Integer.parseInt(s[2]);
}
else
{
major = Integer.parseInt(s[0]);
minor = -1;
patch = -1;
}
if (major == 12 || major == 13 || major == 14) if (major == 12 || major == 13 || major == 14)
{ {
// These versions are since EOL & do not include JDK-8231564 // These versions are since EOL & do not include JDK-8231564, except for 13.0.4+
return false; return false;
} }
return major > 11 || (major == 11 && minor > 0) || (major == 11 && minor == 0 && patch >= 8); return major > 11 || (major == 11 && minor > 0) || (major == 11 && minor == 0 && patch >= 8);
@@ -138,6 +150,7 @@ public class ContainableFrame extends JFrame
/** /**
* Expand frame by specified value. If the frame is going to be expanded outside of screen push the frame to * Expand frame by specified value. If the frame is going to be expanded outside of screen push the frame to
* the side. * the side.
*
* @param value size to expand frame by * @param value size to expand frame by
*/ */
public void expandBy(final int value) public void expandBy(final int value)
@@ -197,6 +210,7 @@ public class ContainableFrame extends JFrame
/** /**
* Contract frame by specified value. If new frame size is less than it's minimum size, force the minimum size. * Contract frame by specified value. If new frame size is less than it's minimum size, force the minimum size.
* If the frame was pushed from side before, restore it's original position. * If the frame was pushed from side before, restore it's original position.
*
* @param value value to contract frame by * @param value value to contract frame by
*/ */
public void contractBy(final int value) public void contractBy(final int value)

View File

@@ -39,5 +39,6 @@ public class ContainableFrameTest
assertFalse(ContainableFrame.jdk8231564("12.0.0")); assertFalse(ContainableFrame.jdk8231564("12.0.0"));
assertFalse(ContainableFrame.jdk8231564("13.0.0")); assertFalse(ContainableFrame.jdk8231564("13.0.0"));
assertFalse(ContainableFrame.jdk8231564("14.0.0")); assertFalse(ContainableFrame.jdk8231564("14.0.0"));
assertTrue(ContainableFrame.jdk8231564("15"));
} }
} }