forked from External/mage
random button
This commit is contained in:
parent
9e6e731a9e
commit
a4dc36d671
2 changed files with 26 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ import java.awt.event.*;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.*;
|
||||
|
||||
import static mage.client.dialog.PreferencesDialog.*;
|
||||
|
|
@ -619,6 +620,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
jButtonRemoveFromMain = new javax.swing.JButton();
|
||||
jButtonAddToSideboard = new javax.swing.JButton();
|
||||
jButtonRemoveFromSideboard = new javax.swing.JButton();
|
||||
jButtonRandomCard = new javax.swing.JButton();
|
||||
jTextFieldSearch = new javax.swing.JTextField();
|
||||
chkNames = new javax.swing.JCheckBox();
|
||||
chkTypes = new javax.swing.JCheckBox();
|
||||
|
|
@ -1152,6 +1154,18 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
});
|
||||
|
||||
jButtonRandomCard.setIcon(new javax.swing.ImageIcon(getClass().getResource("/buttons/dice.png"))); // NOI18N
|
||||
jButtonRandomCard.setToolTipText("Add a random card from the current search to your deck.");
|
||||
jButtonRandomCard.setMargin(null);
|
||||
jButtonRandomCard.setMaximumSize(new java.awt.Dimension(35, 23));
|
||||
jButtonRandomCard.setMinimumSize(new java.awt.Dimension(35, 23));
|
||||
jButtonRandomCard.setPreferredSize(new java.awt.Dimension(30, 28));
|
||||
jButtonRandomCard.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonRandomCardActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jTextFieldSearch.setToolTipText("Searches for card names and in the rule text of the card.");
|
||||
|
||||
chkNames.setSelected(true);
|
||||
|
|
@ -1248,6 +1262,8 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
.addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2, 2, 2)
|
||||
.addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(2,2,2)
|
||||
.addComponent(jButtonRandomCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
|
|
@ -1282,6 +1298,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
.addComponent(jButtonRemoveFromMain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonAddToSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonRemoveFromSideboard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonRandomCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(cardSelectorBottomPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jTextFieldSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jButtonSearch)
|
||||
|
|
@ -1432,6 +1449,14 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
}
|
||||
}//GEN-LAST:event_jButtonAddToMainActionPerformed
|
||||
|
||||
private void jButtonRandomCardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToMainActionPerformed
|
||||
int n = mainTable.getRowCount();
|
||||
mainModel.doubleClick(ThreadLocalRandom.current().nextInt(n), null, false);
|
||||
if (limited) {
|
||||
mainModel.fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void jButtonAddToSideboardActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAddToSideboardActionPerformed
|
||||
if (mainTable.getSelectedRowCount() > 0) {
|
||||
int[] n = mainTable.getSelectedRows();
|
||||
|
|
@ -1693,6 +1718,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
|
|||
private javax.swing.JButton jButtonClean;
|
||||
private javax.swing.JButton jButtonRemoveFromMain;
|
||||
private javax.swing.JButton jButtonRemoveFromSideboard;
|
||||
private javax.swing.JButton jButtonRandomCard;
|
||||
private javax.swing.JButton jButtonSearch;
|
||||
private javax.swing.JToolBar.Separator jSeparator1;
|
||||
private javax.swing.JToolBar.Separator jSeparator2;
|
||||
|
|
|
|||
BIN
Mage.Client/src/main/resources/buttons/dice.png
Normal file
BIN
Mage.Client/src/main/resources/buttons/dice.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
Loading…
Add table
Add a link
Reference in a new issue