Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // DROW
- package com.mycompany.myapp;
- 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;
- 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);
- // Pro only feature
- Log.bindCrashProtection(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 hi = new Form("WEBSITE", BoxLayout.y());
- // Form hi1 = new Form("Hi World", BoxLayout.xCenter()); ????????
- Form hi2 = new Form("WEBSITE", BoxLayout.y());
- Form hi3 = new Form("SETTINGS",BoxLayout.y());
- Form hi4 = new Form("About",BoxLayout.y());
- Toolbar tb = hi.getToolbar();
- Toolbar tb1 = hi2.getToolbar();
- Toolbar tb2 = hi3.getToolbar();
- Toolbar tb3 = hi4.getToolbar();
- /************** Website Toolbar ***********/
- tb.addMaterialCommandToSideMenu("Website", FontImage.MATERIAL_WEB,new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi2.show();
- }
- });
- /*************** Settings Toolbar **********/
- tb.addMaterialCommandToSideMenu("Settings", FontImage.MATERIAL_SETTINGS, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi3.show();
- }
- });
- /*************** About Toolbar **********/
- tb.addMaterialCommandToSideMenu("About", FontImage.MATERIAL_MORE, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi4.show();
- }
- });
- /************ Back WebSite → Home *******************/
- tb1.addCommandToLeftBar("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi.show();
- }
- });
- /************ Back Setting → Home *******************/
- tb2.addCommandToLeftBar("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi.show();
- }
- });
- /************ Back(on the Right) About → Home *******************/
- tb3.addCommandToRightBar("Back",null, new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt) {
- hi.show();
- }
- });
- /**************************************************************************/
- hi.add(new Label("Hi World"));
- hi.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();
- */
Advertisement
Add Comment
Please, Sign In to add comment