so im very very new to java I just started a few days ago so heres my question:
I want to click on that button
JButton buttonRandom = new JButton("Roll The Dice");
buttonRandom.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent arg0)
{
}
and then it should change this lable
JLabel lableNum1 = new JLabel(String.valueOf(zufallsZahlOne));
lableNum1.setFont(new Font("Tahoma", Font.BOLD, 16));
lableNum1.setHorizontalAlignment(SwingConstants.CENTER);
lableNum1.setBounds(10, 11, 66, 51);
frame.getContentPane().add(lableNum1);
into this random number maybe im just too stupid ^^
public int randomZahlenEins()
{
Random r = new Random();
int min = 1;
int max = 6;
int zufallsZahlEins = r.nextInt((max - min) + 1) + min;
return zufallsZahlEins;
}
Aucun commentaire:
Enregistrer un commentaire