Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Project Drow / Menu ( ToolBar/SideBar + Back + Logout )
- //https://imgur.com/a/EG1Bncr
- package com.mycompany.myapp;
- import com.codename1.components.ImageViewer;
- import com.codename1.components.SpanLabel;
- import static com.codename1.ui.CN.*;
- import com.codename1.ui.Display;
- import com.codename1.ui.Form;
- import com.codename1.ui.Dialog;
- import com.codename1.ui.Label;
- import com.codename1.ui.plaf.UIManager;
- import com.codename1.ui.util.Resources;
- import com.codename1.io.Log;
- import com.codename1.ui.Toolbar;
- import java.io.IOException;
- import com.codename1.ui.layouts.BoxLayout;
- import com.codename1.io.NetworkEvent;
- import com.codename1.ui.FontImage;
- import com.codename1.ui.events.ActionEvent;
- import com.codename1.ui.events.ActionListener;
- /**
- * 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) {
- // use two network threads instead of one
- updateNetworkThreadCount(2);
- theme = UIManager.initFirstTheme("/theme");
- // Enable Toolbar on all Forms by default
- Toolbar.setGlobalToolbar(true);
- addNetworkErrorListener(err -> {
- // prevent the event from propagating
- err.consume();
- if(err.getError() != null) {
- Log.e(err.getError());
- }
- Log.sendLogAsync();
- Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
- });
- }
- public void start() {
- if(current != null){
- current.show();
- return;
- }
- Form HomePage = new Form("HomePage", BoxLayout.y());
- // Form hi1 = new Form("Hi World", BoxLayout.xCenter()); ????????
- Form form1 = new Form("WEBSITE", BoxLayout.y());
- Form form2 = new Form("SETTINGS",BoxLayout.y());
- Form form3 = new Form("About",BoxLayout.y());
- Toolbar tb = HomePage.getToolbar();
- Toolbar tb1 = form1.getToolbar();
- Toolbar tb2 = form2.getToolbar();
- Toolbar tb3 = form3.getToolbar();
- /************** Website Toolbar (form1) ***********/
- tb.addMaterialCommandToSideMenu("Website", FontImage.MATERIAL_WEB,new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- form1.add(new SpanLabel(" tb.addMaterialCommandToSideMenu(\"Website\", FontImage.MATERIAL_WEB,new ActionListener() {\n" +
- " @Override\n" +
- " public void actionPerformed(ActionEvent evt) {\n" +
- " form1.add(new Label(\"Website Page \"));\n" +
- " form1.show();\n" +
- " } "));
- form1.show();
- }
- });
- /*************** Settings Toolbar (form2) **********/
- tb.addMaterialCommandToSideMenu("Settings", FontImage.MATERIAL_SETTINGS, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- form2.add(new SpanLabel(" tb.addMaterialCommandToSideMenu(\"Settings\", FontImage.MATERIAL_SETTINGS, new ActionListener() {\n" +
- " @Override\n" +
- " public void actionPerformed(ActionEvent evt) {\n" +
- " form2.add(new Label(\" Settings Page \"));\n" +
- " form2.show(); }"));
- form2.show();
- }
- });
- /*************** About Toolbar **********/
- tb.addMaterialCommandToSideMenu("About", FontImage.MATERIAL_MORE, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- form3.add(new SpanLabel("tb.addMaterialCommandToSideMenu(\"About\", FontImage.MATERIAL_MORE, new ActionListener() {\n" +
- " @Override\n" +
- " public void actionPerformed(ActionEvent evt) {\n" +
- " form3.add(new Label(\"About Page : tb.addMaterialCommandToSideMenu \"));\n" +
- " form3.show();"));
- form3.show();
- }
- });
- /*****************************************************************************************************/
- /************ Back WebSite → Home *******************/
- tb1.addCommandToLeftBar("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- HomePage.show();
- }
- });
- /************ Back Setting → Home *******************/
- //f3.getToolbar().addCommandToOverflowMenu("Back", theme.getImage("back-command.png"), new ActionListener() {
- tb2.addCommandToOverflowMenu("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- HomePage.show();
- }
- });
- /************ Back(on the Right) About → Home *******************/
- tb3.addCommandToRightBar("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- HomePage.show();
- }
- });
- /**************************************************************************/
- HomePage.add(new Label("Hi ! This is the Home Page"));
- HomePage.show();
- //Step2 (not done yet ) : FlowLayout → CENTER CENTER pour (Web,Setting,About)
- }
- public void stop() {
- current = getCurrentForm();
- if(current instanceof Dialog) {
- ((Dialog)current).dispose();
- current = getCurrentForm();
- }
- }
- public void destroy() {
- }
- }
- /******************************* COMBOBOX *******************************************/
- /*
- Form hi = new Form("ComboBox", new BoxLayout(BoxLayout.Y_AXIS));
- ComboBox combo = new ComboBox();
- combo.addItem("Ali");
- combo.addItem("Mohamed");
- combo.addItem("Sarrah");
- hi.add(combo);
- hi.show();
- */
Add Comment
Please, Sign In to add comment