fix: crash when no installed javas detected

This commit is contained in:
Ryan Dowling 2019-06-24 16:12:21 +10:00
parent 8b79d033dc
commit 13173a3798
No known key found for this signature in database
GPG key ID: 5539FCDB88950EFD
3 changed files with 14 additions and 12 deletions

1
.gitignore vendored
View file

@ -1,6 +1,7 @@
# Directories
.gradle/
.settings/
.vscode/settings.json
bin/
build/
dist/

View file

@ -1 +0,0 @@

View file

@ -243,20 +243,22 @@ public class JavaSettingsTab extends AbstractSettingsTab implements Relocalizati
JComboBox<JavaInfo> installedJavas = new JComboBox<>();
List<JavaInfo> systemJavas = Java.getInstalledJavas();
systemJavas.stream().forEach(javaInfo -> {
installedJavas.addItem(javaInfo);
});
if (systemJavas.size() != 0) {
systemJavas.stream().forEach(javaInfo -> {
installedJavas.addItem(javaInfo);
});
installedJavas.setSelectedItem(systemJavas.stream()
.filter(javaInfo -> javaInfo.rootPath.equalsIgnoreCase(App.settings.getJavaPath())).findFirst()
.get());
installedJavas.setSelectedItem(systemJavas.stream()
.filter(javaInfo -> javaInfo.rootPath.equalsIgnoreCase(App.settings.getJavaPath())).findFirst()
.get());
installedJavas.addActionListener(e -> {
javaPath.setText(((JavaInfo) installedJavas.getSelectedItem()).rootPath);
});
installedJavas.addActionListener(e -> {
javaPath.setText(((JavaInfo) installedJavas.getSelectedItem()).rootPath);
});
if (installedJavas.getItemCount() != 0) {
javaPathPanelTop.add(installedJavas);
if (installedJavas.getItemCount() != 0) {
javaPathPanelTop.add(installedJavas);
}
}
}