Welcome to Dream.In.Code
Become a Java Expert!

Join 150,381 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,194 people online right now. Registration is fast and FREE... Join Now!




[solved] FocusListener on a JPanel

 
Reply to this topicStart new topic

[solved] FocusListener on a JPanel

torenrl
16 Feb, 2008 - 06:33 AM
Post #1

New D.I.C Head
*

Joined: 14 Feb, 2008
Posts: 7


My Contributions
I am trying to change the background of a panel and/ or label in an array when they are in focus. Both the label and the panel is setFocusable(true) and setRequestFocusEnabled(true). I have added the FocusListener class to each panel and label. The FocusListener class is like this:

CODE

public static class panOrdFokusAksjon implements FocusListener{
        
        int i;
        
        public panOrdFokusAksjon(int i){
            this.i = i;
        }
        
        public void focusGained(FocusEvent e){panOrd[i].setBackground(Color.cyan);}
        public void focusLost(FocusEvent e){panOrd[i].setBackground(Color.white);}
    }


panOrd[i] is the panel in the array i want to change background color of.

This post has been edited by torenrl: 16 Feb, 2008 - 07:00 AM
User is offlineProfile CardPM
+Quote Post

torenrl
RE: [solved] FocusListener On A JPanel
16 Feb, 2008 - 07:00 AM
Post #2

New D.I.C Head
*

Joined: 14 Feb, 2008
Posts: 7


My Contributions
Solved, I used a MouseListener instead.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:24PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month