Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2007

Tip: Looking for answers? Try searching our database.

Creating JTextArea on main window of app ?

Thread view: 
TonyB - 25 Feb 2007 23:52 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
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.