iifast

Exam - MyApplication.php

Mar 13th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.08 KB | None | 0 0
  1. // Exam - MyApplication.java
  2. // https://imgur.com/a/5IzPju5
  3.  
  4. package com.mycompany.myapp;
  5.  
  6. import com.codename1.components.ImageViewer;
  7. import static com.codename1.ui.CN.*;
  8. import com.codename1.ui.Display;
  9. import com.codename1.ui.Form;
  10. import com.codename1.ui.Dialog;
  11. import com.codename1.ui.Label;
  12. import com.codename1.ui.plaf.UIManager;
  13. import com.codename1.ui.util.Resources;
  14. import com.codename1.io.Log;
  15. import com.codename1.ui.Toolbar;
  16. import java.io.IOException;
  17. import com.codename1.ui.layouts.BoxLayout;
  18. import com.codename1.io.NetworkEvent;
  19. import com.codename1.ui.ComboBox;
  20. import com.codename1.ui.Container;
  21. import com.codename1.ui.EncodedImage;
  22. import com.codename1.ui.Image;
  23. import com.codename1.ui.URLImage;
  24. import com.codename1.ui.events.ActionEvent;
  25. import com.codename1.ui.events.ActionListener;
  26. import com.codename1.ui.layouts.FlowLayout;
  27.  
  28.  
  29. import javafx.scene.image.ImageView;
  30.  
  31. /**
  32.  * This file was generated by <a href="https://www.codenameone.com/">Codename One</a> for the purpose
  33.  * of building native mobile applications using Java.
  34.  */
  35. public class MyApplication {
  36.  
  37.     private Form current;
  38.     private Resources theme;
  39.     EncodedImage enc;
  40.     Image imgs;
  41.     ImageViewer imgview;
  42.     Image imgs1;
  43.     ImageViewer imgview1;
  44.     String url= "http://localhost/codenameoneRessource/img1.png";
  45.         String url1= "http://localhost/codenameoneRessource/img2.png";
  46.  
  47.  
  48.     public void init(Object context) {
  49.         // use two network threads instead of one
  50.         updateNetworkThreadCount(2);
  51.  
  52.         theme = UIManager.initFirstTheme("/theme");
  53.  
  54.         // Enable Toolbar on all Forms by default
  55.         Toolbar.setGlobalToolbar(true);
  56.  
  57.         // Pro only feature
  58.         Log.bindCrashProtection(true);
  59.  
  60.         addNetworkErrorListener(err -> {
  61.             // prevent the event from propagating
  62.             err.consume();
  63.             if(err.getError() != null) {
  64.                 Log.e(err.getError());
  65.             }
  66.             Log.sendLogAsync();
  67.             Dialog.show("Connection Error", "There was a networking error in the connection to " + err.getConnectionRequest().getUrl(), "OK", null);
  68.         });        
  69.     }
  70.    
  71.     public void start() {
  72.         if(current != null){
  73.             current.show();
  74.             return;
  75.         }
  76.         try {
  77.             enc=EncodedImage.create("/logo.png");
  78.         } catch (IOException ex) {
  79.            // Logger.getLogger(MyApplication.class.getName()).log(Level.SEVERE, null, ex);
  80.         }
  81.        
  82.        
  83.         imgs = URLImage.createToStorage(enc, url, url);
  84.         imgview =new ImageViewer(imgs);
  85.         imgs1 = URLImage.createToStorage(enc, url1, url1);
  86.         imgview1 =new ImageViewer(imgs1);
  87.         Label l=new Label();
  88.         l.setText("details1");
  89.         l.addPointerPressedListener(new ActionListener() {
  90.             @Override
  91.             public void actionPerformed(ActionEvent evt) {
  92.                
  93.                
  94.                
  95.                
  96.             }
  97.         });
  98.         Label l1=new Label();
  99.         l1.setText("fggg");
  100.         Form home = new Form("Hi World",new FlowLayout(CENTER,CENTER));
  101.  
  102.                 Form home1 = new Form("Hi World",BoxLayout.y());
  103.                  Toolbar tb = home1.getToolbar();
  104.  
  105.         try {
  106.             tb.addCommandToRightBar("",Image.createImage("/stat.png").scaled(30, 30), new ActionListener(){
  107.                 @Override
  108.                 public void actionPerformed(ActionEvent evt) {
  109.                    home.show();
  110.                    
  111.                 }
  112.             });
  113.         } catch (IOException ex) {
  114.         }
  115.                
  116.         Container ct = new Container(BoxLayout.y());
  117.                 Container cc = new Container(BoxLayout.x());
  118.                 Container cc1 = new Container(BoxLayout.x());
  119.                 cc.add(imgview);
  120.  
  121.                 cc.add(l);
  122.                 cc1.add(imgview1);
  123.                 cc1.add(l1);
  124.                
  125.         ImageViewer imgv = new ImageViewer();
  126.         try {
  127.             imgv =new ImageViewer(Image.createImage("/logo.png"));
  128.                    
  129.                     } catch (IOException ex) {
  130.             ex.printStackTrace();
  131.         }
  132.        ComboBox cb = new ComboBox("Wattaneya","Tessiaa","Hannibal" );
  133.         home1.add(cc);
  134.         home1.add(cc1);
  135.         cb.addActionListener(new ActionListener() {
  136.             @Override
  137.             public void actionPerformed(ActionEvent evt) {
  138.                 if(cb.getSelectedIndex()==0)
  139.                 {
  140.                     home1.show();
  141.                 }
  142.                
  143.             }
  144.         });
  145.                
  146.        
  147.         // this project is not done/completed yet ! the getDetails.php is not connected yet !
  148.        
  149.        
  150.         ct.add(imgv);
  151.         ct.add(cb);
  152.         home.add(ct);
  153.         home.show();
  154.    
  155.     }
  156.  
  157.     public void stop() {
  158.         current = getCurrentForm();
  159.         if(current instanceof Dialog) {
  160.             ((Dialog)current).dispose();
  161.             current = getCurrentForm();
  162.         }
  163.     }
  164.    
  165.     public void destroy() {
  166.     }
  167.  
  168. }
Add Comment
Please, Sign In to add comment