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
Michael Dunn - 26 Feb 2007 02:44 GMT
> 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
[quoted text clipped - 5 lines]
> is the contentPane the main area of the window ?
> Tony
try giving the textArea some size
JTextArea itemArea = new JTextArea(10,10);
now add it to a scrollPane
contentPane.add(new JScrollPane(itemArea));
gethostbyname@gmail.com - 26 Feb 2007 02:56 GMT
> 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
[quoted text clipped - 5 lines]
> 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);
}
public static void main(String[] args) {
Main application = new Main();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
-------------------------------------------------------------
gethostbyname
gethostbyname@gmail.com - 26 Feb 2007 03:26 GMT
On 25 fev, 23:56, "gethostbyn...@gmail.com" <gethostbyn...@gmail.com>
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
[quoted text clipped - 28 lines]
> textArea = new JTextArea();
> getContentPane().add(textArea);
Forgive me. Put
setVisible(true);
after the
getContentPane().add(textArea);
Maybe, this is your source code problem too.
> }
>
[quoted text clipped - 8 lines]
>
> gethostbyname
gethostbyname
TonyB - 26 Feb 2007 10:07 GMT
> On 25 fev, 23:56, "gethostbyn...@gmail.com" <gethostbyn...@gmail.com>
> wrote:
[quoted text clipped - 40 lines]
>>
>> gethostbyname
Hi
Thanks for the help.That item working now. Onto next problem
Tony
gethostbyname@gmail.com - 26 Feb 2007 03:24 GMT
> 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
[quoted text clipped - 5 lines]
> is the contentPane the main area of the window ?
> Tony
Just a question:
Did you add other components to contentPane Container?
gethostbyname