Results 1 to 2 of 2
- 02-16-2010, 08:44 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 20
- Rep Power
- 0
Diabled JButton won't leave the focus
Hi,
The Swing focus sub-systems seems defective to me as it will transfer the focus to a disabled JButton, which is in the focus cycle , but then won't transfer the focus to the next component in the focus cycle on pressing the focus traversal keys.
Ideally, a diabled components should not receive the focus in the first place.
I tried to get around it by writing a propertychange listener so that I can set the focusability of any component in the container to false when it is disabled. However, this code does not seem to be working. What is the remedy? What property name to use in this context?
Java Code:class CustomPropertyListener implements PropertyChangeListener { public void propertyChange(PropertyChangeEvent e) { Component component = (Component) e.getSource(); component.setFocusable(component.isEnabled()); } } // end of inner class definition CustomPropertyListener propertyListener = new CustomPropertyListener(); Component[] components = this.getComponents(); for(Component component : components) { component.addPropertyChangeListener("enabled", propertyListener); }
Regards,
Dinesh
- 02-16-2010, 09:30 AM #2
Similar Threads
-
Leave management System
By anji4u_19 in forum Suggestions & FeedbackReplies: 24Last Post: 04-05-2010, 06:03 PM -
NumberFormat which leave fractions as they are
By itaipee in forum AWT / SwingReplies: 2Last Post: 12-09-2009, 06:11 PM -
problem in doing leave management
By satkk in forum JDBCReplies: 3Last Post: 08-19-2009, 05:51 PM -
problem in doing leave management
By satkk in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 04-01-2009, 04:50 PM -
Creating a JButton that does not show focus
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:38 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks