{"id":4318,"date":"2014-03-30T09:51:22","date_gmt":"2014-03-30T09:51:22","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-can-i-draw-a-solid-square-in-blackberry-collection-of-common-programming-errors\/"},"modified":"2014-03-30T09:51:22","modified_gmt":"2014-03-30T09:51:22","slug":"how-can-i-draw-a-solid-square-in-blackberry-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/how-can-i-draw-a-solid-square-in-blackberry-collection-of-common-programming-errors\/","title":{"rendered":"How can I draw a solid square in BlackBerry?-Collection of common programming errors"},"content":{"rendered":"<p>try this code , Pass in the color in the constructor.<\/p>\n<pre><code>import net.rim.device.api.ui.Color;\nimport net.rim.device.api.ui.Field;\nimport net.rim.device.api.ui.Font;\nimport net.rim.device.api.ui.Graphics;\n\npublic class CustomField extends Field\n{\n\nprivate int backgroundColour; \nprivate int fieldWidth;\nprivate int fieldHeight; \nprivate int padding = 8;\n\npublic CustomField(int color)\n{\n    super(Field.FOCUSABLE); \n    fieldHeight = 100;\n    fieldWidth = 100;\n    this.setPadding(2, 2, 2, 2);\n    this.backgroundColour=color;\n} \n\npublic int getPreferredWidth()\n{\n    return fieldWidth;\n}\n\npublic int getPreferredHeight()\n{\n    return fieldHeight;\n}\n\nprotected void layout(int arg0, int arg1)\n{\n    setExtent(getPreferredWidth(), getPreferredHeight());\n}\n\nprotected void drawFocus(Graphics graphics, boolean on)\n{\n\n} \n\nprotected void paint(Graphics graphics)\n{\n    graphics.setColor(backgroundColour);\n    graphics.fillRect(0, 0, fieldWidth, fieldHeight); \n}\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>try this code , Pass in the color in the constructor. import net.rim.device.api.ui.Color; import net.rim.device.api.ui.Field; import net.rim.device.api.ui.Font; import net.rim.device.api.ui.Graphics; public class CustomField extends Field { private int backgroundColour; private int fieldWidth; private int fieldHeight; private int padding = 8; public CustomField(int color) { super(Field.FOCUSABLE); fieldHeight = 100; fieldWidth = 100; this.setPadding(2, 2, 2, 2); this.backgroundColour=color; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4318","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4318"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4318\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}