Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Menu/ToolBar ( with Arrow img )
- // https://imgur.com/a/dY1NTXo
- // MyApplication.java
- package com.mycompany.myapp;
- import com.codename1.ui.Display;
- import com.codename1.ui.Form;
- import com.codename1.ui.Dialog;
- import com.codename1.ui.plaf.UIManager;
- import com.codename1.ui.util.Resources;
- import com.codename1.ui.Command;
- import com.codename1.ui.Label;
- import com.codename1.ui.Toolbar;
- import com.codename1.ui.events.ActionEvent;
- import com.codename1.ui.events.ActionListener;
- import com.codename1.ui.layouts.BoxLayout;
- import com.codename1.ui.util.UIBuilder;
- /**
- * This file was generated by <a href="https://www.codenameone.com/">Codename
- * One</a> for the purpose of building native mobile applications using Java.
- */
- public class MyApplication {
- private Form current;
- private Resources theme;
- Form f1, f2, f3;
- Command cmd1, cmd2, cmd3, cmdBack;
- public void init(Object context) {
- theme = UIManager.initFirstTheme("/theme");
- // Enable Toolbar on all Forms by default
- Toolbar.setGlobalToolbar(true);
- // Pro only feature, uncomment if you have a pro subscription
- // Log.bindCrashProtection(true);
- }
- public void start() {
- // UIBuilder ui = new UIBuilder();
- Form f1 = new Form(BoxLayout.x());
- f1.add(new Label("Page1"));
- Form f2= new Form(BoxLayout.x());
- f2.add(new Label("Page2"));
- Form f3 = new Form(BoxLayout.x());
- f3.add(new Label("Page3"));
- Form home = new Form(BoxLayout.x());
- home.add(new Label("Home"));
- home.getToolbar().addCommandToSideMenu("Page 1", null, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- f1.show();
- }
- });
- home.getToolbar().addCommandToSideMenu("Page 2", null, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- f2.show();
- }
- });
- home.getToolbar().addCommandToSideMenu("Page 3", null, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- f3.show();
- }
- });
- f1.getToolbar().addCommandToLeftBar("Back", theme.getImage("back-command.png"), new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- home.showBack();
- }
- });
- f2.getToolbar().addCommandToRightBar("Back", theme.getImage("back-command.png"), new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- home.showBack();
- }
- });
- f3.getToolbar().addCommandToOverflowMenu("Back", theme.getImage("back-command.png"), new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- home.showBack();
- }
- });
- home.show();
- }
- public void stop() {
- current = Display.getInstance().getCurrent();
- if (current instanceof Dialog) {
- ((Dialog) current).dispose();
- current = Display.getInstance().getCurrent();
- }
- }
- public void destroy() {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment