CODAPPS. Adding Labels and Buttons to a Form. Clément Levallois

Similar documents
CODAPPS. Adding Labels and Buttons to a Form. Clément Levallois

Creating a Form with two different approaches

CODAPPS. Adding Pictures to a Form. Clément Levallois

CODAPPS. Advanced styling of Components. Clément Levallois

CODAPPS. Designing the layout of the app. Clément Levallois. Version 1.0, last modified

CODAPPS. Making the cookie click. Clément Levallois. Version 1.0, last modified

CODAPPS. Testing and releasing your app for iphones. Clément Levallois

Conditional statements, loops and data structures

Testing and releasing your app for Android

IoT for entrepreneurs. faq. Clément Levallois

CODAPPS. Coding Cheatsheet. Clément Levallois. Version 1.0, last modified

Basics. Mouse The mouse normally looks like a little arrow, but it can change depending on what you are doing

1. Open NetBeans and click File... New Project... Select Java as the Category and Java Desktop Application as the Project Click Next.

MAKING TABLES WITH WORD BASIC INSTRUCTIONS. Setting the Page Orientation. Inserting the Basic Table. Daily Schedule

The MathType Window. The picture below shows MathType with all parts of its toolbar visible: Small bar. Tabs. Ruler. Selection.

Interactive Tourist Map

How to make a power point presentation. Dr. Mohamed F. Foda

August 12. Tips for Gmail. Tips to save time and increase your productivity. Gmail Training

The Newsletter will contain a Title for the newsletter, a regular border, columns, Page numbers, Header and Footer and two images.

New PowerPoint Document

SCRATCH. Introduction to creative computing with Scratch 2.0

SmartBoard & Smart Notebook Software

IN THIS CLASS WE ARE GOING TO LEARN THE BASIC FEATURES OF WINDOWS 8.1 WITH HANDS ON TRAINING THE CLASS WILL RUN ON THE SPEED OF THE AVERAGE STUDENT

Create a unit using United Streaming and PowerPoint. Materials: Microsoft PowerPoint, Internet access, United Streaming account

PowerPoint 2010 Introduction

Working with Pages... 9 Edit a Page... 9 Add a Page... 9 Delete a Page Approve a Page... 10

By: Computer Education. Introduction Level One

Assignment 1. Application Development

In this lesson you are going to create a drawing program similar to Windows Paint. 1. Start with a new project and remove the default cat sprite.

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

WINDOWS 8.X SIG SEPTEMBER 22, 2014

Chapter 4 Devices. About devices. Planning your devices

Math 395 Homework #1 Due Wednesday, April 12

Lecture (06) Java Forms

The complete course: Twitter for mobile apps. Twitter A2Z Part 1. Part 1 setup twitter account and page. April 2014 bonus

CS193P: HelloPoly Walkthrough

HYPERSTUDIO TOOLS. THE GRAPHIC TOOL Use this tool to select graphics to edit. SPRAY PAINT CAN Scatter lots of tiny dots with this tool.

Lesson 2. Using the Macro Recorder

Kidspiration Quick Start Tutorial

MAC BASICS. 125 S. Prospect Avenue, Elmhurst, IL (630) elmhurstpubliclibrary.org. Start Using Computers, Tablets, and Internet

FrontPage Help Center. Topic: FrontPage Basics

Microsoft Expression Web Quickstart Guide

Windows File Management

Jumping into GEMstudio. User guide 2013

Robolab. Table of Contents. St. Mary s School, Panama. Robotics. Ch. 5: Robolab, by: Ernesto E. Angulo J.

Instructions for the Jeopardy through PowerPoint Template

Lesson 4 - Basic Text Formatting

Chapter 5 Devices. About devices. Planning your devices

Graphing on Excel. Open Excel (2013). The first screen you will see looks like this (it varies slightly, depending on the version):

Module Five: Customizing Excel

Here are the topics covered in this tutorial:

Valuable points from Lesson 6 Adobe Flash CS5 Professional Classroom in a Book

Overview In this lab you will Explore some of the features of the new Windows 8 Interface.

Lecture 6. Design (3) CENG 412-Human Factors in Engineering May

About Customizing a SharePoint Server 2007 Site

Using the City of Stamford / Stamford Public Schools. Web System

Activity Robot Behaviors and Writing Pseudocode

Inear Display AMALGAME

Let s Make a Front Panel using FrontCAD

BEGINNER PROGRAMMING LESSON

Flowcharts for Picaxe BASIC

Introduction to Microsoft Windows

DVDFab ifonerestore User Manual DVDFab ifonerestore User Manual

Basic Concepts 1. For this workshop, select Template

Designer Reference 1

TalkToMe: A beginner App Inventor app

[Type text] Windows Quick Start Guide Version 3.5

WHAT YOU WILL WANT TO KNOW ABOUT NOTIFICATIONS AND ACTIONS

GRAPHICS & INTERACTIVE PROGRAMMING. Lecture 1 Introduction to Processing

SMARTBoard. Basic Directions. Part 1 Pages 1-12

Section 1. System Technologies and Implications. Modules. Introduction to computers. File management. ICT in perspective. Extended software concepts

