How to set hand cursor to all buttons

In nowadays web oriented world users expectations are that desktop application behave like web application.

And part of this that cursor must be changed when moving over button and checkbox controls.

Next code snippet satisfied needs:

        public MainFrame{
               initComponents();
               setCursorToAllButtons(this);
        }

        private void setCursorToAllButtons(Container container) {
        Component[] components = container.getComponents();

        for (int i = 0; i < components.length; i++) {
            if (components[i] instanceof Container){
                setCursorToAllButtons((Container)components[i]);
            }
            if (components[i] instanceof JButton || components[i] instanceof JCheckBox) {
                components[i].setCursor(new Cursor(Cursor.HAND_CURSOR));
            }
        }
    }
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • MySpace
  • RSS
  • Twitter
  • Yahoo! Bookmarks
  • Yahoo! Buzz
  • BlinkList
  • blogmarks
  • DZone
  • E-mail this story to a friend!
  • LinkaGoGo
  • Live
  • MisterWong
  • MisterWong.DE
  • Reddit
  • StumbleUpon
  • Technorati
  • ThisNext
  • Tumblr

No related posts.

Leave a Reply


wp