Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 JLabel loop?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Leo Crimson




PostPosted: 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);
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: 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.
Leo Crimson




PostPosted: Sun Mar 04, 2012 3:44 pm   Post subject: Re: JLabel loop?

Figured it out, thanks. Smile
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: