import javax.swing.*; public class JTextAreaExample { public static void main(String[] args) { JFrame f = new JFrame(); JTextArea ta = new JTextArea("Hello World!"); ta.setOpaque(true); // setting the opaque property to true f.add(ta); f.setSize(400, 400); f.setVisible(true); } }
import javax.swing.*; public class JTextAreaExample { public static void main(String[] args) { JFrame f = new JFrame(); JPanel p = new JPanel(); JTextArea ta1 = new JTextArea("This is JTextArea1"); JTextArea ta2 = new JTextArea("This is JTextArea2"); ta1.setOpaque(false); // setting the opaque property to false ta2.setOpaque(false); // setting the opaque property to false p.add(ta1); p.add(ta2); f.add(p); f.setSize(400, 400); f.setVisible(true); } }In both of these examples, the package library used is javax.swing.