I am quite new to Java and learning as a student. I hope you can understand me.
As you can see from the code below, I've only coded the frame and the label. The user should be able to write some song recommendations. There should be at least a few text fields created by an array. When the user makes changes, the new text should be displayed using JOptionPane.WARNING_MESSAGE.
I need some guidance on how I can create an array of JTextField and retrieve the text from an array of String. In addition, how can I use JOptionPane to display all of the text?
Thank you.
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
class TextFrame extends JFrame
{
private final JLabel cLabel;
public TextFrame()
{
super("Hello there!");
setLayout(new FlowLayout());
cLabel = new JLabel("Please write some song recommendations.");
cLabel.setToolTipText("Write below.");
add(cLabel);
}
}
public class TestFrame
{
public static void main (String [] args)
{
TextFrame frame = new TextFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 400);
frame.setVisible(true);
}
}