Skip to content

Commit

Permalink
enhance text fields creation
Browse files Browse the repository at this point in the history
  • Loading branch information
akmsw committed Jan 2, 2024
1 parent f53deaa commit 8a5a43d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
5 changes: 2 additions & 3 deletions src/main/java/armameeldoparti/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
Expand Down Expand Up @@ -99,7 +98,7 @@ private static void populatePlayersSets() {
.put(position, IntStream.range(0, CommonFields.getPlayersAmountMap()
.get(position) * 2)
.mapToObj(i -> new Player("", position))
.collect(Collectors.toList())));
.toList()));
}

/**
Expand Down Expand Up @@ -128,7 +127,7 @@ private static void setPlayersDistribution() {
) {
List<String> filteredLines = buff.lines()
.filter(line -> line.matches(Constants.REGEX_PDA_DATA_RETRIEVE))
.collect(Collectors.toList());
.toList();

IntStream.range(0, filteredLines.size())
.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import javax.naming.InvalidNameException;
import javax.swing.JComboBox;
Expand Down Expand Up @@ -285,7 +284,7 @@ private void updateTextArea() {
.stream()
.filter(player -> !player.getName()
.equals("")))
.collect(Collectors.toList());
.toList();

IntStream.range(0, players.size())
.forEachOrdered(index -> view.getTextArea()
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/armameeldoparti/views/NamesInputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
import armameeldoparti.utils.common.custom.graphical.CustomTextArea;
import armameeldoparti.utils.common.custom.graphical.CustomTextField;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.stream.IntStream;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
Expand Down Expand Up @@ -147,15 +149,12 @@ private void addAnchoragesCheckbox() {
* Builds, stores and configures each position text fields.
*/
private void addTextFields() {
for (Position position : Position.values()) {
int totalPlayersInPosition = CommonFields.getPlayersAmountMap()
.get(position) * 2;

for (int i = 0; i < totalPlayersInPosition; i++) {
textFieldsMap.get(position)
.add(new CustomTextField());
}
}
Arrays.asList(Position.values())
.forEach(position -> textFieldsMap.get(position)
.addAll(IntStream.range(0, CommonFields.getPlayersAmountMap()
.get(position) * 2)
.mapToObj(i -> new CustomTextField())
.toList()));
}

/**
Expand Down

0 comments on commit 8a5a43d

Please sign in to comment.