Código:
import java.awt.*;
import javax.swing.*;
public class AWTUserWriting {
public static void main(String args[]){
Frame frame = new Frame();
}
}
class Frame extends JFrame{
public Frame(){
setTitle("Hola Usuario");
setSize(300, 400);
setResizable(true);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
VentanaTexto text = new VentanaTexto();
add(text);
}
}
class VentanaTexto extends JPanel{
public void paintComponent(Graphics g){
super.paintComponent(g);
JTextField texto = new JTextField(20);
texto.setLocation(0,500);
add(texto);
}
}