Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-07-2010, 02:53 PM
Member
 
Join Date: Feb 2010
Posts: 1
Rep Power: 0
wadhah.alhaddad is on a distinguished road
Question Custom GUI...Help?!
Hello , everyone.
This is my first post,and I am new to Java-and programming in general-, so I am looking forward to learn, and give advice where I can.

I need to create a GUI components from scratch, like a button, Text area etc. Instead,I figured that if I understand the Java components' source(from OpenJDK) I can customize them to my needs, instead of creating new ones.
Here is my problem:
I read the source code of JTextArea (and it's parents), but I cannot figure out how it draws the text!(I expected something like graphics.drawString , or any other method that performs the drawing).All calling to paint() in this class or parent classes, do not have anything that draws the text.

I ask this question because I don't want to develop a text component from scratch, because then I will have to deal with a lot of issues, and I can't find and source code for a simple Text Component.

Can anyone Help me plz?

Also,though outside the topic, Swing components do not have peer components , but all of them inherits from AWT.Compnent, and AWT components have peers, how can that be?!!!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 02-07-2010, 03:54 PM
Senior Member
 
Join Date: Sep 2008
Location: Voorschoten, the Netherlands
Posts: 3,322
Rep Power: 5
JosAH is on a distinguished road
Default
All JComponents delegate their painting to a UI; for a JTextArea a TextUI does the drawing. That's why you don't see any drawing in the JTextArea itself. Those UIs are pluggable; different Look and Feel objects supply their own UIs for the JComponents.

Better extend an existing JComponent than building your own. The fist is much easier (but it depends on what you want to do) than the latter.

kind regards,

Jos
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Tags
gui, jtextarea, textarea from scratch

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom JTree guyjasper AWT / Swing 0 10-20-2008 04:50 PM
Using a custom task in Ant JavaForums Java Blogs 0 05-25-2008 11:40 AM
Custom Avatar JavaBean Suggestions & Feedback 4 01-17-2008 12:28 AM
RCP Custom Look and Feel JavaForums Java Blogs 0 01-02-2008 06:12 PM
Custom tgs in JSP ravian New To Java 2 12-29-2007 05:05 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 09:03 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org