07-18-2012 01:46 AM
In above u can see that ButtonField didn't show any label, what should I do for taht??
In that I had use setExtent() method to fit my buttons on display.
btnSeven = new ButtonField("7") {
protected void layout(int width, int height) {
setExtent(Display.getWidth()>>3, 30);
}
};
btnEight = new ButtonField("8") {
protected void layout(int width, int height) {
setExtent(Display.getWidth()>>3, 30);
}
// protected void paintBackground(Graphics g) {
//
//
// };
};
btnNine = new ButtonField("9") {
protected void layout(int width, int height) {
setExtent(Display.getWidth()>>3, 30);
}
};
btnDiv = new ButtonField("/") {
protected void layout(int width, int height) {
setExtent(Display.getWidth()>>3, 30);
}
};
when I remove setExtent Method label of buttonField will display.
Solved! Go to Solution.
07-18-2012 05:38 AM
07-18-2012 06:01 AM
07-18-2012 10:51 AM
Your problem is your layout override - ButtonField does much more in its layout than just setting the extent. The proper way with ButtonField (never documented, by the way, so I understand your confusion) is to define getPreferredWidth and getPreferredHeight to return your desirable dimensions and leave its layout alone.
When you are ready to play with backgrounds, take a look at Background and BackgroundFactory classes.
07-18-2012 05:29 PM