I cannot figure out how to set the location of the text area. Here is my code. Not sure what is not working, obviously JTextArea is not as simple as setting the location like a button.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class BackgroundImageJFrame extends JFrame {
JButton b1;
JLabel l1;
public BackgroundImageJFrame() {
setTitle("Background Color for JFrame");
setSize(1000, 1000);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
/*One way-----------------*/
setLayout(new BorderLayout());
JLabel background = new JLabel(new ImageIcon("background-landing.png"));
add(background);
background.setLayout(new FlowLayout());
l1 = new JLabel("Here is a button");
b1 = new JButton("I am a button");
JTextArea t1 = new JTextArea("enter username", 10, 20);
t1.setLocation(30, 30);
background.add(l1);
background.add(b1);
background.add(t1);
}
public static void main(String args[]) {
new BackgroundImageJFrame();
}
}