How can I create a 20-number Bet Card look in Jframe

Asked

Viewed 551 times

5

It is a game where your bet will be competing to Sena, Quina and Quadra, so each bet can only have 6 numbers, I need the user to select 6 numbers from these 20 and then I take these 6 selected and make the bet of it. But I just need this one Bookmaker.

So how can I create a Bookmaker of 20 numbers where you will select only 6 of them by clicking on it, then pick the numbers that were selected.
The comparison part and create numbers randomly is already ready and working, I’m using 6 Jcombobox from 1 to 20 for the user to choose the 6 numbers, but it would be more practical if he clicked the numbers scattered on the screen, I also wanted a ball behind each number to give an idea of Bingo. Thank you for your attention!

  • It is a game where your bet will be competing to Sena, Corner and Court, so each bet can only have 6 numbers, I need user to select 6 numbers from these 20 and then I take these 6 selected and make the bet from it.

  • OK I’ll prepare an answer to see if it helps you, however you should rephrase your question is a little confused

  • Okay thanks, I’ll do it.

1 answer

3


Check the code, I think that makes it more practical than selecting the numbers by a combobox, to implement the rule of just letting 5 numbers be selected, but I think you can do this now.

Code:

public class Matrizz extends javax.swing.JFrame {
private List<JToggleButton> listTogglebu = new ArrayList<JToggleButton>(20);
/**
 * Creates new form Matrizz
 */
public Matrizz() {
    initComponents();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    this.setLayout(new GridLayout(2,0));
    jPanel1.setBorder(new EmptyBorder(5, 5, 5, 5));
    this.setSize(500,300);
    this.add(jPanel1);
    this.add(jPanel2);
    jPanel1.setLayout(new GridLayout(2, 10));



    for (int y = 0; y < 20; y++) {
        listTogglebu.add(new JToggleButton("" + (y + 1)));
        jPanel1.add(listTogglebu.get(y));
    }
    JButton ver = new JButton("Selecionados");

    jPanel2.add(ver);
     ver.addActionListener( new ActionListener() {
                 public void actionPerformed(ActionEvent e) {
                      printSelecionado();
                 }


        });


}
  private void printSelecionado() {
            for (JToggleButton jToggleButton : listTogglebu) {
                if(jToggleButton.isSelected())System.out.println(" numero:"+jToggleButton.getText());

      }
        }

outworking:

inserir a descrição da imagem aqui

output:

run:  
numero:3
numero:4
numero:6
numero:12 
numero:15
numero:17
  • 1

    It was cool J Santos, I will implement it anyway, it became more practical, that’s exactly what I wanted, Thanks!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.