Ejemplo Flow

import java.awt.*; public class EjemploFlow//Juan Ramos Mendez { //Atributos Frame f; Button boton1, boton2, boton3, boton4, boton5; Label etiqueta1, etiqueta2; //Constructores public EjemploFlow() { f = new Frame(" Ejemplo con FlowLayout "); boton1 = new Button("Botoncito 1"); boton2 = new Button("Botoncito 2"); boton3 = new Button("Botoncito 3"); boton4 = new Button("Botoncito 4"); boton5 = new Button("Botoncito 5"); etiqueta1 = new Label(); etiqueta1.setText("I love You"); //modificar texto etiqueta2=new Label("Hola esto es una etiqueta"); }//Constructor //Metodos public void lanzaFrame() { f.setSize(800, 300); f.setBackground(Color.black); //Fondo de ventana principal boton1.setBackground(Color.RED); //color al fondo del boton boton2.setBackground(Color.BLUE); boton2.setForeground(Color.YELLOW);//color a la letra del boton //acomodora los componentes de izq a derecha //f.setLayout(new FlowLayout(FlowLayout.LEFT) ); //Admin de distribucion f.setLayout(new FlowLayout() ); // DEFAULT etiqueta1.setBackground(Color.GREEN); etiqueta1.setForeground(Color.WHITE); f.add(boton1); f.add(boton2); f.add(boton3); f.add(boton4); f.add(boton5); f.add(etiqueta1); f.add(etiqueta2); f.setVisible(true);//Para que se vea } public static void main(String[] args) { EjemploFlow ventana = new EjemploFlow(); ventana.lanzaFrame(); }//Main }
Mi primer Flow

1 Response

It could be a little bit better if you use listeners, and try with swing, thank for sharing your code.

Write a comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.