iifast

Menu/with Arrow img

Mar 14th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.47 KB | None | 0 0
  1. // Menu/ToolBar ( with Arrow img )
  2. // https://imgur.com/a/dY1NTXo
  3. // MyApplication.java
  4.  
  5. package com.mycompany.myapp;
  6.  
  7. import com.codename1.ui.Display;
  8. import com.codename1.ui.Form;
  9. import com.codename1.ui.Dialog;
  10. import com.codename1.ui.plaf.UIManager;
  11. import com.codename1.ui.util.Resources;
  12. import com.codename1.ui.Command;
  13. import com.codename1.ui.Label;
  14. import com.codename1.ui.Toolbar;
  15. import com.codename1.ui.events.ActionEvent;
  16. import com.codename1.ui.events.ActionListener;
  17. import com.codename1.ui.layouts.BoxLayout;
  18. import com.codename1.ui.util.UIBuilder;
  19.  
  20. /**
  21.  * This file was generated by <a href="https://www.codenameone.com/">Codename
  22.  * One</a> for the purpose of building native mobile applications using Java.
  23.  */
  24. public class MyApplication {
  25.  
  26.     private Form current;
  27.     private Resources theme;
  28.     Form f1, f2, f3;
  29.     Command cmd1, cmd2, cmd3, cmdBack;
  30.  
  31.     public void init(Object context) {
  32.         theme = UIManager.initFirstTheme("/theme");
  33.  
  34.         // Enable Toolbar on all Forms by default
  35.         Toolbar.setGlobalToolbar(true);
  36.  
  37.         // Pro only feature, uncomment if you have a pro subscription
  38.         // Log.bindCrashProtection(true);
  39.     }
  40.  
  41.     public void start() {
  42.      
  43.        
  44.        
  45.        // UIBuilder ui = new UIBuilder();
  46.         Form f1 = new Form(BoxLayout.x());
  47.         f1.add(new Label("Page1"));
  48.         Form f2= new Form(BoxLayout.x());
  49.         f2.add(new Label("Page2"));
  50.         Form f3 = new Form(BoxLayout.x());
  51.         f3.add(new Label("Page3"));
  52.         Form home = new Form(BoxLayout.x());
  53.         home.add(new Label("Home"));
  54.        
  55.        
  56.         home.getToolbar().addCommandToSideMenu("Page 1", null, new ActionListener() {
  57.  
  58.             @Override
  59.             public void actionPerformed(ActionEvent evt) {
  60.          f1.show();
  61.             }
  62.         });
  63.        
  64.          
  65.         home.getToolbar().addCommandToSideMenu("Page 2", null, new ActionListener() {
  66.  
  67.             @Override
  68.             public void actionPerformed(ActionEvent evt) {
  69.          f2.show();
  70.             }
  71.         });
  72.          
  73.         home.getToolbar().addCommandToSideMenu("Page 3", null, new ActionListener() {
  74.  
  75.             @Override
  76.             public void actionPerformed(ActionEvent evt) {
  77.          f3.show();
  78.             }
  79.         });
  80.        
  81.        
  82.        
  83.         f1.getToolbar().addCommandToLeftBar("Back", theme.getImage("back-command.png"), new ActionListener() {
  84.  
  85.             @Override
  86.             public void actionPerformed(ActionEvent evt) {
  87.            home.showBack();
  88.            
  89.             }
  90.         });
  91.        
  92.          f2.getToolbar().addCommandToRightBar("Back", theme.getImage("back-command.png"), new ActionListener() {
  93.  
  94.             @Override
  95.             public void actionPerformed(ActionEvent evt) {
  96.            home.showBack();
  97.            
  98.             }
  99.         });
  100.        
  101.          
  102.           f3.getToolbar().addCommandToOverflowMenu("Back", theme.getImage("back-command.png"), new ActionListener() {
  103.  
  104.             @Override
  105.             public void actionPerformed(ActionEvent evt) {
  106.            home.showBack();
  107.            
  108.             }
  109.         });
  110.        home.show();
  111.     }
  112.  
  113.     public void stop() {
  114.         current = Display.getInstance().getCurrent();
  115.         if (current instanceof Dialog) {
  116.             ((Dialog) current).dispose();
  117.             current = Display.getInstance().getCurrent();
  118.         }
  119.     }
  120.  
  121.     public void destroy() {
  122.     }
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment