![Curso de Java Netbeans Completo☕ [75.- JLabel en un JPanel (Colocar etiquetas en panles)] 1 java 75](https://www.programadornovato.com/wp-content/uploads/2020/06/java-75-480x251.jpg)
Curso de Java Netbeans Completo☕ [75.- JLabel en un JPanel (Colocar etiquetas en panles)]
En este tutorial vamos a aprender a usar JLabel en un JPanel y crear etiquetas, esas mismas las insertaremos en paneles para poder ocultar el panel y la etiqueta.
Java swing: https://es.wikipedia.org/wiki/Swing_(biblioteca_gr%C3%A1fica)
Codigo: https://github.com/programadornovato/java/commit/876e45bf837608550dd65c5c0c259793675191f1
package com.programadornovato.proy1;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.HeadlessException;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
*
* @author eugenio
*/
public class Ventana extends JFrame{
JPanel panel1;
JPanel panel2;
JPanel panel3;
/*
public Ventana() throws HeadlessException {
Dimension d=new Dimension(500, 500);
this.setSize(d);
}
*/
public Ventana(String title) throws HeadlessException, InterruptedException {
super(title);
//Dimension d=new Dimension(500, 500);
//this.setSize(d);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
//this.setLocation(300, 300);
this.setBounds(300, 300, 500, 500);
this.setLocationRelativeTo(null);
iniciarPaneles();
inicaEtiquetas();
}
protected void iniciarPaneles() {
JPanel contenedor=new JPanel();
this.getContentPane().add(contenedor);
contenedor.setBackground(Color.red);
this.panel1=new JPanel();
this.panel2=new JPanel();
this.panel3=new JPanel();
contenedor.add(this.panel1);
contenedor.add(this.panel2);
contenedor.add(this.panel3);
this.panel1.setBackground(new Color(0, 51, 102));
this.panel2.setBackground(new Color(0, 102, 255));
this.panel3.setBackground(new Color(255, 0, 255));
contenedor.setLayout(new BoxLayout(contenedor, BoxLayout.X_AXIS));
//this.panel3.setVisible(false);
}
protected void inicaEtiquetas() {
JLabel e1=new JLabel("<html>Hola Humano soy la etiqueta1</html>");
JLabel e2=new JLabel("<html>Hola Humano soy la etiqueta2</html>");
JLabel e3=new JLabel("<html>Hola Humano soy la etiqueta3</html>");
this.panel1.add(e1);
this.panel2.add(e2);
this.panel3.add(e3);
e1.setForeground(Color.white);
e2.setForeground(Color.white);
e3.setForeground(Color.white);
this.panel1.setLayout(null);
this.panel2.setLayout(null);
this.panel3.setLayout(null);
e1.setBounds(10, 100, 90, 60);
e2.setBounds(10, 100, 90, 60);
e3.setBounds(10, 100, 90, 60);
e1.setText("<html>Hola humano</html>");
this.panel2.setVisible(false);
}
}
🔗 Instalar Netbeans 11 en Ubuntu con Snap [Mas fácil que en windows?]: https://www.youtube.com/watch?v=LllPPV9SMzQ
🔗 Instalar Netbeans 11 en Windows 10: https://www.youtube.com/watch?v=EouitrKS6Cw
🔗 Descargar e Instalar Netbeans 11 en ubuntu 18 04: https://www.youtube.com/watch?v=tWiX3Z5t5kQ
🔗 Netbeans Sublime Theme ?: https://www.youtube.com/watch?v=oAF2Q7mTZZM
🔗 Editar CSS directamenete en Chrome con Netbeans: https://www.youtube.com/watch?v=HlQs0a7R2cY
🔗 Esta lista de reproducción: https://www.youtube.com/playlist?list=PLCTD_CpMeEKTT-qEHGqZH3fkBgXH4GOTF
Codigos en gdrive: https://drive.google.com/file/d/1M6c0VYqrzpq6KwdWkrkw7Aalm8FkdITH/view?usp=sharing
Gracias por apoyar este canal: https://www.patreon.com/programadornovato?fan_landing=true
🔗 Facebook: https://facebook.com/ProgramadorNovatoOficial
🔗 Twitter: https://twitter.com/programadornova
🔗 Linkedin: https://www.linkedin.com/in/programadornovato/
🔗 Instagram: https://www.instagram.com/programadornovato/
Anterior tutorial Siguiente tutorial
Ave que vuela, a la cazuela.