Solved

Creating custom swing componenets

Posted on 2006-11-23
8
239 Views
Last Modified: 2012-06-27
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
Comment
Question by:farhadabas
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Expert Comment

by:ADSLMark
ID: 18004136
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
 

Author Comment

by:farhadabas
ID: 18004645
I have read that but how about more detailed things like setting the events and different states.
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 18006155
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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:farhadabas
ID: 18010041
0
 
LVL 10

Expert Comment

by:ADSLMark
ID: 18010605
How about this question on the sun java forum:

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

Mark
0
 

Author Comment

by:farhadabas
ID: 18012435
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
 
LVL 10

Accepted Solution

by:
ADSLMark earned 115 total points
ID: 18012440
I understand, maybe this helps:

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

Mark
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 18012473
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question