Skip to content

Commit

Permalink
fix double update bug in shuffle selection
Browse files Browse the repository at this point in the history
  • Loading branch information
warmCabin committed Nov 15, 2023
1 parent b8fb9d3 commit 67e15ff
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/main/java/io/github/arrayv/prompts/ShufflePrompt.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,19 @@ private void initComponents() {
jScrollPane1.setViewportView(this.jList1);
jScrollPane2.setViewportView(this.jList2);

jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList1.addListSelectionListener(evt -> {
try {
jList1ValueChanged();
jList1ValueChanged(evt);
} catch (Exception e) {
JErrorPane.invokeErrorMessage(e);
}
});

jList2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
jList2.addListSelectionListener(evt -> {
try {
jList2ValueChanged();
jList2ValueChanged(evt);
} catch (Exception e) {
JErrorPane.invokeErrorMessage(e);
}
Expand Down Expand Up @@ -205,17 +207,17 @@ private void jButton1ActionPerformed() {//GEN-FIRST:event_jList1ValueChanged
new ShuffleDialog(arrayManager, this);
}//GEN-LAST:event_jList1ValueChanged

private void jList1ValueChanged() {//GEN-FIRST:event_jList1ValueChanged
if (initializing)
private void jList1ValueChanged(ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
if (initializing || evt.getValueIsAdjusting())
return;
int selection = jList1.getSelectedIndex();
Distributions[] distributions = arrayManager.getDistributions();
if (selection >= 0 && selection < distributions.length)
arrayManager.setDistribution(distributions[selection]);
}//GEN-LAST:event_jList1ValueChanged

private void jList2ValueChanged() {//GEN-FIRST:event_jList1ValueChanged
if (initializing)
private void jList2ValueChanged(ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
if (initializing || evt.getValueIsAdjusting())
return;
int selection = jList2.getSelectedIndex();
if (shuffleModel.getElementAt(0).equals("Advanced")) {
Expand Down

0 comments on commit 67e15ff

Please sign in to comment.