1. Home
  2. /
  3. Codename-one
  4. /
  5. Codename One Stopwatch App

Codename One Stopwatch App - Codename-one Typing CST Test

Loading…

Codename One Stopwatch App — Codename-one Code

Implements a simple stopwatch with start, stop, and reset using Codename One Timer.

import com.codename1.ui.*;
import com.codename1.ui.layouts.FlowLayout;

public class StopwatchApp extends Form {
	private int seconds = 0;
	private Label timeLabel;
	private com.codename1.ui.util.UITimer timer;

	public StopwatchApp() {
		setTitle("Stopwatch");
		setLayout(new FlowLayout(Component.CENTER));

		timeLabel = new Label("00:00");
		Button start = new Button("Start");
		Button stop = new Button("Stop");
		Button reset = new Button("Reset");

		timer = new com.codename1.ui.util.UITimer(() -> {
		seconds++;
		timeLabel.setText(String.format("%02d:%02d", seconds / 60, seconds % 60));
		revalidate();
		});

		start.addActionListener(e -> timer.schedule(1000, true, this));
		stop.addActionListener(e -> timer.cancel());
		reset.addActionListener(e -> { seconds = 0; timeLabel.setText("00:00"); });

		addAll(timeLabel, start, stop, reset);
	}
}

Codename-one Language Guide

Codename One is a cross-platform mobile development framework that allows developers to build native mobile apps for iOS, Android, Windows, macOS, and web using Java or Kotlin. It provides a single codebase with a rich set of UI components and native device access.

Primary Use Cases

  • ▸Cross-platform mobile apps for iOS, Android, Windows, macOS
  • ▸Enterprise mobile solutions and internal tools
  • ▸Consumer apps targeting multiple devices
  • ▸Rapid prototyping with Java/Kotlin
  • ▸Apps requiring native device features (camera, sensors, storage)

Notable Features

  • ▸Single Java/Kotlin codebase for all platforms
  • ▸Native compilation for iOS, Android, and desktop
  • ▸Rich set of UI components with theming support
  • ▸Access to device APIs via lightweight wrappers
  • ▸Cloud build service for automated native compilation

Origin & Creator

Created by Shai Almog and the Codename One team in 2012, Codename One was designed to simplify mobile app development across platforms using Java.

Industrial Note

Best suited for teams with strong Java expertise who want to write once and deploy anywhere without managing multiple platform-specific projects.

More Codename-one Typing Exercises

Codename One Simple Todo AppCodename One Counter AppCodename One Login FormCodename One Notes AppCodename One Image ViewerCodename One Theme SwitcherCodename One Calculator AppCodename One Weather FetcherCodename One QR Scanner

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher