私はlwuitアプリを作っています。それにインデックスを使いたいです。
たとえば。LWUITで2(raise to)3を表示するにはどうすればよいですか?それを行う方法はありますか?
class
基本式を含む派生物を作成Container
します。この例では、2であり、パワー(ここでは3)です。
public class Power extends Container {
private Label pow = new Label(), base = new Label();
public Power(String base, String power)
{
super(new BoxLayout(BoxLayout.Y_AXIS));
getStyle().setPadding(0, 0, 0, 0);
this.base.setText(base);
String temp = "";
while (temp.length() < base.length())
{
temp = temp.concat(" ");
}
temp = temp.concat(power);
pow.setText(temp);
pow.setTextPosition(Label.BOTTOM);
Font font = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
pow.getStyle().setFont(font, false);
pow.getStyle().setPadding(Component.BOTTOM, 0, false);
pow.getStyle().setMargin(Component.BOTTOM, 0, false);
this.base.getStyle().setMargin(Component.TOP, 0, false);
addComponent(pow);
addComponent(this.base);
}
}
次にinstanciate
、それをあなたの中Form
に追加し、それを追加します(addComponent
):
public class yourForm extends Form
{
...
private Power expr = new Power("2","3");
...
public yourForm()
{
...
addComponent(expr);
...
}
...
}