iifast

Untitled

Feb 11th, 2020
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.22 KB | None | 0 0
  1. // DROW
  2. package com.mycompany.myapp;
  3.  
  4. import static com.codename1.ui.CN.*;
  5. import com.codename1.ui.Display;
  6. import com.codename1.ui.Form;
  7. import com.codename1.ui.Dialog;
  8. import com.codename1.ui.Label;
  9. import com.codename1.ui.plaf.UIManager;
  10. import com.codename1.ui.util.Resources;
  11. import com.codename1.io.Log;
  12. import com.codename1.ui.Toolbar;
  13. import java.io.IOException;
  14. import com.codename1.ui.layouts.BoxLayout;
  15. import com.codename1.io.NetworkEvent;
  16. import com.codename1.ui.FontImage;
  17. import com.codename1.ui.events.ActionEvent;
  18. import com.codename1.ui.events.ActionListener;
  19.  
  20. /**
  21.  * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
  22.  * of building native mobile applications using Java.
  23.  */
  24. public class MyApplication {
  25.  
  26.     private Form current;
  27.     private Resources theme;
  28.  
  29.     public void init(Object context) {
  30.         // use two network threads instead of one
  31.         updateNetworkThreadCount(2);
  32.  
  33.         theme = UIManager.initFirstTheme("/theme");
  34.  
  35.         // Enable Toolbar on all Forms by default
  36.         Toolbar.setGlobalToolbar(true);
  37.  
  38.         // Pro only feature
  39.         Log.bindCrashProtection(true);
  40.  
  41.         addNetworkErrorListener(err -> {
  42.             // prevent the event from propagating
  43.             err.consume();
  44.             if(err.getError() != null) {
  45.                 Log.e(err.getError());
  46.             }
  47.             Log.sendLogAsync();
  48.             Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
  49.         });        
  50.     }
  51.    
  52.     public void start() {
  53.         if(current != null){
  54.             current.show();
  55.             return;
  56.         }
  57.        Form hi = new Form("WEBSITE", BoxLayout.y());
  58.       // Form hi1 = new Form("Hi World", BoxLayout.xCenter()); ????????
  59.        Form hi2 = new Form("WEBSITE", BoxLayout.y());
  60.        Form hi3 = new Form("SETTINGS",BoxLayout.y());
  61.        Form hi4 = new Form("About",BoxLayout.y());
  62.          
  63.        
  64.        Toolbar tb = hi.getToolbar();
  65.        Toolbar tb1 = hi2.getToolbar();
  66.         Toolbar tb2 = hi3.getToolbar();
  67.          Toolbar tb3 = hi4.getToolbar();
  68.        
  69.      
  70.        
  71.        
  72.          /************** Website Toolbar  ***********/
  73.           tb.addMaterialCommandToSideMenu("Website", FontImage.MATERIAL_WEB,new ActionListener() {
  74.             @Override
  75.             public void actionPerformed(ActionEvent evt) {
  76.             hi2.show();
  77.           }
  78.         });
  79.        
  80.           /***************  Settings  Toolbar   **********/
  81.             tb.addMaterialCommandToSideMenu("Settings", FontImage.MATERIAL_SETTINGS, new ActionListener() {
  82.             @Override
  83.             public void actionPerformed(ActionEvent evt) {
  84.                 hi3.show();
  85.            
  86.             }
  87.         });
  88.             /***************  About  Toolbar   **********/
  89.             tb.addMaterialCommandToSideMenu("About", FontImage.MATERIAL_MORE, new ActionListener() {
  90.             @Override
  91.             public void actionPerformed(ActionEvent evt) {
  92.                 hi4.show();
  93.            
  94.             }
  95.         });
  96.            
  97.             /************  Back WebSite → Home    *******************/
  98.            
  99.        tb1.addCommandToLeftBar("Back",null, new ActionListener(){
  100.             @Override
  101.             public void actionPerformed(ActionEvent evt) {
  102.                 hi.show();
  103.            
  104.             }
  105.         });  
  106.            
  107.           /************  Back Setting → Home    *******************/
  108.            
  109.        tb2.addCommandToLeftBar("Back",null, new ActionListener(){
  110.             @Override
  111.             public void actionPerformed(ActionEvent evt) {
  112.                 hi.show();
  113.            
  114.             }
  115.         });
  116.        
  117.           /************  Back(on the Right) About → Home    *******************/
  118.            
  119.        tb3.addCommandToRightBar("Back",null, new ActionListener(){
  120.             @Override
  121.             public void actionPerformed(ActionEvent evt) {
  122.                 hi.show();
  123.  
  124.             }
  125.         });
  126.        
  127.        
  128.           /**************************************************************************/
  129.         hi.add(new Label("Hi World"));
  130.         hi.show();
  131.        
  132.        
  133.         //Step2 (not done yet ) : FlowLayout → CENTER CENTER pour (Web,Setting,About)
  134.        
  135.        
  136.     }
  137.  
  138.     public void stop() {
  139.         current = getCurrentForm();
  140.         if(current instanceof Dialog) {
  141.             ((Dialog)current).dispose();
  142.             current = getCurrentForm();
  143.         }
  144.     }
  145.    
  146.     public void destroy() {
  147.     }
  148.  
  149. }
  150.  
  151.   /*******************************  COMBOBOX  *******************************************/
  152. /*
  153.       Form hi = new Form("ComboBox", new BoxLayout(BoxLayout.Y_AXIS));
  154.        
  155.        
  156.     ComboBox combo = new ComboBox();
  157.     combo.addItem("Ali");
  158.     combo.addItem("Mohamed");
  159.     combo.addItem("Sarrah");
  160.  
  161.     hi.add(combo);
  162.       hi.show();
  163. */
Advertisement
Add Comment
Please, Sign In to add comment