Logros
 Debemos  ser capaces de identificar los
 objetos principales de la GUI, sus
 métodos comunes y su utilización; así
 mismo, construir interfaces con formato.
Objetos
 Objeto       Nombre            Tipo       Estándar

          Etiqueta         JLabel        lblEtiqueta

          Caja de texto    JTextField    txtCajaTexto

          Botón            JButton       btnBoton

          Combo            JComboBox     cboCombo

          Área de texto    JTextArea     txtArea

          Barra de
                           JScrollPane   scpBarra
          Desplazamiento
Sintaxis
//Declaración de variables globales
JLabel lblTitulo;
 Tipo     Nombre




//Declaración de variables globales
JButton btnAceptar, btnCancelar;
   Tipo       Nombre    Nombre
Sintaxis
//Crea la interfaz gráfica de usuario
public void init(){

     getContentPane().setLayout(null);

     lblEtiqueta = new JLabel(“Etiqueta”);
     lblEtiqueta.setBounds(x,y,ancho,alto);
     getContentPane().add(lblEtiqueta);

}
Métodos
   Letra

    setFont(new Font(“fuente”, formato, tamaño));
    •   fuente: monospaced, arial, verdana, algerian, etc.
    •   formato:    Font.Plain    (Plano)
                    Font.Bold     (Negrita)
                    Font.Italic   (Cursiva)
        • tamaño: entero positivo

lblEtiqueta.setFont(new Font(“monospaced”,Font.Bold, 9));
Métodos
 Color   de letra

 setForeground(Color.color);

 •   color: RED, GREEN, WHITE, MAGENTA, etc.

 setForeground(new Color(R,G,B));

 •   RGB: R (rojo), G (verde), B (azul). 0 – 255

     btnBoton.setForeground(Color.GREEN);
Métodos
 Color   de fondo

 setBackground(Color.color);

  color:   BLUE, GREEN, WHITE, CYAN, etc.

 setBackground(new Color(R,G,B));

  RGB:   R (rojo), G (verde), B (azul). 0 – 255

 txtArea.setBackground(new Color(0,0,255));
Métodos
 Etiquetas
  setOpaque(boolean);
    Valores:   true, false
 lblEtiqueta.setOpaque(true);

  Alineación
    JLabel.LEFTA la izquierda              Etiqueta
    JLabel.CENTER     Al centro             Etiqueta
    JLabel.RIGHT      A la derecha             Etiqueta

   lblEtiqueta = new JLabel(“Ejemplo”, JLabel.CENTER);
Métodos
 Combos
  addItem(“Item      01”);
    Agrega    items al objeto ComboBox
 cboCombo.addItem(“Lista”);

 Botones
  addActionListener(this);
    El   objeto podrá ser “escuchado”
 btnBoton.addActionListener(this);
Ejemplos
Clase10

Más contenido relacionado

PPT
Suitcases ANT1 February 2014
PDF
PPT
Briefing & debriefing skills pwc
PPTX
Propeller Diameter & Pitch - Choosing the right prop for your boat
DOC
Curriculum vitae
PDF
Dajung Lee Portfolio
PPT
Helicopter rescues presentation
Suitcases ANT1 February 2014
Briefing & debriefing skills pwc
Propeller Diameter & Pitch - Choosing the right prop for your boat
Curriculum vitae
Dajung Lee Portfolio
Helicopter rescues presentation

Destacado (9)

PPT
Briefing & debriefing skills
PPTX
Sailing Aerodynamic theory
PPT
Teaching Stand up PWC (jet skiing) from a Superyacht
PPTX
Safeguarding Children & Vunerable Adults
PPT
PPT
Briefing & debriefing skills
PPTX
Propeller Ventilation & Cavitation - the basics
PPT
Buoyage & chart symbols
PPT
Briefing & debriefing skills
Sailing Aerodynamic theory
Teaching Stand up PWC (jet skiing) from a Superyacht
Safeguarding Children & Vunerable Adults
Briefing & debriefing skills
Propeller Ventilation & Cavitation - the basics
Buoyage & chart symbols
Publicidad

Clase10

  • 1. Logros  Debemos ser capaces de identificar los objetos principales de la GUI, sus métodos comunes y su utilización; así mismo, construir interfaces con formato.
  • 2. Objetos Objeto Nombre Tipo Estándar Etiqueta JLabel lblEtiqueta Caja de texto JTextField txtCajaTexto Botón JButton btnBoton Combo JComboBox cboCombo Área de texto JTextArea txtArea Barra de JScrollPane scpBarra Desplazamiento
  • 3. Sintaxis //Declaración de variables globales JLabel lblTitulo; Tipo Nombre //Declaración de variables globales JButton btnAceptar, btnCancelar; Tipo Nombre Nombre
  • 4. Sintaxis //Crea la interfaz gráfica de usuario public void init(){ getContentPane().setLayout(null); lblEtiqueta = new JLabel(“Etiqueta”); lblEtiqueta.setBounds(x,y,ancho,alto); getContentPane().add(lblEtiqueta); }
  • 5. Métodos  Letra setFont(new Font(“fuente”, formato, tamaño)); • fuente: monospaced, arial, verdana, algerian, etc. • formato: Font.Plain (Plano) Font.Bold (Negrita) Font.Italic (Cursiva) • tamaño: entero positivo lblEtiqueta.setFont(new Font(“monospaced”,Font.Bold, 9));
  • 6. Métodos  Color de letra setForeground(Color.color); • color: RED, GREEN, WHITE, MAGENTA, etc. setForeground(new Color(R,G,B)); • RGB: R (rojo), G (verde), B (azul). 0 – 255 btnBoton.setForeground(Color.GREEN);
  • 7. Métodos  Color de fondo setBackground(Color.color);  color: BLUE, GREEN, WHITE, CYAN, etc. setBackground(new Color(R,G,B));  RGB: R (rojo), G (verde), B (azul). 0 – 255 txtArea.setBackground(new Color(0,0,255));
  • 8. Métodos  Etiquetas  setOpaque(boolean);  Valores: true, false lblEtiqueta.setOpaque(true);  Alineación  JLabel.LEFTA la izquierda Etiqueta  JLabel.CENTER Al centro Etiqueta  JLabel.RIGHT A la derecha Etiqueta lblEtiqueta = new JLabel(“Ejemplo”, JLabel.CENTER);
  • 9. Métodos  Combos  addItem(“Item 01”);  Agrega items al objeto ComboBox cboCombo.addItem(“Lista”);  Botones  addActionListener(this);  El objeto podrá ser “escuchado” btnBoton.addActionListener(this);