Pular para o conteúdo
CrossFly é 100% open sourceSiga no GitHub
CrossFlyCrossFly
Começar
Exemplos

Trinta e oito telas que você roda aqui mesmo

Quatro aplicativos completos e trinta e quatro receitas, cada um rodando no seu navegador a partir do mesmo Java que vai para Android, iOS, desktop (Windows, macOS e Linux) e web. Leia o código ao lado, copie e siga.

4
aplicativos de exemplo
34
receitas
4
plataformas, um código

Rodando aqui

Compilado para JavaScript pelo TeaVM — é o mesmo código, não um vídeo dele.

WindowGridLayoutSkinSqliteDbTeaVM
Rodando aquiCrossFly 0.1.32
Iniciando o aplicativo…

Compilado para JavaScript pelo TeaVM — é o mesmo código, não um vídeo dele.

Assuntos
Receitas93 linhas
Layouts

Any Component becomes a container with setLayout. The same three labels, three ways.

Layout
Receitas65 linhas
Theme tokens

Flip the switch. The token line follows the theme; the hardcoded one does not, and turns unreadable — no rebuild involved.

Tema
Receitas76 linhas
Switching skins

Shape, radius, padding and typeface all come from the skin. Nothing below knows which one is in force.

Tema
Receitas71 linhas
Bottom sheet with a fixed footer

BottomSheet already gives you the header, the grabber, the close button and a footer that floats over the scroll. You only fill body().

NavegaçãoSobreposições
Receitas113 linhas
Listing: cards or table

A card answers "what is this one?"; a row answers "how do these compare?". Which one the reader needs changes during the day, so Listing lets them switch.

Listas
Receitas81 linhas
Choosing from a list

ListViewWindow does single and multi selection, with the title, the confirm and the tap-to-choose already wired.

ListasEntrada
Receitas123 linhas
Picking a date range

DatePicker answers "which day". This answers "between which two", which has its own rules — and its own ways of being wrong.

Entrada
Receitas65 linhas
Reordering a list

The first row has no up arrow and the last has no down arrow — hidden, not removed, so the column does not jitter as rows move.

Listas
Receitas77 linhas
Making a screen testable

Tag anything a test must reach. Text breaks on rewording, class breaks on a second instance, index breaks on insertion — a tag breaks only when someone removes it.

Testes
Receitas84 linhas
A form that fights back

setMode does most of the work: it picks the keyboard, the mask and the validation together. A regex on the way out only tells the user they already got it wrong.

FormuláriosEntrada
Receitas97 linhas
Telling the user something

Interrupt in proportion to what you need back. A confirmation on something reversible teaches people to dismiss confirmations — including the one that mattered.

Avisos
Receitas65 linhas
Bottom nav that becomes a rail

One flag — tabsAtBottom — and the strip is a bottom bar on a phone and a rail on a tablet. Resize the window to see it happen.

NavegaçãoLayout
Receitas131 linhas
Waiting

Known length gets a bar. Unknown gets a spinner. A finished measurement — a share, a score — gets a ring, and that one is not waiting at all.

Avisos
Receitas80 linhas
Cards that reflow

Tell CardGrid the width a card wants, not how many columns to use. Resize the window — the reflow is the framework's, not yours.

Layout
Receitas97 linhas
A header that collapses

header() scrolls away, pinned() never does. Put the identity in the first and the control the reader needs at row 200 in the second.

LayoutListas
Receitas102 linhas
Charts

autoThemeColors themes the axes, grid and background — but NOT the series. A series left at colour 0 falls back to a library grey, and becomes the one thing on screen ignoring your brand.

Gráficos
Receitas110 linhas
A list too big to build

createView is rare, bindView is constant. Anything slow in bindView — a query, a request, an allocation — is felt directly as stutter while scrolling.

ListasDesempenho
Receitas154 linhas
Storing something

Add a few notes and reopen the recipe — they are still there. The same code runs on desktop, Android, iOS and the web.

Dados
Receitas188 linhas
Capturing a signature

