Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: TEXT AREA

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default TEXT AREA

    Please i am beginner totaly in programming, and i am starting with java... Please my problem is that i don't know how to insert a text area in my code. Please i really need help from you guyz. Here is my CODE
    import javax.swing.*; public class HelloJava{ public static void main(String[] args){ JFrame frame=new JFrame("Hello, Java"); JLabel label= new JLabel("Hello, Java!", JLabel.CENTER); frame.get.ContentPane().add(label); frame.setSize(500, 500); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}
    Sorry for the way the codes are arranged, i use mobile phone to write the codes thats why...Thanks in Advance!!!


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,181
    My Mood
    Hungover
    Thanks
    141
    Thanked 602 Times in 517 Posts

    Default Re: TEXT AREA

    After fixing the compiler error in this code (do you really do your development on your phone?), I can see that you successfully add a JLabel to your JFrame. What's stopping you from adding a JTextArea in a similar fashion?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: TEXT AREA

    Thanks for your reply, i didn't do the development on my phone i use pc but my PC doesn't have internet connection thats why i didnt use it to write the code here... I wil try and add the JTextArea to the code and i will back to u... Tnx 1s again

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,181
    My Mood
    Hungover
    Thanks
    141
    Thanked 602 Times in 517 Posts
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: TEXT AREA

    This is how i did it and still when i run it, it didn't show any text area. Please can you correct it 4 me?... Here is d code
    import javax.swing.*; public class HelloJava{ public static void main(String[] args){ JFrame frame=new JFrame("Hello, Java"); JLabel label= new JLabel("Hello, Java!", JLabel.CENTER); JTextArea textarea= new JTextArea();frame.getContentPane().add("Text Area");frame.get.ContentPane().add(label); frame.setSize(500, 500); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}}
    ..Thanks in Advance!!!

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,181
    My Mood
    Hungover
    Thanks
    141
    Thanked 602 Times in 517 Posts

    Default Re: TEXT AREA

    I'm not sure what you expected this to do. You create a JTextArea, but then you attempt to add a String "Text Area" to the JFrame, which doesn't make sense. A String is not a component. Then you add a JLabel overtop of the String (which already didn't make sense). Is this really the code you're running?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. The Following User Says Thank You to KevinWorkman For This Useful Post:

    mankind (September 5th, 2013)

  8. #7
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: TEXT AREA

    Yes, please correct it 4 me so that i can learn from my mistakes... Tnx 1s again for ur help

  9. #8
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,181
    My Mood
    Hungover
    Thanks
    141
    Thanked 602 Times in 517 Posts

    Default Re: TEXT AREA

    That's not really how this works. Did you read the tutorial I posted, or the Swing tutorial in general? Your syntax is not valid at all, which makes me question whether the code you posted is actually what you're running.

    Also, please read the link in my signature on asking questions the smart way, especially the part about not using SMS-style abbreviations. Plenty of our members do not speak English as a first language, so it can be hard to read. Plus it makes you look lazy.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #9
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: TEXT AREA

    Thanks now i got u correctly, tnx for your help

Similar Threads

  1. Replies: 1
    Last Post: May 18th, 2013, 11:28 PM
  2. [SOLVED] [Asking] Listener on Text Area
    By ardisamudra in forum AWT / Java Swing
    Replies: 7
    Last Post: September 30th, 2012, 06:01 AM
  3. problem with printing to text area
    By gatorsgirl in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 25th, 2012, 10:06 AM
  4. Text file to text area and Radiobuttons?
    By donaldmax in forum What's Wrong With My Code?
    Replies: 9
    Last Post: May 27th, 2011, 04:45 AM
  5. Display in a text area
    By susieferrari in forum Java Theory & Questions
    Replies: 21
    Last Post: March 22nd, 2011, 09:56 AM