Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //File Name : AddTaskForm.java
- package com.mycompany.myapp.gui;
- import com.codename1.ui.FontImage;
- import com.codename1.ui.Form;
- import com.mycompany.myapp.entities.Task;
- /**
- *
- *@author
- */
- public class AddTaskForm extends Form {
- public AddTaskForm(Form previous) {
- setTitle(" Add a new task ");
- setLayout(BoxLayout.y());
- //Creer l'interface d'ajout
- TextField tfName = new TextField("","TaskName");
- TextField tfStatus = new TextField("","Status : 0 - 1 ");
- Button btnValider = new Button("Add task" );
- btnValider.addActionListener(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent evt){
- // Verifier les donnees saisies par l'utilisateur
- if( (tfName.getText().length==0)||(tfStatus.getText().length()==0))
- Dialog.show("Alter", "Please fill all the fields" , new Command("OK"));
- else
- {
- try {
- Task t = new Task(Integer.ParseInt(tfStatus.getText()), tfName.getText());
- //invoquer la method ajout
- if (new ServiceTask().addTask(t))
- //verifier son retour
- Dialog.show("Success","Connection accepted" , new Commad("OK"));
- else
- Dialog.show("ERROR","Server error",new Command("OK"));
- } catch(NumberFormatException e) {
- Dialog.show("ERROR","Status must be a number", new Commad("OK") );
- }
- }
- }
- });
- addAll(tfName,tfStatus,btnValider);
- getToolbar().addMaterialCommandToLeftBar("",FontImage.MATERIAL_ARROW_BACK,e->previous.showBack());
- }
- }
Add Comment
Please, Sign In to add comment