White pad, not the theme surface: the image is captured to be printed. Under dark mode a themed pad captures white ink on navy, which is unusable downstream.

EntradaDesenho
Receitas84 linhas
Pickers

show(answer -> …) on all of them, and answer is null when the user backed out. The ones needing hardware live in R21, and the system file picker in R31 — those can be refused.

Entrada
Receitas244 linhas
Camera, barcode and GPS

Ask whether the device HAS it before offering it. PlatformUtils.isSupported answers per capability, at runtime — never a check on which platform this is.

Dispositivo
Receitas162 linhas
Animation

Styles.animationDuration is the house value — match it, so the app moves at one speed. Anything the user waits through twice was too long the first time.

Animação
Receitas119 linhas
Painting your own

A component is a rectangle that can draw. width/height are yours, getAutoHeight says how much room you want, and onPaint puts something in it.

Desenho
Receitas90 linhas
Floating action button

It floats over the content, so leave room at the bottom of the list — bottomInset is what stops it covering the last row nobody can then scroll past.

Navegação
Receitas124 linhas
A map with pins

OSM needs no API key, so a map works the moment you write it. Opens in a window of its own — a native view inside a scrolling page floats over everything around it.

Dispositivo
Receitas97 linhas
Images

Decode once, keep the Image, reuse it. Loading inside onPaint or inside a list's bind step is what makes scrolling stutter where the pictures are.

Imagens
Receitas110 linhas
Keyboard and focus

Tab follows the order you ADDED the fields, not where they ended up on screen. Build in reading order and the tab order is correct without being designed.

Entrada
Receitas161 linhas
Writing your own component

Search dev/crossfly/ui first — most of what you are about to write is already there. When it genuinely is not, this is the shape.

Componentes próprios
Receitas129 linhas
Brand and dark mode

One seed generates the whole palette, for both themes. Nothing below names a colour, which is why the switch needs no rebuild.

Tema
Receitas160 linhas
Empty, loading and broken

Three of these are usually left to render as blank space. Blank space reads as a bug, never as an answer.

AvisosListas
Receitas249 linhas
Files, sharing and printing

Ask the capability, not the platform. Phones, Windows 10+ and the Mac have the picker and the share sheet; Linux has no share sheet; a browser has the picker always and the sheet only sometimes. Printing takes a PDF, and every platform's own dialog does the rest.

Dispositivo
Receitas284 linhas
Video playback

A native surface over the canvas, like the map. Ask the capability first: all five platforms have it now, and one that does not says so instead of showing black.

Dispositivomedia
Receitas120 linhas
Embedded web page

A native browser over the canvas, at this component's rect. On the web it is an <iframe>, and script only reaches a page from your own origin.

Dispositivomedia
Receitas402 linhas
Reading an odometer (OCR)

Show a strip, read the strip. The viewfinder is only as tall as the digits, and the recognizer gets that band and nothing else — so the speedometer and the trip meter around it never compete with the number.

Dispositivo
Aplicativos2025 linhas
Depot — offline-first CRUD

One shell, three listings over a local database, a detail and a long form. A thing you navigate away from is a Window; a thing you switch between is not.

DadosListasFormulários
Aplicativos495 linhas
Pulse — a dashboard

One screen, read rather than operated: a headline number, a KPI grid and charts, all re-fed by the single control that changes the period.

Gráficos
Aplicativos445 linhas
Fieldwork — capturing from the device

Every capture has three states, not two: empty, captured, and unavailable on this device — and the third is the one a phone-only developer never sees.

Dispositivo
Aplicativos1017 linhas
Order entry — a wizard

A linear flow that validates per step, lets the reader walk back freely, and ends on a review built from the same data the steps collected.

FormuláriosNavegação
Para uma IA

Versões desta página legíveis por máquina, para um modelo ler a prateleira em vez de adivinhar a API.

Todos os exemplos, em JSONllms.txt

Comece por um destes

Escolha a forma mais próxima do que você está construindo, copie e mude as partes que são suas.

Ler a documentação