Skip to content
CrossFly is 100% open sourceFollow us on GitHub
CrossFlyCrossFly
Get started

This page was machine-translated from Portuguese and may contain errors. The Portuguese version is canonical.

Anatomy of a project

Understand what generated the “skeleton” before you touch it.

The Gradle modules

:core     → código compartilhado: suas Windows, componentes, lógica, dados
:lwjgl3   → launcher desktop
:android  → launcher Android
:ios      → launcher iOS (RoboVM)
:web      → launcher Web (TeaVM)

You program almost always in core. Each launcher only does the OS bootstrap — it instantiates the Main and configures the window (see platforms).

How the MainWindow is resolved

The Main instantiates the main window by reflection:

  1. it uses the class indicated in cmdline["classname"] (passed by the launcher); or
  2. in its absence, the overridden getMainWindow().

Requirement: the class needs a public no-argument constructor (it’s instantiated by reflection).

Complete example (copy, paste and run)

A minimal, runnable MainWindow class, with the no-args constructor required by reflection:

package com.exemplo;

import dev.crossfly.ui.*;
import dev.crossfly.ui.layout.*;

public class MainWindow extends Window
{
   public MainWindow() { }          // no-args constructor (required for reflection)

   @Override
   public void onShow() throws Exception
   {
      super.onShow();
      setLayout(new VerticalLayout());
      add(LAY_AUTO, new Label("MainWindow resolvida por classname"));
   }
}

Suggested app organization

Inside core, a structure that scales (see app architecture):

app/
 ├─ ui/screens/      → suas Windows (uma tela = uma Window)
 ├─ ui/components/   → componentes reutilizáveis
 ├─ data/            → repositórios (SQLite, rede)
 └─ model/           → objetos de domínio

Assets and fonts

The base fonts (Roboto, FontAwesome, Material) are loaded at bootstrap; your assets (images, data) live in the project’s assets directory and are read by path (see Images).

Next steps

→ Panoramic tour of CrossFly

See also

Was this page helpful?