Grade: 7 Lesson name: Creating a School News Letter Microsoft Word 2007

1. Move your mouse to the location you wish text to appear in the document. 2. Click the mouse. The insertion point appears.

DS3-UG02 Basic Setup and Configuration

What Is a Program? Pre-Quiz

Introduction to the Weebly Toolkit for Building Websites

UpContent for Hootsuite Content Source SET UP GUIDE AND USER MANUAL

Prototyping. Readings: Dix et al: Chapter 5.8 Marc Rettig: Prototyping for tiny fingers, Communications of the ACM, April 1994.

File Storage & Windows Tips

Getting Started With Windows 7

Computer Basics. Need more help? What s in this guide? Types of computers and basic parts. Why learn to use a computer?

AT&T Website Solutions SM FAQ for

Getting to Integris/SIS

Powerful presentation solutions from Microsoft Improve the way you create, present, and collaborate on presentations. Use enhanced multimedia

Photoshop tutorial: Final Product in Photoshop:

Open your blogger dashboard and click the design tab and then click template designer

TEACHER QUICK GUIDE FOR EDLINE

Measuring in Pixels with Scratch

Inspiration Quick Start Tutorial

InDesign Basics. Adobe

Branching Error (a.k.a. the VM Program Instruction Break Error) By Sanjay and Arvind Seshan DEBUGGING LESSON

Understanding the Interface

Adobe Flash CS3 Reference Flash CS3 Application Window

Understanding Word Processing

In this lesson, you ll learn how to:

Creating and Using an Account

SciGraphica. Tutorial Manual - Tutorials 1and 2 Version 0.8.0

The BLR Employee Handbook Builder allows you to create your own customized employee handbook. Benefits include:

Tips for Effective Online Office Hours

-Using Excel- *The columns are marked by letters, the rows by numbers. For example, A1 designates row A, column 1.

Transcription:

CODAPPS Adding Labels and Buttons to a Form Clément Levallois 2018-01-12

Table of Contents 1. Some preparations........................................................................ 1 2. Adding a Label to your Form............................................................... 5 a. A piece of text is called a Label. Why? 5 b. Concrete steps to add a Label to the Form 5 c. Label or Span Label? 9 3. Adding a Button to your Form - and your first Action!....................................... 11 a. Adding the button 11 b. Making the button do something 13 c. Step-by-step creation of an action attached to the button 13 The end................................................................................... 20

last modified: 2018-01-23 1. Some preparations Not sure what a Form is? Have a look at the previous lessons! To start this lesson, we will assume that you already created a Form called "Form1" and that you opened it in the GUI Builder, like this: [pub?w=1440&h=1080] <em>https://docs.google.com/drawings/d/e/2pacx- 1

1vSZrQqUaxVkLbjSyAnY8bu0IFgBrRTvCOZ2i9vhtcA5LaT5ZUXqFhcPFHVc4E9DZRzTVepawvIb338a/ 2

Figure 1. Opening the Form we created to work on it pub?w=1440&h=1080</em> So that you should now have the GUI Builder open to design your Form. Here is a recall of the different panels that compose the GUI Builder: [pub?w=1440&h=1080] <em>https://docs.google.com/drawings/d/e/2pacx- 3

1vTLmA6SJYK28g7ypoFem5WovZ7hX1vUjna9Sh3mkTtRWtTeuquCn50G72S_kt1cDUtaH9u52H1fGln 4

h/pub?w=1440&h=1080</em> Figure 2. Discovering the GUI Builder 2. Adding a Label to your Form a. A piece of text is called a Label. Why? As mentioned in a previous lesson, in coding and software development, things don t have intuitive names: For example, a "screen" is called a Form (we have explained this one before). Another example: every element to be put on the Form is going to be called a "Component", so make sure you memorize this. And a Component that shows some text is going to be called a Label. Not "Text". Why? Simply because calling it "Text" would be misleading. When you show some text on screen there is the text itself, but also its size, color, id, etc.! so "Label" is more accurate: a Label is made of a piece of text and a color, a size, some decorations (maybe bold? italic?), etc. With these explanations and clarifications made, we can now add a Label in our app! b. Concrete steps to add a Label to the Form Start by opening the 'Core Components' menu on the top right: [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 5

6 1vRsMnjK415Ikdk8GMoHX9bayKSgvtT6ZovBv1S3Qs4h_WJXoFoi239WELLcI_TZt2ifIX4wq-BqxDh-

/pub?w=1434&h=791</em> Figure 3. Opening the Core Components menu Then drag and drop a Label onto the Form. Place it where you prefer: [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 7

8 1vR0DDosS7CtbpLEWueQ5DlO1ZukhwnzMYGTPL2Z94jZay1e4kvKGurDZLhMSkiS0caE--

Figure 4. Drag - dropping a Label tc5usmkmnu/pub?w=1434&h=791</em> c. Label or Span Label? You may have noticed that a Component called "Span Label" also exists, right next to Label: [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 9

1vSflXDBf95uRdeSO12WXeyA4G_kUqxzRBZKCcu42iQKLD8PQTPK743niD9gWMJucvGuzu4Yoyy7tZd 10

I/pub?w=1434&h=791</em> Figure 5. A Span Label Span Labels are like regular Labels, but their text can stretch on many lines, not just one. Even if this is a tiny difference, you have cases when one is more practical than the other. 3. Adding a Button to your Form - and your first Action! a. Adding the button Adding a Button is easy: just like we did for Labels, we just need to drag and drop the Button onto the Form: [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 11

1vTA3dVNZGthIBJLSlBe5ETgfVVuXkYecR7TuXz0ZyQpcWLR7KOMF0yRAGALtlLDFCbCwVaTbv2XGIj 12

8/pub?w=1434&h=791</em> Figure 6. Drag - dropping a Button b. Making the button do something Of course the button, alone, is not interesting: it should do something when the user of the app touches it. You can launch the preview of your app (big green arrow in the NetBeans menu): you see in the preview that the button can be pressed, but nothing happens. We need to attach an Action to the button. Actions can be very complex: for example, a gaming app has buttons making characters jump or run. Or a store app has buttons that select products and make payments! All these actions happen through lines of code that need to be written. We are going to create a very simple action to illustrate the principle: pressing the button will change the text of the Label c. Step-by-step creation of an action attached to the button This is not completely stable. If the creation of the action does not work well: Delete your button and create a new one Follow the steps carefully, without taking shortcuts Only if you have tried several times and things still don t work, then you can report an issue here. 1. Make sure you have a Label on the Form - since we want to change its text with the Button! (you should have one as we created one, above in this lesson). 2. Select the button with your mouse and click on the three dots in the properties: [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 13

14 1vTh6txPb0VnbXWTovpmS9ZGFuz6GcS6hgH664-

Iewcz7eyBcNqfkqv15ScTdGCGjBA22Ei0dkYZLbpI/pub?w=1434&h=791</em> Figure 7. Selecting the Button This opens a new window. 3. Give a name to the action and to the button [pub?w=1434&h=791] <em>https://docs.google.com/drawings/d/e/2pacx- 15

16 1vT347e9ts2KIIRkgKW8qbEooFp4IexuSyN-vZFBJYGWXzXKQztCdkEbs-

HrSzdKIwJU9wEmsEsBu9Iy/pub?w=1434&h=791</em> Figure 8. Giving a name to the action and to the button You might have the idea to add a picture to your button, because you see properties named "icon" or "Pick Image". Actually, the best way to add a picture to a button is to use a "Scaled Button", not a Button. We explain how to do in the lesson on "Adding Pictures" in this module. 4. The GUI Builder should have switched automatically back to NetBeans (don t worry the GUI Builder has not been closed) The lines of code for an action have been automatically written in the file of your Form, which is called "Form1.java" if your Form is named Form1. These lines of code should look like: Form1.java //-- DON'T EDIT ABOVE THIS LINE!!! public void onupdatelabeltextcommand(com.codename1.ui.events.actionevent ev, com.codename1.ui.command cmd) { 1 } 2 1 This line is complicated but you can notice that the name of our Action appears in it ("UpdateLabelText"). Notice also the opening curly brace at the end of the line: { 2 This is a closing curly brace. Everything you write between the opening curly brace { and the closing curly brace } will be performed when the user touches the button. So let s write the instruction to change the text of the Label! We are going to write just one line of code between the curly braces: this.gui_label.settext("pressed!"); Here we suppose that the Label that you want impact with your Button is called "Label". Check the name of your Label in the GUI Builder: if it is named Label_1 or Label_2, then the line of code should become: this.gui_label_1.settext("pressed!"); or this.gui_label_2.settext("pressed!"); So that it looks like: 17

Form1.java //-- DON'T EDIT ABOVE THIS LINE!!! public void onupdatelabeltextcommand(com.codename1.ui.events.actionevent ev, com.codename1.ui.command cmd) { this.gui_label.settext("pressed!"); 1 } 1 the line we added between the curly braces. You can now preview your app (big green arrow in NetBeans). Press the button in the preview, the effect should be: [pub?w=1440&h=1080] <em>https://docs.google.com/drawings/d/e/2pacx- 18

1vTGoQNP8cQHsOTNsSFnYNgNyBx6kjzlSnW6xWhXp2ZzcX7BxJ03yiGQejvS3hO2wUwHY6968SUnQ 19

Figure 9. Previewing the button and its action UvV/pub?w=1440&h=1080</em> Not this result? Make sure you save the GUI Builder! (File! Save) Congratulations! You learned how to place a Label on screen, a Button, and how to make the Button perform an action. This is a huge step! In the next lesson of this module, we are going to learn how to insert a picture in the app. The end Questions? Want to open a discussion on this lesson? Visit the forum here (need a free Github account). Find references for this lesson, and other lessons, here. Licence: Creative Commons, Attribution 4.0 International (CC BY 4.0). You are free to: copy and redistribute the material in any medium or format Adapt remix, transform, and build upon the material # for any purpose, even commercially. This course is designed by Clement Levallois. Discover my other courses in data / tech for business: http://www.clementlevallois.net Or get in touch via Twitter: @seinecle 20