Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Creating custom swing componenets

If I want to create my own JComponent, how would I do that?
For example If i wanted to create my own textbox component, where would I start?
If someone could point me in the right direction with online tutorials or something, that would be great.
0
farhadabas
Asked:
farhadabas
  • 3
  • 3
  • 2
1 Solution
 
ADSLMarkCommented:
You should make a class extending JComponent. Take a look at this website:

http://72.5.124.55/docs/books/tutorial/uiswing/painting/practice.html

Mark
0
 
farhadabasAuthor Commented:
I have read that but how about more detailed things like setting the events and different states.
0
 
hoomanvCommented:
For custom events, you should provide a set of methods for others to register for them
addXXXListener, removeXXXListener, fireXXX
http://www.javaworld.com/javaqa/2000-08/01-qa-0804-events.html
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
farhadabasAuthor Commented:
0
 
ADSLMarkCommented:
How about this question on the sun java forum:

http://forum.java.sun.com/thread.jspa?threadID=745297&messageID=4267482

Mark
0
 
farhadabasAuthor Commented:
the above is good but i was thinking something more complete, a whole tutorial on making a component from scratch and adding listeners in it and stuff
0
 
ADSLMarkCommented:
I understand, maybe this helps:

http://www.onjava.com/pub/a/onjava/2004/08/11/desktop.html

Mark
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now