Re: Creating JTextArea on main window of app ?



On 25 fev, 23:56, "gethostbyn...@xxxxxxxxx" <gethostbyn...@xxxxxxxxx>
wrote:
On 25 fev, 20:52, "TonyB" <t...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

I'm trying out a simple gui. I'm trying to create an text area to allow me
to display some text from inside the app if a menu item is clicked. I think
JTextArea will do the job, but I'm having problems making it appear.
The code to add to my container is
Container contentPane = frame.getContentPane();
JTextArea itemArea = new JTextArea();
contentPane.add(itemArea);
is the contentPane the main area of the window ?
Tony

Post the complete source code to I understand what you are doing with
frame reference.

Look a simple working source code:

-------------------------------------------------------------
package javaapplication3;

import javax.swing.JFrame;
import javax.swing.JTextArea;

public class Main extends JFrame {
private JTextArea textArea;

public Main() {
super("PH");

setSize(500,500);
setVisible(true);

textArea = new JTextArea();
getContentPane().add(textArea);


Forgive me. Put

setVisible(true);

after the

getContentPane().add(textArea);

Maybe, this is your source code problem too.


}

public static void main(String[] args) {
Main application = new Main();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

}

-------------------------------------------------------------

gethostbyname


gethostbyname

.



Relevant Pages

  • Re: Creating JTextArea on main window of app ?
    ... JTextArea will do the job, but I'm having problems making it appear. ... Container contentPane = frame.getContentPane; ... Look a simple working source code: ... private JTextArea textArea; ...
    (comp.lang.java.gui)
  • Re: Creating JTextArea on main window of app ?
    ... JTextArea will do the job, but I'm having problems making it appear. ... Container contentPane = frame.getContentPane; ... JTextArea itemArea = new JTextArea; ...
    (comp.lang.java.gui)