I'm trying to write a GUI that has 2 JPanels, the left panel with an image and JLabel below it, and the right one with a scrollable JTextArea. For whatever reason the JTextArea isn't showing up.
import javax.swing.*; import java.awt.*; public class TextAreaDemo extends JFrame { private JPanel p1, p2; private ImageIcon javaIcon; private JLabel jlblIcon; private JTextArea jtxtDetails; private JScrollPane scrollPane; public TextAreaDemo() { p1 = new JPanel(); p1.setLayout(new GridLayout(2, 1)); p1.add(new JLabel(javaIcon = new ImageIcon("image\\java.jpg"))); p1.add(jlblIcon = new JLabel("An Icon")); jlblIcon.setFont(new Font("Helvetica", Font.BOLD, 20)); add(p1, BorderLayout.WEST); p2 = new JPanel(); p2.add(jtxtDetails = new JTextArea("Java uses the javax.swing.ImageIcon class to represent an icon. An icon is a fixed- size picture; typically it is small and used to decorate.", 100, 100)); jtxtDetails.setLineWrap(true); jtxtDetails.setWrapStyleWord(true); scrollPane = new JScrollPane(jtxtDetails); add(p2, BorderLayout.EAST); } public static void main(String[] args) { TextAreaDemo frame = new TextAreaDemo(); frame.setTitle("TextAreaDemo"); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setVisible(true); } }