Java Programming Tutorial - 76 - MouseMotionListener interface

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 197

  • @Ele20002
    @Ele20002 7 лет назад +14

    Tip: Hover over Class name with error and click "Add Unimplemented Methods"
    Saves Typing all 6 methods

  • @lopyus
    @lopyus 10 лет назад +17

    Bucky is the best person I've ever met in this planet.

  • @hurolinci5986
    @hurolinci5986 9 лет назад +7

    How can you not be creative? Your programs and tutorials are just the best to selfstudy this stuff

  • @potenvandebizon
    @potenvandebizon 11 лет назад +15

    Learning IS fun. That's what these video's are for.

    • @grymmatarmar
      @grymmatarmar 11 лет назад +1

      True true :)

    • @physicsimpossible73
      @physicsimpossible73 10 лет назад +1

      Dude I don't like your profile picture, no offence :)
      lol

    • @potenvandebizon
      @potenvandebizon 9 лет назад +1

      Epicnerd73 Watch 'The Shining' by Stanley Kubrick, you'll know where it's from :)

    • @TheJRGamer8
      @TheJRGamer8 9 лет назад +2

      +Mistermaarten150 HEEEEEEEEEEEEERRRRRRRRRRRRRESSSSSSSSSS JOHNNNNNYYYY

  • @BlueSkyNoise
    @BlueSkyNoise 9 лет назад +51

    "but hey, I'm not that creative. that's what my therapist told me" lmao

    • @morte3252
      @morte3252 8 лет назад +1

      That's um, pretty sad, was bucky down at the time? Who knows the background info?

    • @patrasculucian2403
      @patrasculucian2403 7 лет назад

      +Morte It was a joke.

  • @Bad_Horsey
    @Bad_Horsey 11 лет назад +2

    You rock, dude. Your tutorials are totally saving my ass this semester. Thanks!

  • @destructionman1
    @destructionman1 13 лет назад

    Wow I'm so glad I found this set of tutorials. I looked forever online and found such useless stuff on mouse listeners, and this is just what I needed.

  • @surbhidua7
    @surbhidua7 10 лет назад

    I have been following your tutorials for quite sometime now and I must say they are really good. Easy and simple to understand! You have really made learning Java easier. Thanks a ton! :)

    • @saalleER
      @saalleER 7 лет назад

      And did you learned Java =p?

  • @twoofakindmagic
    @twoofakindmagic 13 лет назад

    bucky, I spent about an hour studying oracle's api and after about another hour of experimentation I looked it up on youtube and this helped soooooo much!

  • @abovestand
    @abovestand 14 лет назад

    Who knew how fun a program that changes from white to red could be lol...
    Thanks once again for another awesome tutorial!

  • @BstlNas
    @BstlNas 11 лет назад

    I feel like Bucky is my personal mentor...any time I need help, I ask thenewboston and he always has a tutorial on it and he always explains it to me perfectly

  • @babakmbm
    @babakmbm 12 лет назад +1

    you are the most useful man on the internet,,, you rule

  • @Juceeass
    @Juceeass 5 лет назад

    thanks for this bucky. Youve been saving uni students for 10 years.

  • @ericalas93
    @ericalas93 12 лет назад

    thank you so much for this tut!! saved me from lots of headaches trying to decrypt my profs lecture notes...

  • @TheBlacktwister8
    @TheBlacktwister8 8 лет назад +13

    "Learning is not that fun" - Bucky 2009

  • @einhacker-typ6457
    @einhacker-typ6457 7 лет назад

    Nice. We're on our way to creating a simple game through this tutorial

  • @princegupta6779
    @princegupta6779 8 лет назад +8

    this program was jut amazing!!!!!!!

  • @OBeymydreamz
    @OBeymydreamz 12 лет назад +1

    you can add the "getX()" and "getY()" in dragging event so u can see how your mouse changes coordinates while you are moving pressing the mouse button.
    cheers!

  • @thomashartnagle7179
    @thomashartnagle7179 12 лет назад

    This helped me so much when i was trying to learn how to do mouse events thank you so much

  • @quequequenananana
    @quequequenananana 12 лет назад

    The event is clicking, moving it, and then releasing it, it doesnt matter if you did it fast or slow, thats why you dont get MouseClicked, because from when you pressed, to when you released, you moved the mouse...

  • @lilredcutie0
    @lilredcutie0 12 лет назад

    It's because you put your handler class inside the GUI constructor, and not as its own private class. It should be outside the GUI constructor, but still inside the GUI class.
    I did the same thing by accident.

  • @IceAmStiel
    @IceAmStiel 12 лет назад

    Abstract means that you've got to overwrite all existing methods within the class, so probably you forgot to overwrite one of those - it's pretty well working like it's stated in the vid

  • @jcweaver1990
    @jcweaver1990 13 лет назад

    this is by far the funnest program we've made ;)

  • @dhruvsharma5884
    @dhruvsharma5884 11 лет назад

    When i used to jump to higher videos to see how hard it is and i used to be like what is this i am never gonna learn it and now i am like meh! Piece of cake ~.~

  • @ahmermirza
    @ahmermirza 8 лет назад

    thank you so much man. I really appreciate your tutorials. Cheers!

  • @zldamstr
    @zldamstr 13 лет назад

    Bucky, you MAKE learning fun. :) Thanks so much man.

  • @arunhegdedvg
    @arunhegdedvg 13 лет назад +1

    you are awesome sir........

  • @meruems
    @meruems 9 лет назад

    Thank you Bucky I was looking for this!

  • @Robostate
    @Robostate 10 лет назад

    I had to put a "package" line to head the classes. It also said something like "statusbar can be final". And it prompted me to put @Override before all of the methods. No errors, but no GUI. I am using Netbeans, but it seems to work pretty much the same way.

  • @Mattedatten
    @Mattedatten 14 лет назад

    @fakeface20
    I have kind of just understood this, so this explanation might be wrong, but:
    String.format("The item %s", item)
    Means that the text is "The item " + a String object called item.
    String.format("The number is %d", num)
    The text becomes "The number is " + a (for example) int called num.
    This was written in notepad, it probably looks better there than here on youtube comments.
    Well
    @thenewboston
    Great tutorials! And it makes it even more great when you see what you are doing :)

  • @klimqx
    @klimqx 6 лет назад

    people get addicted to smoking and drinking
    im addicted to your videos XD
    for real man you explain things very good

  • @burhan1992
    @burhan1992 13 лет назад

    try this: inside mouseMoved(), write mousepanel.setBackground(new Color(100, event.getX(), event.getY())); but make sure the height and width of the panel doesn't exceed 255 or exception will be thrown =)

  • @midnightcarsintokyo
    @midnightcarsintokyo 13 лет назад

    If you change the colors so that mouse pressed is black and then the rest are white, and then you click really fast loads of times, you have a strobe.

  • @endtheis
    @endtheis 13 лет назад

    @Coolcl0wn
    It's easier to tell the program "if dragging", instead of "if mouse moving and mouse down" every time.

  • @harivigneshr6244
    @harivigneshr6244 2 года назад

    Thank you for posting this video. What would be the Java code to write text into an existing word (.docx) file?

  • @StormyJMaster
    @StormyJMaster 11 лет назад

    Mouse released is when you press down the mouse (hold down) and stop pressing.

  • @alexhunter4800
    @alexhunter4800 5 лет назад

    Thank you very very very much!!!!! I could draw the path on the map!!! you saved my ass =*

  • @eliteveteran8218
    @eliteveteran8218 15 лет назад

    GJ again bucky, reply please, you thinking about going far into java? e.g. TCP communication, servers clients.

  • @paziipa
    @paziipa 14 лет назад

    Thank you for great tutorials! :)

  • @cheersfornads
    @cheersfornads 14 лет назад

    You are awesome. Thank you so much.

  • @OOchriOO
    @OOchriOO 12 лет назад

    of the world! Trust me, i'm saying it from Switzerland

  • @SamDwyaa
    @SamDwyaa 12 лет назад

    Yes the game itself is coded in Java but I am fairly certain that the .exe only access the game files and launcher. Hope this helped.

  • @nathanshepherd2451
    @nathanshepherd2451 7 лет назад

    i have looked. and tried to figure out what i am doing wrong. even copied it word for word.
    when i run my main the window pops up but when i click nothing happens.
    under my
    public void MouseClicked method it is underlined saying event is never used locally.

  • @lewisp90
    @lewisp90 14 лет назад

    you're my hero

  • @somethingtojenga
    @somethingtojenga 11 лет назад

    Wouldn't it be more useful to 'getX' and 'getY' on 'mouseMoved'? Would that update the coordinates while it's moving or just when it starts moving?

  • @bangerproductions1584
    @bangerproductions1584 8 лет назад

    you are creative men i think you know it :D

  • @_mr.lala_patel_
    @_mr.lala_patel_ 3 года назад

    Present sir, Ankit

  • @andypejman
    @andypejman 15 лет назад

    Im stuck on a program for school, how can I make the user input characters until he inputs an upper case letter w/ JOptionPane?
    also
    Have the user input Strings until he inputs the word "Quit". The case of the letters should not matter.

  • @JKTCGMV13
    @JKTCGMV13 13 лет назад

    @amiorkovtube File>Export...>(window will pop up)Java>Runnable Jar File , then under launch configuration select the file that has your main method in it.
    this gives you a .jar, im not sure how to get an .exe :(

  • @mohannad8977
    @mohannad8977 9 лет назад +4

    Is there any method for Mouse scrolling ?
    Like when you move the wheel of the Mouse something must happen

    • @EP_1990
      @EP_1990 9 лет назад +7

      Memo Thunder addMouseWheelListener. I don't know the methods which we need to override but you can check it.

    • @mohannad8977
      @mohannad8977 9 лет назад

      Sure, Thank you i will try it :)

    • @riddhigupta3371
      @riddhigupta3371 9 лет назад

      Eshan Patil thanks

    • @oribarmatz5840
      @oribarmatz5840 8 лет назад

      +Memo Thunder there is a listener called "mouseWheelListener". use it!

    • @patrasculucian2403
      @patrasculucian2403 7 лет назад

      C'mon! If the're wasn't any method for mouse scrolling you wouldn't be in the comments section xD

  • @Torodiamo
    @Torodiamo 11 лет назад

    Sadly the case "You entered the area" never takes place cause it gets overwritten by "You moved the button"...

  • @LetumFilms
    @LetumFilms 11 лет назад

    I tried that and, yes, it works :D

  • @RaymundoGabriel
    @RaymundoGabriel 13 лет назад +1

    you shoud make like a little homework , just for practice and then make the exercise just to see if we made it right! :)

  • @drizzle666
    @drizzle666 13 лет назад

    the only tutorial that helped me figured out the mouse events, great work, man, and i guess u got a lot of girls in real life huh?

  • @geirendre
    @geirendre 13 лет назад

    The mouseEntered method will never work (you wouldn't
    see the "You entered the area" message, because the method
    mouseMoved captures the same event.
    Apart from that little "flaw", great tutorial :-)

  • @jiffpop5143
    @jiffpop5143 6 лет назад

    I'm curious why it gives you the mouse click location after you click. Shouldn't it also say "You released the mouse."

  • @Whompratt1342
    @Whompratt1342 12 лет назад

    C'mon Hoss! Get it together!

  • @glogalswaze
    @glogalswaze 12 лет назад

    5 people just like to see the world burn Mr. Wayne.....

  • @tranquangchung2892
    @tranquangchung2892 8 лет назад

    very good.thanks

  • @MichaelS0305
    @MichaelS0305 12 лет назад

    how would you apply the changing of the background to a button instead of the whole screen?

  • @dinublanovschi1640
    @dinublanovschi1640 7 лет назад

    Is there any way I can get the first and the last point of the mouseDragged ?I tried it in some ways but I didn't got it successfully

  • @mcfundash1
    @mcfundash1 13 лет назад

    @JKTCGMV13 @amiorkovtube You cant get an .exe thats only with c/c++, a completely different langouage (with a few similaritys) I plan to learn c++ and objective-c after java :D
    keep programmin!

  • @RonanConnolly
    @RonanConnolly 11 лет назад

    That's why he added the setBackground method.

  • @buffaloSoldier519
    @buffaloSoldier519 9 лет назад

    MouseMoves works but MouseDragged doesn't for me :(
    Edit: Actually it turns out it works, just doesn't work when I'm trying to detect which button is being dragged.

  • @lodman97
    @lodman97 13 лет назад

    lol *high voice*Oh i didn't enter yet...*normal voice* OH i entered

  • @cokish1
    @cokish1 13 лет назад

    I hava all these GUI tutorials in one file. So I have big window with bunch of buttons when I run it. For some reason I can't add status bar to it. Is that because of "SetLayout..."? Please, help

  • @eisa313
    @eisa313 13 лет назад

    @burhan1992 really cool, thanks for sharing that =)

  • @janverm
    @janverm 15 лет назад

    I would like some tutorials on sockets, i don't understand it very well, but i would really like to learn sockets.

  • @laserbean00001
    @laserbean00001 7 лет назад +1

    I tried typing the exact same code yet it does not work for some reason. And why doesn't your code have " public static void main(String[] args)" ???

    • @iamthebull5SH
      @iamthebull5SH 6 лет назад

      I suppose his main method is in his apples class.

  • @games.8781
    @games.8781 11 лет назад

    can't wait till i'm at this tutorial

    • @grymmatarmar
      @grymmatarmar 11 лет назад

      Which tutorial are you on?

    • @games.8781
      @games.8781 11 лет назад

      now 67

    • @games.8781
      @games.8781 11 лет назад

      i mean 68

    • @grymmatarmar
      @grymmatarmar 11 лет назад

      Games. Nice nice, started a little over a week ago, the only thing that takes a while to learn is the GUI i would say, due to it's large choices of classes, functions, etc

  • @YourAppleTechHelp
    @YourAppleTechHelp 15 лет назад

    he is up in 81 now :D:D:D:D
    Great tutorials!!! (i'm on 56 or something :P)

  • @ujjwalmainali3927
    @ujjwalmainali3927 10 лет назад

    You may have noticed when the mouse pointer enters the Window "You entered the area" message doesn't pops up which had included in his mouseEntered method but instead " YOu moved the mouse" appears in the status bar which was defined in mouseMoved method. Does anyone know why is this happening?

    • @RaiZRiZ
      @RaiZRiZ 10 лет назад +3

      ujjwal mainali ***** It's not a typo its to do with precedence of java
      since the mouseMoved event has precedence over the mouseEntered event it's statement get overridden, the only way to get the "You entered the area" code to be written it is to clear the mouseMoved method i.e you can do this:
      public void mouseMoved(MouseEvent event){}
      Basically: mouseMoved > mouseEntered

    • @Handle_EzSubs
      @Handle_EzSubs 9 лет назад +1

      ***** Actually, I think it's because it already executed the mouseEntered method, and changed the status bar, but as you enter you also moved the mouse, so it quickly changes the text again. You know how fast computers moved these days, so we couldn't see the changes with our eyes.

  • @thenerdtroops
    @thenerdtroops 12 лет назад

    you should be knighted !
    sir Bucky Roberts of America.

  • @skyoceanfun
    @skyoceanfun 8 лет назад

    Sorry. Could not get the released and entered message.

  • @anurag8725
    @anurag8725 7 лет назад +2

    If you want to see coordinates with mouse movement
    public void mouseMoved(MouseEvent event){
    statusbar.setText(String.format("You're moving mouse at %d,%d", event.getX(),event.getY()));
    }

  • @yung_broccolini
    @yung_broccolini 13 лет назад

    7:08 EPIC VOICE CRACK!

  • @PacoRV
    @PacoRV 12 лет назад

    And what if I want to drag and image from one point to wherever inside the window? :D

  • @allaboutthementality1594
    @allaboutthementality1594 9 лет назад +2

    This wont work for me.

  • @techgeek9340
    @techgeek9340 15 лет назад

    Not trying to be rude. lol...but anywayz, i personal like it, The new boston doesn't really flood the sub. list. he just runs out of mins for the video. although he is a partner, i wouldn't like to watch a 45 min. long vid. lol.....but he's alright.

  • @Oonsk051
    @Oonsk051 9 лет назад

    thank you so so so so much

  • @zeloguy
    @zeloguy 11 лет назад

    This is not making a distinction between left-mouse click/release/drag and right mouse click/release/drag

  • @mymessage11
    @mymessage11 8 лет назад

    hi. something is wrong here. for mouseEntered although the coluor changed to blue but in the statusbar, this sentence appears : you moved the mouse and it should be you entered the area.someone explain it to me . tq

    • @idiotproductions708
      @idiotproductions708 8 лет назад

      The same happened for me. When the cursor enters the mousepanel, the listener is calling the mouseEntered method, but it is also simultaneously calling the mouse moved method as well. I think that is part of the reason why he changed the background color to red so you could see that both events are happening at the same time. The text output from mouseMoved is just showing up over the text output from mouseEntered. If we had not set any text output for the mouseMoved method and instead changed the color when the user moves the cursor, I would guess that the text output from mouseEntered would appear in the text field when you enter the mousepanel.

    • @pragneshrht
      @pragneshrht 8 лет назад +2

      If you want to see the "you entered the area" text in the status bar, keep the cursor steady in the area, press alt+tab and switch to the java window "the title"..

    • @mymessage11
      @mymessage11 8 лет назад +1

      Tq. Pragnesh

  • @pancakesimone
    @pancakesimone 12 лет назад

    @kripis0 *slaps face* its called the freaking launcher that launches the jar file... Please, you're welcome to use your brain at anytime

  • @janellogrono8379
    @janellogrono8379 11 лет назад

    why is it my mouse works only in statusbar area instead at the whole window

  • @lightbikevids1422
    @lightbikevids1422 11 лет назад

    can anybody explain the released mouse i never get that in my status bar thanks

  • @a_medley
    @a_medley 15 лет назад

    no... actionscript 4 isn't out, this is java... actionscript 4 is coming in 2010. Early 2010, as stated by adobe.

  • @Roger4313
    @Roger4313 12 лет назад

    DAFUQ mine has an error saying class is abstract can someone help me pls?

  • @MILCHMONSTER3D
    @MILCHMONSTER3D 11 лет назад

    did you eventually added the listeners to the statusbar?

  • @rockyscarlet
    @rockyscarlet 14 лет назад

    this was fun

  • @Trunks7890
    @Trunks7890 12 лет назад

    bucky could probably make a tutorial on that

  • @MrPillyg
    @MrPillyg 13 лет назад

    When I try this program, I get the error "selection does not contain a main type"

  • @RonanConnolly
    @RonanConnolly 11 лет назад +2

    Who's Hoss?

  • @howtostudent2
    @howtostudent2 11 лет назад

    Btw i commented on most video's to help people :)

  • @matiasvega4191
    @matiasvega4191 8 лет назад

    How could you get the program to output the pointer's location as you move it?

    • @burakmete5759
      @burakmete5759 8 лет назад

      event.getX()

    • @deviboi
      @deviboi 8 лет назад

      In the mouseMoved method put
      statusbar.setText(String.format("Position at X:%d Y:%d", event.getX(), event.getY()))

  • @physicsimpossible73
    @physicsimpossible73 10 лет назад +1

    I thought using the implements thing it would get all the events from MouseListener and MouseMotionListener. How come you had to write out all the methods?

    • @S3CR3AL
      @S3CR3AL 10 лет назад +1

      From what I understand from the previous tutorials (mainly the ActionListener tutorial # 53), is that the Listener classes are an abstract class with a few abstract methods within them. As a result of being an abstract class, any other class that wants to utilize its methods, will be required to overwrite any of the abstract methods. It just so happens that MouseListener has 4 classes that need to be overwritten, while MouseMotionListener has 2. I hope that helps!

    • @physicsimpossible73
      @physicsimpossible73 10 лет назад

      S3CR3AL Ok thanks

    • @lukecxu
      @lukecxu 10 лет назад +1

      S3CR3AL He didn't go over this in any of his tutorials but you are partially true.
      implements means you are using an interface which means that you have to override ALL of its method.
      @Epicnerd73 the reason why he has to rewrite everything is because he used implements not extends. extend = inheritance
      implement = interface (Think of interface as a template of methods that you MUST define, although the actual word template is used in java/c++ or something else)

    • @gudthing
      @gudthing 10 лет назад

      Luke Xu I was going to reply with the difference but you beat me to it. But yeah implement = interface - every method must be overwritten, extend is just standard inhertiance :)

  • @zki2
    @zki2 13 лет назад

    ahah you should add an event that when the mous enters the window a nasty website like lemon***** pops up and then send it to a firend xD

  • @norhanesmat7651
    @norhanesmat7651 11 лет назад

    please add more tutorial on different concept spacefic in Gui

  • @MrClinton82
    @MrClinton82 11 лет назад

    For some reason I had to use (java.awt.event.MouseEvent event) inorder for java to say that I implimented the methods.

    • @grymmatarmar
      @grymmatarmar 11 лет назад

      Then you haven't imported the java.awt.event if you think about it for a second :), I even tried to take away the java.awt.event and I had to do the same thing, that's why you import it. To make it easier to use the functions/classes

    • @MrClinton82
      @MrClinton82 11 лет назад

      Ya thats exactly what it was. I gave up before I really thought about it. Sucks when things are just to simple or easy for my mind to think of those first. Kind of like the first engine i rebuilt I later found out all I needed was gas.

    • @grymmatarmar
      @grymmatarmar 11 лет назад

      Yeah, I finished all these and watched 66 tutorials of the android development series, then I started another serie by Travis ( MyBringBack ) and I was sooo sure I was right about the coding part, after 1 hour of looking I restarted eclipse and it worked. Lol

  • @jeanrodrigues6249
    @jeanrodrigues6249 2 года назад

    Genil

  • @JunedHussain
    @JunedHussain 7 лет назад

    Where is mouse double clicked?