Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2010
    Rep Power

    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?!!!

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power


    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,


Similar Threads

  1. Custom JTree
    By guyjasper in forum AWT / Swing
    Replies: 0
    Last Post: 10-20-2008, 05:50 PM
  2. Custom Avatar
    By JavaBean in forum Suggestions & Feedback
    Replies: 4
    Last Post: 01-17-2008, 01:28 AM
  3. Custom tgs in JSP
    By ravian in forum New To Java
    Replies: 2
    Last Post: 12-29-2007, 06:05 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts