Where is the Java TextArea paint method implemented?
I am looking for the paint
method implementation for a Java TextArea
component (java.awt.TextArea).
I have read through the source code for the class as well as its super class (java.awt.TextComponent), but have not found a public void paint(Graphics g)
method implementation, which I think means the class would be using the default Component#paint(Graphics)
implementation, which doesn't make sense. Am I missing som开发者_如何转开发ething here? How is a TextArea
component painted?
TextArea is an AWT component, not a Swing component. It's thus what's called a heavyweight component, which means it's in fact implemented by a native component of the underlying platform/OS (i.e. a Windows/Gnome/Motif component, depending on the OS), called the peer of the component. The painting is thus done by the platform's native widget, and not by the component.
AWT Components
is dinosauruses from last milenium, and only by back-compactible
are there and still exists, please/better would be to change that to the Todays JComponents
, all starts with "J" here is list of JComponents with tutorials, but for Swing's JComponents is there paintComponent(Graphics g)
instead of paint(Graphics g)
method paint is still there but for deepest painting in XxxXxxUI, for example MetalButtonUI, but not for painting Image/Lines/Text ... and just try to avoid a similar examples from year 2000 and another very old examples, that's really wrong implemntation for Custom Painting in Java6's Swing,
here is your required tutorial and Java6 API
on this Forum are plenty threads about Painting Something in JComponents
EDIT: if you want to paint something then look for JLabel (is transparent by defalut), that best JComponent
for 2D Graphics, examples for that here, and with paintComponent() method only
精彩评论