How can a class extending MouseAdapter override mouseDragged method?

I've found this code from somewhere, don't remember where
private class DragLimiter extends MouseAdapter {
@Override
public void mousePressed(MouseEvent e) {
pressedX = e.getX();
pressedY = e.getY();
@Override
public void mouseDragged(MouseEvent e) {
label.setLocation(
Math.min(
Math.max(label.getX() + e.getX() - pressedX, BORDER),
panel.getWidth() - label.getWidth() - BORDER),
Math.min(
Math.max(label.getY() + e.getY() - pressedY, BORDER),
panel.getHeight() - label.getHeight() - BORDER));
}The question is how can a class extending MouseAdapter override mousedragged()?
I found that MouseAdapter implements MouseListener whose subinterface is MouseMotionListener, I think this has something to do with the question.
But I've always thought you can only override methods of the super classes or interfaces not vice versa.
I believe I have some kind of fundamental misunderstanding of this and would like to have some help in understanding this.
Thanks

This is more a Java question than a Swing question.
I found that MouseAdapter implements MouseListener whose subinterface is MouseMotionListenerThat's not correct: if you look at MouseAdapter Javadoc, you'll find that it implements both MouseListener and MouseMotionListener (and MouseMotionListener is not a subinterface of MouseListener).
Regardless, if you look at the javadoc, you see that MouseAdapter declares a method public void mouseDragged(MouseEvent). It doesn't matter whether this is also declared by an interface, a subclass can override it all the same.

Similar Messages

  • If I know a name of class , how can I get it's attribute and methods

    If I know a name of class , how can I get it's attribute and methods as well as it's detail information by ABAP code ?
    Best regards ,

    HI, Chandra ,
    Thank you very much , I can get the result
    Best regards,
    DATA lo_class TYPE REF TO cl_oo_class.
    DATA lt_attribs TYPE seo_attributes.
    FIELD-SYMBOLS: <attrib> TYPE vseoattrib.
    TRY.
        CREATE OBJECT lo_class
          EXPORTING
            clsname = 'CLASS_NAME'.
      CATCH cx_class_not_existent .
    ENDTRY.
    lt_attribs = lo_class->get_attributes( ).
    BREAK-POINT.

  • How can I get extended warranty for my nokia 5800 ...

    How can I get extended warranty for my nokia 5800 express music  

    Nokia does not give extended warranty except perhaps in some promo. The dealer you bought it from may offer you extended warranty with them. Apart from that, none.
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • Can a Class extend a Main Class

    Can a Class extend a Class containing
    "public static void main(String[] args)"

    What sort of methods a class has doesn't determine
    whether it may be extended or not. If the class is
    marked Final determines whether it may be subclassed
    or not.
    And if it is accesible in the context that it is being used in.

  • How can I use my array in another method.... Or better yet, what's wrong?

    I guess I'll show you what I am trying to do rather and then explain it
    public class arraycalc
    int[] dog;
    public void arraycalc()
    dog = new int[2];
    public void setSize(int size)
    dog[1] = size;
    public int getSize()
    return dog[1];
    This gives me a null pointer exception...
    How can I use my array from other methods?

    You have to make the array static. :)
    Although I must admit, this is rather bad usage. What you want to do is use an object constructor to make this class an object type, and then create the array in your main class using this type, and then call the methods from this class to modify your array. Creating the array inside the other method leads to a whole bunch of other stuff that's ... well, bad. :)
    Another thing: Because you're creating your array inside this class and you want to call your array from another class, you need to make the array static; to make it static, you must make your methods static. And according to my most ingenious computer science teacher, STATIC METHODS SUCK. :D
    So, if you want to stick with your layout, it would look like:
    public class arraycalc
         static int[] dog;
         public static void arraycalc()
              dog = new int[2];
         public static void setSize(int size)
              dog[1] = size;
         public static int getSize()
              return dog[1];
    }But I must warn you, that is absolutely horrible code, and you shouldn't use it. In fact, I don't even know why I posted it.
    You should definitely read up on OOP, as this problem would be better solved by creating a new object type.

  • How can we call "SP.UI.Notify.addNotification" methods in sharepoint designer page(.aspx) load without any onclick control?

    Hello Friends,
    How can we call "SP.UI.Notify.addNotification" methods in sharepoint designer page(.aspx) load without any onclick control?
    Scenario: When i was open my page i need to show below script,But here i used button control.
    <script type="text/javascript" src="/_layouts/14/MicrosoftAjax.js"></script><script src="/_layouts/14/sp.runtime.js" type="text/javascript"></script>
    <script src="/_layouts/14/sp.js" type="text/javascript"></script><script type="text/javascript">
    var strNotificationID;
    function showNofication()
     strNotificationID = SP.UI.Notify.addNotification("<font color='#AA0000'>In Progress..</font> <img src='/_Layouts/Images/kpiprogressbar.gif' align='absmiddle'> ", false);
    </script>
    <div class="ms-toolpanefooter"><input class="UserButton" onclick="Javascript:showNofication();" type="button" value="Show Nofitication"/> </div>
    Thanks
    Reddy

    Hi  Reddy,
    You can use the window.onload method for achieving your demand as below:
    <script type="text/javascript">
    window.onload=function(){
    </script>
    Hope this helps!
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • How can I get the InsertionPoint with FindText method.

    Hi All:
    In indesing script, I can find "abc text" with FindText method, and I want to insert a image here, but how can I get the insertionPoint(the FindText method return an object)? any help?
    Thanks in advance.

    What seems to be the problem?
    >app.findTextPreferences.findWhat = "text";
    >text = app.activeDocument.findText();
    >alert ("insertionpt "+text[0].insertionPoints[0].horizontalOffset);
    gives (as expected) the horizontal position of the first occurrance of "the".
    Note that findText returns an
    i array
    of found items; its length may be 0 (not found), 1 (only found once), or any other number.
    InsertionPoints is
    i also
    an array. Perhaps you expected it to be 'the' position of the found text -- it doesn't. It's an array of all insertion points in the found text.
    'The' position of the text (in its parent text) is something like text[0].index ("The index of the Text in the collection or parent object.")

  • How can I get to know if a method is threads-safe?

    Hi, there.
    How can I get to know if a method is threads-safe?
    For example, in two different threads, is System.out.print() method safe or not?And where can I find the information with regard to this?
    thanks very much.

    System.out is a PrintStream object. None of the methods there use the synchronized modifier, but if you look in the source code, you will find out it is thread-safe, because it will use synchronized blocks whenever it writes some text.
    The source code is in the src.jar file which you can extract.
    I didn't find any comments about that PrintStream is thread-safe in the API.

  • HT201359 How can I use PayPal as my payment method?

    How can I use PayPal as my payment method for my apple account?

    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact

  • How Can I get extend of ThemeBasedFOI layers

    Hi,
    I am trying to figure out how I can get extend of ThemeBasedFOI layers. With this information I try to center my theme based FOI.
    So far I tried two ways:
    - My first trial was getLayerBoundingBox method of ThemeBasedFOI class. However the resulting SdoGeometry was the extend of the whole map. After I zoom out/in, pan I can not center my FOI with getLayerBoundingBox result.
    - My second trial was getFOIDataEntries method of ThemeBasedFOI class. Through iteration (of FOI data) I try to find layer extend. However, when the layer content was polyline or polygon the method was failed. Since I can only reach the first coordinate of the foi data entries. The failure was dramatic if there is only one FOI data in layer (for this case I can not even has clue about the extend).
    How can I get ThemeBasedFOI extend (now and future)? I also wonder if there is anybody there getting the true result from getLayerBoundingBox method. I also expect that I will utilize this method in future without any problem.
    Thanks for help and interest.

        JenJenTen,
    I understand that having a preset text that you did not want can be a bit frustrating when sending out text. To clarify, is the preset message like a signature at the end of your text? Does this only happen in text messages or when your send emails also? Is your SMS delivery confirmation on? Messaging>Settings>SMS delivery confirmation.
    LindseyT_VZW
    Follow us on Twitter @VZWSupport

  • How can I read Extended APDU input to the same buffer

    The following is the code I am currently using where inBuffer is an intermediate array of 1000 length. However, I do not want to allocate any buffers at all, and just want to send a command apdu of 1000 byte length and modify it in the code and return the modified buf in the response APDU.
    // Read extended APDU input
    byte[] buf = apdu.getBuffer();
    short bytesRead = apdu.setIncomingAndReceive();
    short dataOffset = apdu.getOffsetCdata();
    // store first chunk in our intermediate byte array <-- how do i get rid of the intermediate array
    Util.arrayCopyNonAtomic(buf, dataOffset, inBuffer, (short) 0, bytesRead);
    // what is the overall length?
    short overallLength = apdu.getIncomingLength();
    short messageOffset = bytesRead;
    if (bytesRead != overallLength){ // otherwise we're finished, all bytes received
         short received = 0;
         do{
                   received = apdu.receiveBytes((short)0);
                   Util.arrayCopyNonAtomic(buf, (short)0, inBuffer, messageOffset, received);
                   messageOffset  += received;
              } while(received != 0);
    * REST OF CODE IN PROCESS METHOD
    I have also tried replacing the above code with the following
    short bytesLeft = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
    if (bytesLeft < (short)55) ISOException.throwIt( ISO7816.SW_WRONG_LENGTH );
    short readCount = apdu.setIncomingAndReceive();
    while ( bytesLeft > 0){
      // process bytes in buffer[5] to buffer[readCount+4];
      bytesLeft -= readCount;
      readCount = apdu.receiveBytes ( ISO7816.OFFSET_CDATA );
    as shown in the javadocs API, but it does not compile.
    This is my command APDU:
    /send 800100000003E8000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003E8
    As you can see:
    CLA - 80
    INS - 01
    P1 & P2 - 00
    LC - 0003E8
    Data - 1000 0s
    LE - 03E8
    I am using JavaCard 3.0 with JCOP in Eclipse. How can I read the extended length apdu to the same buffer? I have no problem in returning an extended length response APDU. Thanks a lot for the help.

    You should not call the convenience method setIncomingAndReceive() in your first code. Please find out about the different APDU states. Furthermore, your Applet should implement the ExtendedLength tagging interface.

  • How can a class be notified when an open file is modified externaly ?

    Hi!
    Can a class that open a File be notified when that file is modified by another program ? If yes how ?
    Thanks!

    I don't know that any operating system provides facilities to hook into the filestore this way (whatever language you're programming in). Probably the best you can do is to check the last modified time periodically.

  • How can I force Firefox to override javascript when opening links with ctrl+click?

    There are certain sites that always open up a link in the active window despite said links being opened by ctrl+clicking it. Basically what happens is that a java script on the site forces the active window to load the link while at the same time Firefox follows the ctrl+click command and loads it in a new tab. You end up with two tabs with the same information and always have to go back in your original tab to be able to open other links.
    Usually you can open the link the way you want by right-clicking and selecting 'Open Link in New Tab' but for some reason ctrl+click is treated as if it was a regular click. How can I stop this from happening and force Firefox to ONLY load the new tab?
    This problem is not specific to the version of Firefox I'm using or the operating system, but seems to be caused by java script on the site. Disabling java scripts makes the problem go away but sometimes it also disables the sites.

    If you're trying to protect your browser from hackers, I'd recommend setting up a master password for your saved passwords. Other than that, your anti-virus and firewall are responsible for keeping your computer safe.
    If you're trying to protect your browser from someone else (i.e. somebody who can physically use the computer) just lock your entire computer with a password. If someone else has to use it, you could try letting them use the guest account.

  • How can I return null in a double method

    I have a method, and like this:
    public double fu(){
    In some case I want to return null instead of a double value, how can I make it?
    Thanks.

    The approach with the wrapperclass works. But you should consider, why you want to return null. Is it just to express that an error occured? Then better throw an exception. Or do you want to return that there cannot be a usefull return. Then try to define a special value for that like -1. Normally there is a better approch then returning null.
    public class Doubles {
      public static void main(String[] args) {
        double d = 0;
        try {
          d = doIt();
        } catch (DoubleException d) {
          System.err.println("You made an error.");
      public static double doIt() throws DoubleException {
        if (allOk)
          return 10.123;
        else if (noUsefullAnswer)
          return -1;
        else if (bigError)
          throw new DoubleException("You made a mistake, dummy.");
    public class DoubleException extends Exception {
      public DoubleException(String s) {
        super(s);
    }

  • How can i select view attribute in a method

    hi how can i select view attribute in method and pass that attribute to procedure
        public void DeleteAgr(Integer agrid) {
                     ViewObject svo = this.findViewObject("AGR");
                     //select current view id from agr and link id with agrid          
                    callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new Object[] { agrid });
    }Edited by: Tshifhiwa on 2012/06/30 1:01 PM
    Edited by: Tshifhiwa on 2012/06/30 1:22 PM
    Edited by: Tshifhiwa on 2012/06/30 1:24 PM

    hi i use your sample but now am geting this errror (oracle.jbo.JboException) JBO-29000: Unexpected exception caught: java.lang.NullPointerException, msg=null
    ----- Level 1: Detail 0 -----
    (java.lang.NullPointerException) null check the code below
                              public String getCurrentagrid(String currentagrId) {
                            if (currentagrId != null && currentagrId.length() > 0) {
                                ViewObjectImpl agrVO =
                                    this.getAGR1();
                                if (agrVO != null) {
                                    Key key = new Key(new Object[] { currentagrId });
                                    //Searching for the row with key
                                    //getRow(key) will search in the cache which contain atmost
                                    //2000 records Becoz the MaxFetchSize of EmpVO is 2000
                                    AGRRow agrRow =
                                        (AGRRow)agrVO.getRow(key);
                                    //if the record with key is not present in the cache
                                    if (agrRow == null) {
                                        //Searching for the row with key in the DataBase
                                        //findByKey() searches in DB
                                        Row[] agrRows = agrVO.findByKey(key, 1);
                                        if (agrRows != null && agrRows.length != 0) {
                                            //agrRows = (AGRRow)agrRows[0];
                                    if (agrRow  != null) {
                                        //currentagrId = (String)agrRow.getAttribute("id");
                                        //agrVO.executeQuery();
                                        //agrRow = agrVO.first();
                                        callPerformSdmsLogon("SMS_FORM_TO_ADf.delete_agr(?)", new  Object[] { currentagrId });
                            return currentagrId ;
                        }Edited by: Tshifhiwa on 2012/07/01 10:51 AM
    Edited by: Tshifhiwa on 2012/07/01 11:38 AM

Maybe you are looking for