Results 1 to 5 of 5
- 08-17-2011, 10:41 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 3
- Rep Power
- 0
Direction for creating a custom JTextField input
Hi,
I'd like to ask if anyone would kindly point me in the direction of creating my own unique text input field. Basically, I've written a JLabel component with its paint overridden to display the text in a circle layout (pointing the angle of each character to the centre).
I'd now like to figure out how to write an input field to take the text, rather than popping up a JTextField and using that. Where do I start? I.E. Should I be:
o Look at extending and overriding the methods in JTextField (my concern is that this natively expects the text to be horizontal. I believe).
o Research how input from the keyboard can be taken and writing my input field (seems to be a lot of work here to digest and understand).
I'll continue to research, but wondered if someone can save me sometime by pointing me off in the right direction. I'm comfortable around SWING, but no way an expert; hence asking for help.
Thanks and kind regards
Sp33dy
- 08-17-2011, 10:58 AM #2
JTextField with a custom (and fairly complex) UI delegate (i.e. TextFieldUI). Your custom JLabel should also be implemented via a LabelUI class, not by extending JLabel.
Maybe you can pick up some ideas from my Vertical Label UI « Java Tips Weblog
And it's Swing, not SWING (it isn't an acronym).
db
- 08-17-2011, 11:08 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 3
- Rep Power
- 0
Thanks db,
I'll head to your article now. I wasn't aware of the LabelUI class, but I'll get on and learn now. I always knew my JLabel was a hack to prove I could implement what I desired. Thanks for replying so quickly! Also, thanks for the correction on Swing naming. I'd always assumed it was an acronym.
Kind regards
Sp33dy
- 08-17-2011, 08:40 PM #4
Member
- Join Date
- Aug 2011
- Posts
- 3
- Rep Power
- 0
Hi db,
A huge thanks! Using the UI Delegates is a lot easier and cleaner than I'd been doing with extending and overriding the paint methods of the JPanel and JLabel classes!
Very quick initial test is showing me that I can indeed replace the Look'n'feel whilst tapping into the JTextField's editing capability.
A huge thanks. Chuffed to nuts!
Regards
Sp33dy
- 08-17-2011, 09:08 PM #5
Similar Threads
-
input from JTextField
By Willriker in forum New To JavaReplies: 13Last Post: 08-14-2011, 02:17 AM -
Allow only numerical input on JTextField
By patriotsfan in forum AWT / SwingReplies: 3Last Post: 05-31-2011, 12:39 PM -
Dynamically input text JTextField. Is it possible?
By africanhacker in forum New To JavaReplies: 2Last Post: 03-21-2011, 04:23 PM -
Convert Input from JTextField to int?
By jls7168 in forum New To JavaReplies: 7Last Post: 02-20-2009, 02:29 AM -
Constraining Input in JTextField
By kataya in forum AWT / SwingReplies: 1Last Post: 06-26-2008, 06:25 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks