Añadiendo jlabel a un jframe usando componentes
Tengo 2 clases,
Mi clase principal crea un marco y quiero que otra clase le agregue contenido. Un poco de lectura me dijo que debería usar componentes para hacer esto, sin embargo, cuando ejecuto mi código, el marco está vacío.
public static void main(String[] args)
{
// create frame
JFrame frame = new JFrame();
final int FRAME_WIDTH = 800;
final int FRAME_HEIGHT = 600;
// set frame attributes
frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);
frame.setTitle("My Frame");
frame.setVisible(true);
Component1 Com = new Component1();
Component add = frame.add(Com);
}
Mi clase de componente crea un JLabel
public class Component1 extends JComponent {
public void paintComponent()
{
JLabel label = new JLabel("<html>Some Text</html>");
}
}
No obtengo ningún error de compilación, sin embargo no obtengo ningún texto en mi JFrame.
¿Alguien puede explicar lo que estoy haciendo mal?
Chris