How to use the MouseAdapter and mouseEntered

I've made panel(Jpanel) with a Label(Jlabel) wich contains an Image).
but i want the image changes in another Image when the mouse passesover the image, without click the mouse?
how can i get this, if i can?
some told use the MouseAdapter anf the mouseEntered, but how
here is the program
public class Panel1 extends JPanel
JLabel ImageLabel,ImageLabel3;
ImageIcon imatge1,imatge2,imatge;
boolean asig;
int Ymove,Xmove;
public Panel1()
               imatge1 = new ImageIcon("c:/Applet/imatges/lupa.gif");
     imatge2 = new ImageIcon("c:/Applet/imatges/not.gif");
          ImageLabel = new JLabel (imatge1);
          ImageLabel.setBackground(new Color(255,219,183));
ImageLabel.setForeground(new Color(255,219,183));
ImageLabel.setOpaque(true);
add(ImageLabel);
//Add a MouseAdapter to the Jlabel and change the image in the mouseEntered method of the adapter.

Here a simple example:
import java.awt.*;
import java.awt.event.*;
class MAdapter extends Frame
     private Button b1, b2, b3;
     public MAdapter()
          addWindowListener(new WindowAdapter()
               public void windowClosing(WindowEvent e)
                    dispose();
                    System.exit(0);
          setLayout(new GridLayout(3, 1, 10, 10));
          b1 = new Button("Button 1");
          b2 = new Button("Button 2");
          b3 = new Button("Button 3");
          MouseListener mListener = new MMListener();
          b1.addMouseListener(mListener);
          b2.addMouseListener(mListener);
          b3.addMouseListener(mListener);
          add(b1); add(b2); add(b3);
     class MMListener extends MouseAdapter
          public void mouseEntered(MouseEvent e)
               Object o = e.getSource();
               if (o == b1)
                    b1.setBackground(Color.yellow);
               else if (o == b2)
                    b2.setBackground(Color.yellow);
               else
                    b3.setBackground(Color.yellow);
          public void mouseExited(MouseEvent e)
               Object o = e.getSource();
               if (o == b1)
                    b1.setBackground(Color.LIGHT_GRAY);
               else if (o == b2)
                    b2.setBackground(Color.LIGHT_GRAY);
               else
                    b3.setBackground(Color.LIGHT_GRAY);
     public static void main(String args[])
          MAdapter mainFrame = new MAdapter();
          mainFrame.setSize(400, 200);
          mainFrame.setTitle("MAdapter");
          mainFrame.setBackground(Color.LIGHT_GRAY);
          mainFrame.setVisible(true);

Similar Messages

  • Gantt chart: Don't know how to use the tooltipkeys and toolkeylabel

    I have a problem. Don't know how to use the tooltipkeys and toolkeylabel. I used jquery to select the gantt bars and on mouse over i was getting the task id "tid" then passing it to adf bean with serverlistener and showing a popup that is adf component with javascript. For positioning of the popup I used a button that has width and height 0 and has position absolute and gets the coordinates of the mouse.
    "div[et]" is a jquery selector that selects all the elements that have attribute et. I noticed that all the bars have that attribute as a few other attributes as well "part"...
    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
            xmlns:dvt="http://xmlns.oracle.com/dss/adf/faces">
        <af:document title="untitled1.jsf" id="d1">
            <af:resource type="javascript" source="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"/>
            <af:resource type="javascript" source="resources/js/home.js"/>
            <af:messages id="m1"/>
            <af:form id="f1">
               <af:commandButton text="commandButton 1" id="cb1" inlineStyle="visibility:hidden; width:0; height:0" />
                <af:popup id="noteWindow" contentDelivery="lazyUncached" binding="#{homeBean.popup}">
                    <af:noteWindow id="popupWindow">
                        <af:panelFormLayout id="pfl2">
                            <af:panelLabelAndMessage label="Task id" id="plam5">
                                <af:outputText value="#{homeBean.taskId1}" id="ot64"/>
                            </af:panelLabelAndMessage>
                            <af:panelLabelAndMessage label="Start Location Name" id="plam6">
                                <af:outputText value="#{homeBean.startLocation}" id="ot7"/>
                            </af:panelLabelAndMessage>
                            <af:panelLabelAndMessage label="Stop Location Name" id="plam7">
                                <af:outputText value="#{homeBean.stopLocation}" id="ot8"/>
                            </af:panelLabelAndMessage>
                            <af:panelLabelAndMessage label="tasktype" id="pla2m7">
                                <af:outputText value="#{homeBean.taskType}" id="ot9"/>
                            </af:panelLabelAndMessage>
                        </af:panelFormLayout>
                    </af:noteWindow>
                </af:popup>
                <af:serverListener type="jsServerListener" method="#{homeBean.serverEventHandler}"/>
                <dvt:schedulingGantt id="gantt1" value="#{bindings.PersonView1.schedulingGanttModel}" var="row"
                                     startTime="2011-07-04 00:00:00" endTime="2011-07-04 23:00:00" summary="gsg"
                                     showMenuBar="false" showToolbar="false" iconPlacement="left"
                                     showTasksAsDailyBar="false">
                    <f:facet name="major">
                        <dvt:timeAxis scale="days" id="ta1"/>
                    </f:facet>
                    <f:facet name="minor">
                        <dvt:timeAxis scale="hours" id="ta2"/>
                    </f:facet>
                    <f:facet name="nodeStamp">
                        <af:column sortProperty="#{bindings.PersonView1.hints.PersonId.name}" sortable="false"
                                   headerText="#{bindings.PersonView1.hints.PersonId.label}" id="c1">
                            <af:outputText value="#{row.PersonId}" id="ot1">
                                <af:convertNumber groupingUsed="false"
                                                  pattern="#{bindings.PersonView1.hints.PersonId.format}"/>
                            </af:outputText>
                        </af:column>
                    </f:facet>
                </dvt:schedulingGantt>            
            </af:form>
        </af:document>
    </f:view>javascript:
    $(document).ready(bindEvents());
    function bindEvents() {
        $("div[et]").live('mouseover', function (e) {
             $('#cb1').css("position", 'absolute');
             $('#cb1').css("top", e.pageY-4);
             $('#cb1').css("left", e.pageX);
            var popup = AdfPage.PAGE.findComponentByAbsoluteId("noteWindow");
            var element = AdfPage.PAGE.findComponent("f1");
            var taskIdToPass = null;
            if ($(this).attr("tid") !=undefined) {
                 taskIdToPass = $(this).attr('tid').toString();
            } else {
                taskIdToPass = $(this).parent().attr('tid').toString();
            var param = {            taskId : taskIdToPass        };
            AdfCustomEvent.queue(element, "jsServerListener", param, true);
            if (!popup.isPopupVisible()) {
                var hints = {};
                hints[AdfRichPopup.HINT_LAUNCH_ID] = "cb1";
                hints[AdfRichPopup.HINT_ALIGN_ID] =  "cb1";
                hints[AdfRichPopup.HINT_ALIGN] = AdfRichPopup.ALIGN_AFTER_START;
                popup.show(hints);
        }).live("mouseout", function () {
            var popup = AdfPage.PAGE.findComponentByAbsoluteId("noteWindow");
            popup.hide();
    };My bean that is session bean:
    package view;
    import oracle.adf.model.BindingContext;
    import oracle.adf.model.binding.DCDataControl;
    import oracle.adf.view.rich.component.rich.RichPopup;
    import oracle.adf.view.rich.render.ClientEvent;
    import oracle.jbo.ApplicationModule;
    import oracle.jbo.Key;
    import oracle.jbo.Row;
    import oracle.jbo.RowSetIterator;
    import oracle.jbo.ViewObject;
    public class HomeBean {
        private RichPopup popup;
        private String taskId1;
        private String startLocation;
        private String stopLocation;
        private long taskId;
        private String taskType;
        public HomeBean() {
            super();
        public void serverEventHandler(ClientEvent clientEvent) {    
            String taskIdString = clientEvent.getParameters().get("taskId").toString();
            this.taskId = Long.parseLong(taskIdString);
            DCDataControl dc1 = BindingContext.getCurrent().findDataControl("AppModuleDataControl");
            ApplicationModule am = dc1.getApplicationModule();
            ViewObject vo = am.findViewObject("PdTrfDayView1");  
            RowSetIterator rowSetIterator = vo.createRowSetIterator(null);
            Row[] rows = rowSetIterator.findByKey(new Key(new Object[] {taskId}), 1);
            Row row = rows[0];
           this.taskId1 =  row.getAttribute("PdTrfDayId").toString();
           this.startLocation = row.getAttribute("StartLocation").toString();
           this.stopLocation = row.getAttribute("StopLocation").toString();
           this.taskType = row.getAttribute ("PdTrfTypeId").toString();
            RichPopup.PopupHints ph = new RichPopup.PopupHints();
            vo.closeRowSetIterator();
        public long getTaskId() {
            return taskId;
        public void setPopup(RichPopup popup) {
            this.popup = popup;
        public RichPopup getPopup() {
            return popup;
        public String getTaskId1() {
            return taskId1;
        public String getStartLocation() {
            return startLocation;
        public String getStopLocation() {
            return stopLocation;
        public String getTaskType() {
            return taskType;
    }I am wondering If i can use setCurrentRow on the iterator that i create and use it for displaying on the popup instead of binding startLocation and stopLocation to the bean and if there is any benefit of that at all...
    Edited by: 897833 on Nov 24, 2011 11:37 AM

    Hi,
    To use tooltipkeys and tooltiplabel in gantt, you can add following code in managed bean
    public String[] getTooltipKeys()
    return new String[]{"columnA", "columnB", "StartDate", "EndDate"};
    public String[] getTooltipLabels()
    return new String[]{"A", "B", "Start Date", "End Date"};
    where , the string array in the ToolTipKeys represents the columns, of the table you have in the gantt component , and the string array in TooltipLabels displays the label you want to display for the table columns.
    In the jsff, you could call the bean methods as follows:
    tooltipKeys="#{GanttBean.tooltipKeys}"
    tooltipKeyLabels="#{GanttBean.tooltipLabels}"

  • How to use the validations and exceptions  in BPEL

    Hi,
    How to use the validations and exceptions in BPEL.
    pls provide one sample example to give the exceptions and validations in BPEL

    Hi,
    For example you can create a simple BPEL Process and you can throw an error during running process. If input data is not valid and format is not correct you can throw error using throw activity and using catch activity you can catch particular error. The catch-all will handle all the error occurred with the scope.
    you can also refer faulthandling section in the link for more information related to exception handling.
    http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/faults.htm#sthref1188
    Regards,
    Deepa

  • How to use the eventing and databag with a WAS 6.20 ?

    How to use the eventing and databag with a WAS 6.20 ?
    Is what there is a good guide for these services?
    Thank's

    In the raise event you can pass the value
    like below.
    <SCRIPT>
    function raiseEvt(value1){
    if(window.document.domain == window.location.hostname){
    if ( document.domain.indexOf(".") > 0 ) document.domain = document.domain.substr(document.domain.indexOf(".")+1);
       EPCMPROXY.raiseEvent( "urn:com.sap:BWEvents","BWiViewevent", value1, null );
      // alert('tree domain'+document.domain);
    </SCRIPT>
    and in the
    subscribe event you can get the values like below.
    <script language="javascript">
    if(window.document.domain == window.location.hostname){
    document.domain = document.domain.substring(document.domain.indexOf('.')+1);
        EPCMPROXY.subscribeEvent("urn:com.sap:BWEvents","BWiViewevent", window, "myreceiveEvent");
    function myreceiveEvent( eventObj ) {
          document.forms[0].gp_hidden.value = eventObj.dataObject;
    </script>
    Also look at the following link for a complete documentation.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/Enterprise%20Portal%20Client.pdf
    Regards
    Raja

  • How to use the user and role API's and where to use it

    Hi All,
    I have configured SSO for my UCM11g. Now my application authenticates through the Oracle SSO login page. Currently it is working with SQL authenticator.
    Now, i have to use LDAP authenticator. when i will configure the LDAP authenticator, i have to use the user and role API's to fetch the user profile information from LDAP. i have got the API's which will be used to fetch the respected information, but i am not getting as where i will write those java programs and how this API will be used in my application. what settings i need to do on it so that application uses the API's. ?
    Please can anyone help me on this.
    thanks,
    Saurabh

    Hi, Mithu,
    Thanks a lot for your help in advance.
    I have carefully read the document: https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6b66d7ea-0c01-0010-14af-b3ee523210b5.
    Now, I think I have to set the processor of every actions in every process if I use the GP for processing the workflow.
    I am better to hope that I can set the processor to the role for every actions in every process in the runtime through get the organizational structure in the WDA(webdynpro for java or webdynpro for java). Thus, the customer don't set the processor to the role for every action in every process when runing in the GP.   I don't know how to do this. 
    Whether the function is not supported in the GP? If so, I have to config two organizational structure: in the R/3 and in the Portal. I don't think our customer don't receipt this solution.
    Do you give me some hints? Thanks a lot.  My email: [email protected]
    Thanks again.
    Thanks & Regards,
    Tao

  • How to use the rescue and recovery, and the product recovery discs ?

    Hi everyone,
    I've just recently became a new owner of a T61, and really enjoying it. I haven't had a chance yet to test-drive the lenovo phone support, as I have not yet screwed anything up that bad that required their help. I did try a clean factory reinstall from the service partition and it worked great. I would like to find out, how does one use the rescue and recovery startup disc, and the product recovery discs that I created myself? From my previous experience with Dell and HP, I only had to insert the first one and restart the computer, and the rest followed. But with ThinkPads, if I ever wanted to bring it to a clean factory state using those discs, do I use rescue and recovery first, followed by the product recovery? I'm curious, what is the difference between the two? 
    T61 (7658CTO), T9300, 3GB, 250GB, XP Pro
    Solved!
    Go to Solution.

    blake_ibm wrote:
    Hi! I'm blake
    There is no diff between the two... One is on  the Hard Drive and the other on CD/DVD.
    Having the HDD version (pre-installed) is a good for trouble shooting.  It uses a whole diff O/S on a whole diff partition (not C.
    So if you are having problems and boot to RnR (via F11), and those problems go away. you know your issue is software related. If you still have the same problems probly Hardware related...  IT IS AN EFFECTIVE WAY TO TAKE WINDOWS OUT OF THE PROBLEM.
    Other then that. You can re-image another HDD from disks, you can't do that with the F11 version.
    dose all that make sense?
    Hi blake_ibm,
    Thanks. All this makes perfect sense to me, but that's not what I'm asking for. My question is this: if I wanted to bring my notebook to its factory shipped condition using my recovery cd's, how do I do that? Do I insert cd1 first and then restart the notebook, or do I just insert it without restarting it, or perhaps I should use first the rescue and recovery?
    You said that there is no difference between the two, but what two are you talking about man? I am not comparing cd recovery to partition recovery. I am talking about rescue and recovery cd, with system recovery cd's. These are the two things that I'm talking about.
    I'm really grateful for all replies, but please people, read the question first !!!
    I would really appreciate if someone could explain the steps involved in performing a clean factory recovery, using the cd's, and not the recovery partition. I just want to know for the future, in case one day I have to do it. That is all I'm asking.
    T61 (7658CTO), T9300, 3GB, 250GB, XP Pro

  • N8 Photo Editing - how to use the cut and paste?

    Hello,
    I am trying to edit some photos - there is a an option to use an ellipse or magic wand.  I thought that was to cut and paste from the photos.
    All I can do is select and area - but how do I cut it. 
    I tried save, but it saves the whole image...
    Or am I just doing this wrong...
    Thanks,
    VeePee
    Nokia 3395
    Nokia 6600
    Nokia N95 8GB
    Nokia N8 (Anna)
    Nokia Lumia 930

    I was hoping to use the ellipse or magic want to cut and paste items in a certain shape to paste on other photos.
    I could do this on my N95-4.
    So there is no way to photo edit with cut and paste?
    Any idea what the ellipse and magic wand function do, and how do they work?
    Thanks,
    VeePee
    Nokia 3395
    Nokia 6600
    Nokia N95 8GB
    Nokia N8 (Anna)
    Nokia Lumia 930

  • How to use the userid and password infor from Oracle DB in BO

    Out client has the userid and passwords(encrypted) infomration stored in oracle table.
    Is it possible to import this useid and password information into BO .And use the same userid and password from Oracle table for its login authentication and for data security...?
    In other words can the userid/pwd info from Oracle Profile Table imported and re-used in BO Enterprise Edition.

    If the users/pw are in an Oracle LDAP v3 compliant server then you can import them via LDAP plugin, else you would need to bring them in an enterprise users via script. The Import wizard can do this and the SDK (see the SDK forums for more info on how)
    Maintaining the passwords would be difficult unless you are using and industry standard directory like LDAP.
    Regards,
    Tim

  • How to use the mirrored and log shipped secondary database for update or insert operations

    Hi,
    I am doing a DR Test where I need to test the mirrored and log shipped secondary database but without stopping the mirroring or log shipping procedures. Is there a way to get the data out of mirrored and log shipped database to another database for update
    or insert operations?
    Database snapshot can be used only for mirrored database but updates cannot be done. Also the secondary database of log shipping cannot used for database snapshot. Any ideas of how this can be implemented?
    Thanks,
    Preetha

    Hmm in this case I think you need Merge Replication otherwise it breaks down the purpose of DR...again in that case.. 
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to use the "GEN_KEY" and "FROM_KEY" of RFC_GET_TABLE_ENTRIES

    Hi there,
    I am using JCO java connector in my own client application to talk to SAP. I need to use RFC_GET_TABLE_ENTRIES to read table entries.
    Just wondering if anyone knows how to use GEN_KEY and FROM_KEY of this function to narrow the table read as it currently returns all the entries in the table. Could someone provide the exact syntax of the data that I need to pass to these two parameters please?
    Your help is much appreciated!

    Thanks for your reply.
    I am using this table "USRSYSACTT". It is keyed on "MANDT", "SUBSYSTEM", "LANGU" and "AGR_NAME". When I want to only get the entry where the SUBSYSTEM = "SUB123", LANGU="E" and AGR_NAME="Role Name", I passed GEN_KEY="SUB123    ERole Name                     ". It did not work for me. It seems that only the "SUBSYSTEM" field has some effect. It returns all the entries with the correct subsystem. But the LANGU and AGR_NAME do not seem to have any effect.
    Any idea what I have done wrong.
    Thanks again

  • How to use the webcam and make work

    I have a NOTEBOOK with a webcam is a windows 7 32-bit and one day it crash and it been reboot back, but, every since the webcam it not working. what should I do to make it work.

    Hi Proboco,
    Please provide us the complete model of your system along with the operating system, so that we can assist you in a better way.
    How to locate model number:
    Notebook:
    http://h10025.www1.hp.com/ewfrf/wc/document?cc=us&lc=en&docname=c00033108
    Regards,
    =======================
    I am an HP employee.
    If my suggestion was helpful, you can thank me by clicking on the "Kudos" button!
    If my answer solved your problem, please feel free let the community know by clicking the "Accept as Solution" button!!

  • How to use the forums and get (helpful) help!

    Please, I beg you, read the Javadoc on the class you are asking about:
    http://java.sun.com/j2se/1.4/docs/api/index.html
    Have you looked for an answer in Suns training documentation, tutorials and Java specification?
    http://developer.java.sun.com/developer/infodocs/
    Post your code so that it is readable:
    http://forum.java.sun.com/faq.jsp#messageformat
    Of course, is everyone followed these rules (including me) these forums would probably be a very lonely place ;)

    You either use single quotes in the SQL string, or (my preferred method) use a Prepared Statement
    String sql = "select count(cc.id) from customers c, creditcards cc where c.cc_id = '" + ccID+ "' ";
    // or better IMO
    sql = "select count(cc.id) from customers c, creditcards cc where c.cc_id = ?");
    PreparedStatement pstmt = con.prepareStatement(sql);
    sql.setString(1, ccID);The prepared statement protects you agains SQL injection attacks, and any values that would need escaping in SQL. What would happen if someone entered a single quote in the ccID field?

  • Can anyone tell me how to use the loops and backing tracks with a single guitar input? I can't seem to figure out how to set this up

    I am trying to configure Mainstage to input my own guitar and add a backing track from the library or a loop but, I can figure out how to open or add the tracks I've downloaded. Any help would be great

    did you try the PlayBack preset/template?
    once you open the PlayBack plug-in you just load the tracks from the plug-in's menu.

  • How to use the servlets and javabeans in the JavaServer Pages?

    I have some trouble on the usage of JavaBeans and Servlets.
    Who can tell me the resource about those?
    Thank you!

    The JOT Servlets framework integrates Java Beans and Servlets. You can download the evaluation package and look at the demonstration applications to get some ideas about how it works.
    JOT Servlets - http://www.jotobjects.com

  • How to use the IPOD and create a playlist

    My friend loaded my IPOD with music but now when I connect to the computer Itunes come up but don't show any of the music he loaded in my Ipod, and how can I create a playlist with the music that is in my Ipod.
    Please help

    Yes yoy have to create the playlist in Itunes, but I think
    I did not ask the proper question, I know how to turn on the Ipod, my question is if he loaded my ipod with his music now when I connect the ipod to the compputer Itunes comes up but it does not show in the computer all the songs he has loaded, Itunes is there but there is no songs what I am trying to say Itunes is there but it is empty, how am I going to create a playlist and there is nothing there. When I first connected there where there but now I don't see it, this is frustrating I need to create playlists for my classes and I can't do it I Thought that buying an Ipod would be easy but is not Please help me otherwise I don't know who to ask.

Maybe you are looking for

  • Unable to install itunes 10.4.1 on my dell laptop windows 7 64 bit

    Hello I am unable to install itunes 10.4.1 on my dell laptop windows 7 64 bit: i have tried to install itunes on my windows 7 64 bit dell laptop, and everytime it says installation successfully installed, but i can't find the files anywhere in the co

  • Nokia Browser driving me insane!

    Hey everyone, I really hope someone can help me! I downloaded the new firmware for my N97mini, the v.11.0.045 i believe its called. Now when I for example browse YouTube, except for the fact that it wont play a video in full screen because it just do

  • Technical Photo-JPEG question

    I am doing a project where a client has provided me with 400 Photo-JPEG files. (stock footage from Digital Juice). They load and playback just fine in a sequence that was created using the Make Sequence button. I was informed by a knowledgeable perso

  • Newbie: What is your favorite feature?

    Care to share your favorite feature? I am tryint to get to know my new BlackBerry This is so different from the Treo but I do love that the email is delivered without delay.  Hoping to discover why the Verizon Rep.  thinks the BlackBerry is a Superio

  • Calendar time is 2 hours off of macbook pro time

    Installed Mtn Lion. Calendar reflects a time (the indicator line through today's date). It is off by two hours. It reschedules all my appointments.