English 中文(简体)
无法在显示纽芬兰-黑莓清单的形式上添加背景图或图像
原标题:Not able to add background color or image on the form displaying a list of buttons-Blackberry

我正在拟订以下法典,该法典有6个州的欢迎形式。

在点击其中每一个县时,它打开了新的表格。

   class MyAPP extends UiApplication {
    public static void main(String[] args) {
            UiApplication instance = new MyAPP();
            instance.enterEventDispatcher();
    }
    private ButtonField btntest,btntest1,btntest2,btntest3,btntest4,btntest5;
    public MyAPP() {

            MainScreen testScreen = new MainScreen();


            final LabelField field  = new LabelField("Company",LabelField.FIELD_HCENTER | LabelField.NON_FOCUSABLE)
    {
        protected void paint(Graphics g)
            {       
                     g.clear();
                    g.drawRect(0,0, 50, 50);
                    int oldColor = g.getColor();
                    g.setColor(Color.DODGERBLUE);
                    g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
                    g.setColor(oldColor);
                    g.drawRect(100, 100, 50, 50);
                    super.paint(g);
             }
    };
    testScreen.setTitle(field);


    //Add status field to bottom of screen in blue color

    final LabelField field1  = new LabelField(" Copyright")
    {
        protected void paint(Graphics g)
            {       
                  //   g.clear();
                    g.drawRect(0,0, 50, 50);
                    int oldColor = g.getColor();
                    g.setColor(Color.DODGERBLUE);
                    g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
                    g.setColor(oldColor);
                    g.drawRect(100, 100, 50, 50);
                    super.paint(g);
             }

    };
    //field1.setFontColor(Color.WHITE);

        btntest1 = new ButtonField("Customer",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);  
        btntest = new ButtonField("Bills  ",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);
        btntest2 = new ButtonField("Ledger ",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK); 
        btntest3 = new ButtonField("Receipts",ButtonField.FIELD_HCENTER | ButtonField.CONSUME_CLICK);


         btntest1.setChangeListener(new FieldChangeListener()
      {
           public void fieldChanged(Field field,int context) 
           {
              pushScreen(new NextScreen2());
           }
      });




     btntest.setChangeListener(new FieldChangeListener()
      {
           public void fieldChanged(Field field,int context) 
           {
              pushScreen(new NextScreen1());
           }
      });


      btntest2.setChangeListener(new FieldChangeListener()
      {
           public void fieldChanged(Field field,int context) 
           {
              pushScreen(new NextScreen4());
           }

      });

我也试图绘制一个形象图,该图位于形式的核心,但该图在任何地方出现。

In the present code i have added title and status fields and also i have added

  1. An image to the top of the screen with welcome caption.
  2. There are 6 buttons that are center aligned.

这是否是因为纽托邦处于中心位置,而且没有空间可以用来执行彩色,无法看到。 另外,我也未能增加整个形式背景的图像。 任何了解解决办法的人都应获得指导。 成就

最佳回答

Try following code:

// initialize background
Bitmap bm = Bitmap.getBitmapResource("myImage");
Background bg = BackgroundFactory.createBitmapBackground(bm);

// getMainManager(), apply background
testScreen.getMainManager().setBackground(bg);
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签