hey, I'm fairly new to Java programming, so I was wondering if I could get a little bit of help, or direction.
the following code works fine, but I need to edit it so that the labels are not alphabetic but numeric - so that the labels display 4 digits which are randomly initialized each time. I know I have to use math.random somehow, I'm just not sure how to apply it to my labels and such
this is the part of the code that I know I have to change, just not sure how exactly:
Code:import java.awt.*; import javax.swing.*; public class AnagramLabels { private Label lab1, lab2, lab3; public AnagramLabels(ThreeButtons.ThreeButtonFrame w ) { lab1 = new Label(); lab1.setBounds(230, 30, 200, 40); lab1.setFont(new Font("",Font.BOLD,30)); lab1.setText("ABCD"); w.add(lab1); w.repaint(); lab2 = new Label(); lab2.setBounds(230, 70, 200, 40); lab2.setFont(new Font("",Font.BOLD,30)); lab2.setText("EFGH"); w.add(lab2); w.repaint(); lab3 = new Label(); lab3.setBounds(230, 110, 200, 40); lab3.setFont(new Font("",Font.BOLD,30)); lab3.setText("TABC"); w.add(lab3); w.repaint(); } }


Reply With Quote


Bookmarks