iifast

DrowMenu.java

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