HomeTabPane.java
上传用户:luxiaowei
上传日期:2022-06-06
资源大小:58k
文件大小:5k
源码类别:

J2ME

开发平台:

Java

  1. /*
  2.  * MOMTabPane.java
  3.  *
  4.  * Created on April 22, 2010, 12:45 PM
  5.  *
  6.  * To change this template, choose Tools | Template Manager
  7.  * and open the template in the editor.
  8.  */
  9. package com.MOM.ui.design;
  10. import com.MOM.ui.control.*;
  11. import com.MOM.Constants;
  12. import com.MOM.resources.Resources;
  13. import com.MOM.ui.MOMUiFactory;
  14. import com.framework.DisplayManager;
  15. import com.framework.EditControl;
  16. import com.framework.ImageControl;
  17. import com.framework.RadioControl;
  18. import com.framework.RadioGroup;
  19. import com.framework.ScrollableContainer;
  20. import com.framework.SpacerControl;
  21. import com.framework.TickerTextControl;
  22. import javax.microedition.lcdui.Graphics;
  23. /**
  24.  *
  25.  * @author Tejaswi
  26.  */
  27. public class HomeTabPane extends MOMTabPane {
  28.     /** Variables */
  29.     TickerTextControl searchButton;
  30.     EditControl searchEditControl;
  31.     RadioGroup searchRadioGroup;
  32.     ShareMarketReadingControl shareMarketControl;
  33.     MOMewsGroupControl topNewsGroup;
  34.     MOMewsGroupControl preMarket;
  35.     /** Creates a new instance of MOMTabPane */
  36.     public HomeTabPane() {
  37.     }
  38.     public void init() {
  39.         // creating tab button
  40.         tabButton = new SpacerControl();
  41.         tabButton.setBgImage(Resources.getInstance().getImage(Resources.HOME_ICON_OFF_IMAGE));
  42.         tabButton.setSelectionBgImage(Resources.getInstance().getImage(Resources.HOME_ICON_ON_IMAGE));
  43.         tabButton.setHeight(Resources.getInstance().getImage(Resources.TAB_BUTTON_ON_IMAGE).getHeight());
  44.         // creating tab body
  45.         tabBody = new ScrollableContainer();
  46.         tabBody.setLayout(Constants.TAB_PANE_LIST_LAYOUT);
  47.         // Adding search lable
  48.         tabBody.addChildren(MOMUiFactory.getDarckLabel(Constants.SEARCH_STRING));
  49.         tabBody.addChildren(getSearchBox());
  50.         tabBody.addChildren(getSearchRadioPane());
  51.         
  52.         shareMarketControl = new ShareMarketReadingControl();
  53.         tabBody.addChildren(shareMarketControl);
  54.         shareMarketControl.setNiftyChange("Change");
  55.         shareMarketControl.setSensexChange("Change");
  56.         shareMarketControl.setNiftyReading("Reading");
  57.         shareMarketControl.setSexsexReading("Reading");
  58.         
  59.         MultilineArrowControl label1 = new MultilineArrowControl(Constants.GLOBAL_MARKET_UPDATE_STRING, true, false,Resources.getInstance().getFontBlackMediumBold());
  60.         label1.setSelectable(false);
  61.         tabBody.addChildren(label1);
  62.         
  63.         topNewsGroup = new MOMewsGroupControl(Constants.TOP_NEWS_LABEL);
  64.         tabBody.addChildren(topNewsGroup);
  65.         topNewsGroup.addInformation("Dubai connection: Indian compaines may get extra hit.");
  66.         topNewsGroup.addInformation("Tata Moters Q2 cons seen at Rs. 170 cr");
  67.         topNewsGroup.addExtraInformation("More top news");
  68.         
  69.         
  70.         preMarket = new  MOMewsGroupControl(Constants.PRE_MARKET_STRING);
  71.         tabBody.addChildren(preMarket);
  72.         preMarket.addInformation("Asian Market end over.");
  73.         preMarket.addInformation("Dubai connection: Indian compaines may get extra hit.");
  74.         preMarket.addExtraInformation("More");
  75.     }
  76.     private ScrollableContainer getSearchBox() {
  77.         ScrollableContainer container = new ScrollableContainer();
  78.         container.setLayout(Constants.HORIZONAL_LAYOUT_01);
  79.         searchButton = MOMUiFactory.getSearchButton(Constants.SEARCH_STRING);
  80.         ImageControl imgControl = MOMUiFactory.getUnselectbleImageControl(Resources.getInstance().getImage(Resources.SEARCH_ICON_IMAGE));
  81.         searchEditControl = MOMUiFactory.getEditControl(DisplayManager.getInst().getWidth() - (4 * Constants.LEFT_PADDING) - searchButton.getWidth() - imgControl.getWidth(), searchButton.getHeight());
  82.         imgControl.setHeight(searchButton.getHeight());
  83.         imgControl.setAllignment(Graphics.HCENTER | Graphics.VCENTER);
  84.         container.addChildren(searchEditControl);
  85.         container.addChildren(searchButton);
  86.         container.addChildren(imgControl);
  87.         return container;
  88.     }
  89.     private ScrollableContainer getSearchRadioPane() {
  90.         ScrollableContainer container = new ScrollableContainer();
  91.         searchRadioGroup = new RadioGroup();
  92.         container.setLayout(Constants.HORIZONAL_LAYOUT_01);
  93.         for (int i = 0; i < Constants.SEARCH_RADIO_BUTTONS.length; i++) {
  94.             RadioControl control = MOMUiFactory.getRadioControl(Constants.SEARCH_RADIO_BUTTONS[i]);
  95.             container.addChildren(control);
  96.             searchRadioGroup.addRadioControl(control);
  97.         }
  98.         container.resize();
  99.         container.setHeight(container.getHeight() + Constants.TOP_PADDING);
  100.         return container;
  101.     }
  102. }