⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainscreen.java

📁 java web services how to program
💻 JAVA
字号:
// Fig. 16.16: MainScreen.java
// MainScreen enables the user to select which Web service the
// MIDP device should invoke.
package jws1casestudy.clients.j2me;

// import J2ME packages
import javax.microedition.lcdui.*;

class MainScreen extends List {

   // create list of available Web services
   MainScreen( final Display display )
   {
      super( "Select Web service", List.IMPLICIT );

      // available Web services
      append( "Get book information", null );
      append( "Get best price", null );

      // create soft button commands
      Command selectCommand = 
         new Command( "Select", Command.OK, 0 );
      addCommand( selectCommand );

      // allow soft button access
      setCommandListener(
         new CommandListener() {

            // invoked when user presses soft button
            public void commandAction( 
               Command command, Displayable displayable )
            {
               // determine action, based on selected List item
               switch( getSelectedIndex() ) {

                  // get book info
                  case 0:
                     display.setCurrent(
                        new BookInformationScreen( display ) );
                     break;

                  // get best price
                  case 1:
                     display.setCurrent( 
                        new BookPriceScreen( display ) );
                     break;
               }

            } // end method commandAction
         }
      );

   } // end MainScreen constructor

} // end class MainScreen

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -