Computer Science Canada JLabel loop? |
Author: | Leo Crimson [ Sun Mar 04, 2012 11:27 am ] |
Post subject: | JLabel loop? |
Would it be possible to create a loop for this code (pretty much all the JLabel lines)? lblQuestion1 = new JLabel ("Question 1.", JLabel.LEFT); lblQuestion1.setPreferredSize (new Dimension (400, 35)); lblQuestion1.setFont(font1); lblQuestion2 = new JLabel ("Question 2", JLabel.LEFT); lblQuestion2.setPreferredSize(new Dimension (400,35)); lblQuestion2.setFont(font1); lblQuestion3 = new JLabel ("Question 3", JLabel.LEFT); lblQuestion3.setPreferredSize(new Dimension (400, 35)); lblQuestion3.setFont(font1); lblQuestion4 = new JLabel ("Question 4", JLabel.LEFT); lblQuestion4.setPreferredSize (new Dimension (400, 35)); lblQuestion4.setFont (font1); lblQuestion5 = new JLabel ("Question 5", JLabel.LEFT); lblQuestion5.setPreferredSize (new Dimension (400, 35)); lblQuestion5.setFont (font1); lblQuestion6 = new JLabel ("Question 6", JLabel.LEFT); lblQuestion6.setPreferredSize(new Dimension (400, 35)); lblQuestion6.setFont(font1); lblQuestion7 = new JLabel ("Question 7", JLabel.LEFT); lblQuestion7.setPreferredSize (new Dimension (400, 35)); lblQuestion7.setFont(font1); lblQuestion8 = new JLabel ("Question 8", JLabel.LEFT); lblQuestion8.setPreferredSize (new Dimension (400, 35)); lblQuestion8.setFont(font1); lblQuestion9 = new JLabel ("Question 9", JLabel.LEFT); lblQuestion9.setPreferredSize (new Dimension (400, 35)); lblQuestion9.setFont(font1); lblQuestion10 = new JLabel ("Question 10", JLabel.LEFT); lblQuestion10.setPreferredSize (new Dimension (400, 35)); lblQuestion10.setFont(font1); |
Author: | Insectoid [ Sun Mar 04, 2012 11:30 am ] |
Post subject: | RE:JLabel loop? |
Create an array of questions and use string operations to set the jlabel titles. |
Author: | Leo Crimson [ Sun Mar 04, 2012 3:44 pm ] |
Post subject: | Re: JLabel loop? |
Figured it out, thanks. ![]() |