1 2 23 24 package javax.microedition.lcdui; 25 26 27 public abstract class Item 28 { 29 30 static final int OUTOFITEM = Integer.MAX_VALUE; 31 32 StringComponent labelComponent; 33 Screen owner = null; 34 private boolean focus = false; 35 36 37 Item(String label) 38 { 39 labelComponent = new StringComponent(label); 40 } 41 42 43 public String getLabel() 44 { 45 return labelComponent.getText(); 46 } 47 48 49 public void setLabel(String label) 50 { 51 labelComponent.setText(label); 52 } 53 54 55 int getHeight() 56 { 57 return labelComponent.getHeight(); 58 } 59 60 61 boolean isFocusable() 62 { 63 return false; 64 } 65 66 67 void keyPressed(int keyCode) 68 { 69 } 70 71 72 abstract int paint(Graphics g); 73 74 75 void paintContent(Graphics g) 76 { 77 labelComponent.paint(g); 78 } 79 80 81 void repaint() 82 { 83 if (owner != null) { 84 owner.repaint(); 85 } 86 } 87 88 89 boolean hasFocus() 90 { 91 return focus; 92 } 93 94 95 void setFocus(boolean state) 96 { 97 focus = state; 98 } 99 100 101 Screen getOwner() 102 { 103 return owner; 104 } 105 106 107 void setOwner(Screen owner) 108 { 109 this.owner = owner; 110 } 111 112 113 boolean select() 114 { 115 return false; 116 } 117 118 119 int traverse(int gameKeyCode, int top, int bottom, boolean action) 120 { 121 return 0; 122 } 123 124 } 125 | Popular Tags |