JTextArea not appearing?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Williams

    JTextArea not appearing?

    I haven't done any Java programming for a good long bit, so this is probably
    something really silly but anyways, can anyone tell me why my JTextArea is
    not appearing when I run this?

    public class MyApp extends JFrame {
    JTextArea textArea;

    public MyApp() {
    getContentPane( ).setLayout(nul l);

    textArea = new JTextArea();
    textArea.setCol umns(300);
    textArea.setRow s(10);
    textArea.setLoc ation(120, 5);
    textArea.setVis ible(true);

    getContentPane( ).add(textArea) ;

    setDefaultClose Operation(JFram e.EXIT_ON_CLOSE );
    setSize(500, 500);
    setVisible(true );
    }

    public static void main(String args[]) {
    MyApp win = new MyApp();
    }
    }


  • Anthony Borla

    #2
    Re: JTextArea not appearing?


    "Chris Williams" <chris@dwango.c om> wrote in message
    news:bpgf6l$6mp @dispatch.conce ntric.net...
    [color=blue]
    > I haven't done any Java programming for a good long bit,
    > so this is probably something really silly but anyways, can
    > anyone tell me why my JTextArea is not appearing when
    > I run this?
    >
    > public class MyApp extends JFrame {
    > JTextArea textArea;
    >
    > public MyApp() {
    > getContentPane( ).setLayout(nul l);
    >
    > textArea = new JTextArea();
    > textArea.setCol umns(300);
    > textArea.setRow s(10);
    > textArea.setLoc ation(120, 5);
    > textArea.setVis ible(true);
    >
    > getContentPane( ).add(textArea) ;
    >
    > setDefaultClose Operation(JFram e.EXIT_ON_CLOSE );
    > setSize(500, 500);
    > setVisible(true );
    > }
    >
    > public static void main(String args[]) {
    > MyApp win = new MyApp();
    > }
    > }
    >
    >[/color]

    Remove this line:

    getContentPane( ).setLayout(nul l);

    Also, this:

    textArea.setVis ible(true);

    is unnecessary, but benign.

    I hope this helps.

    Anthony Borla


    Comment

    Working...