Use line 19 before 16 and 17. You are not initializing the theTextArea.
Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
import javax.swing.*;
import java.awt.*;
public class mainForSimpleGUI
{
public static void main(String[] args)
{
SimpleJavaGUI labelFrame = new SimpleJavaGUI();
labelFrame = new SimpleJavaGUI();
labelFrame.setLocationRelativeTo(null);
labelFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
labelFrame.setSize(300, 300);
labelFrame.setVisible(true);
}
}
@SuppressWarnings("serial")
class SimpleJavaGUI extends JFrame
{
public JTextArea theTextArea;
public SimpleJavaGUI()
{
super("mainForSimpleGUI");
setLayout(new FlowLayout() );
theTextArea = new JTextArea(2, 20);
theTextArea.setLocation(15, 30);
theTextArea.setAlignmentX(CENTER_ALIGNMENT);
theTextArea.setAlignmentY(CENTER_ALIGNMENT);
theTextArea.setText(" Follow the white rabbit.");
theTextArea.setToolTipText("This is a text area.");
theTextArea.setEditable(false);
theTextArea.setDisabledTextColor(Color.BLACK);
theTextArea.setLineWrap(true);
theTextArea.setBorder(BorderFactory.createLineBorder(Color.black) );
add(theTextArea);
}
}
I applied this and it is showing me the text area.
Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49