| 1 29 30 package nextapp.echo2.testapp.thousandmonkeys.factories; 31 32 import nextapp.echo2.app.Color; 33 import nextapp.echo2.app.Component; 34 import nextapp.echo2.app.Label; 35 import nextapp.echo2.testapp.thousandmonkeys.ComponentFactory; 36 37 40 public class LabelFactory 41 implements ComponentFactory{ 42 43 private int count = 0; 44 45 48 public Component newInstance() { 49 Label label = new Label(); 50 switch ((int) (Math.random() * 3)) { 51 case 0: 52 label.setText("Label #" + ++count); 53 label.setBackground(new Color((int) (16777216 * Math.random()))); 54 break; 55 case 1: 56 label.setText("The quirk red fox jumps over the lazy brown dog."); 57 label.setForeground(new Color((int) (16777216 * Math.random()))); 58 break; 59 case 2: 60 label.setText("Initially Plain Label"); 61 break; 62 } 63 return label; 64 } 65 } 66 | Popular Tags |