problem with appearance of pane tab

The following code creates a tab simple part Manager with 2 tabs and simple LabelField for the tab labels.  In the image as an attachment, you will see that there is a solid experience behind the LabelField.  I tried to give transparent backgrounds of the LabelField, but who has not removed this experience.  How can I get rid of this experience?

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.component.pane.*;
import net.rim.device.api.ui.decor.*;

public class BugRptTabs extends UiApplication
{
  public static void main(String[] args)
  {
    UiApplication instance = new BugRptTabs();
    instance.enterEventDispatcher();
  }    

  public BugRptTabs()
  {
    pushScreen( new BugScreen() );
  }

  private class BugScreen extends MainScreen
  {
    public BugScreen()
    {
      super( Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR
                    | Manager.NO_HORIZONTAL_SCROLL
                    | Screen.DEFAULT_CLOSE
                                        | Screen.DEFAULT_MENU );

      // setup the tab model with 2 tabs
      PaneManagerModel model = new PaneManagerModel();
      model.enableLooping( true );

      // create a transparent background
      Background bg = BackgroundFactory.createSolidTransparentBackground(
                                                       Color.BLACK, 0 );

      // setup the first tab
      VerticalFieldManager vfm = new VerticalFieldManager(
                               Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH |
                               Manager.NO_VERTICAL_SCROLL |
                               Manager.NO_HORIZONTAL_SCROLL );
      LabelField lbl = new LabelField( "Content for tab 1", Field.FOCUSABLE );
      vfm.add( lbl );
      MyLabelField myLbl = new MyLabelField( "Tab 1", Field.FOCUSABLE );
      myLbl.setBackground( bg );
      Pane pane = new Pane( myLbl, vfm );
      model.addPane( pane );

      // setup the second tab
      vfm = new VerticalFieldManager( Field.USE_ALL_HEIGHT | Field.USE_ALL_WIDTH |
                                      Manager.NO_VERTICAL_SCROLL |
                                      Manager.NO_HORIZONTAL_SCROLL );
      lbl = new LabelField( "Content for tab 2", Field.FOCUSABLE );
      vfm.add( lbl );
      myLbl = new MyLabelField( "Log", Field.FOCUSABLE );
      myLbl.setBackground( bg );
      pane = new Pane( myLbl, vfm );
      model.addPane( pane );

      // select the tab to be displayed
      model.setCurrentlySelectedIndex( 0 );     

      // setup the rest of the components
      HorizontalTabTitleView titleView =
               new HorizontalTabTitleView( Field.FOCUSABLE );
      titleView.setNumberOfDisplayedTabs( 2 );
      titleView.setModel( model );

      PaneView paneView = new PaneView( Field.FOCUSABLE );
      paneView.setModel( model );

      PaneManagerView view = new PaneManagerView( Field.FOCUSABLE  |
                                           Manager.NO_VERTICAL_SCROLL |
                                           Manager.NO_HORIZONTAL_SCROLL |
                                           Manager.USE_ALL_HEIGHT |
                                           Manager.USE_ALL_WIDTH,
                                           titleView, paneView );
      view.setModel( model );
      model.setView( view );

      // set the background color of the tabs
      bg = BackgroundFactory.createSolidBackground( Color.BLACK );
      titleView.setTabBackground( Field.VISUAL_STATE_ACTIVE, bg );
      titleView.setTabBackground( Field.VISUAL_STATE_FOCUS, bg );
      titleView.setTabBackground( Field.VISUAL_STATE_NORMAL, bg );

      // set the background color of the remainder of the
      // title area (behind the tabs)
      titleView.setBackground( Field.VISUAL_STATE_ACTIVE, bg );
      titleView.setBackground( Field.VISUAL_STATE_FOCUS, bg );
      titleView.setBackground( Field.VISUAL_STATE_NORMAL, bg );

      // configure the Controller
      HorizontalTabController controller = new HorizontalTabController();
      controller.setModel( model );
      controller.setView( view );
      model.setController( controller );
      view.setController( controller );

      // add the tab manager to the MainScreen
      this.add( view );
    }

    private class MyLabelField extends LabelField
    {
      public MyLabelField( String str )
      {
        super( str );
      }

      public MyLabelField( String str, long style )
      {
        super( str, style );
      }

      protected void paint(Graphics graphics)
      {
        graphics.setColor( Color.WHITE );
        super.paint( graphics );
      }
    }
  }
}

A few other changes were necessary to 6.0.  I removed titleView.setTabBackground (Field.VISUAL_STATE_FOCUS, bg); andtitleView.setBackground (Field.VISUAL_STATE_FOCUS, bg); and changed the way the labels have been added.

Rather than use a focusable LabelField, do the lbl1 and lbl2 LabelFields not focusable and create a NullField focusable.  Add the two of them to a HorizontalFieldManager and also use the label to your component.

This allows the screenshot I attached (using the same Simulator with which you test).

Tags: BlackBerry Developers

Similar Questions

Maybe you are looking for