Dragging a JLable makes it bounce?

I'm not sure if this is the best forum for this topic, but I think it's a swing problem more than an Event problem. I have JLabel that I want to drag around on top of a JPanel. But whenever I drag the component it doesn't move with the mouse, it bounces back and forth. Here is the code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestTab extends JPanel{
     JLabel j = new JLabel("Test");
     int X = 20;
     int Y = 20;
     public TestTab(){
          j.addMouseMotionListener(new DragMouse());
          this.add(j);
     public void paintComponent(Graphics     g) {
          super.paintComponent(g);
          j.setLocation(X,Y);
     class DragMouse implements MouseMotionListener{
          public void mousePressed(MouseEvent e){
               System.out.println(e.getSource());
          public void mouseDragged(MouseEvent e){
               X = e.getX();
               Y = e.getY();
               System.out.println(X + ", " + Y);
               repaint();
          public void     mouseMoved(MouseEvent e){}     // ignore these     events
}Here's the app that uses it.
import javax.swing.*;
import java.awt.event.*;
public class Test extends JFrame{
     public static void main(String args[]) {
          new Test().setVisible(true);
     public Test(){
          // Window Properties
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          setBounds((screenSize.width-600)/2, (screenSize.height-450)/2, 300, 450);
          setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
          setResizable(false);
          this.setContentPane(new TestTab());
}As you can see I print out the coordinate, and here's what is spits out.
65, 89
103, 233
66, 90
104, 235
67, 90
105, 237
72, 95
106, 239
73, 97
107, 239
74, 99
111, 243
74, 100
112, 245
75, 100
113, 247
79, 104
115, 253
80, 104
115, 252
Thanks for any insight into this problem.

Thank you for that tip. I was able to get it to work by doing something similar.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestTab extends JPanel{
     MouseEvent pressed;
     Point location;
     JLabel j = new JLabel("Test");
     int X = 20;
     int Y = 20;
     public TestTab(){
          j.addMouseListener(new DragMouse());
          j.addMouseMotionListener(new DragMouse());
          this.add(j);
     public void paintComponent(Graphics g) {
          super.paintComponent(g);
          j.setLocation(X,Y);
     class DragMouse implements MouseListener, MouseMotionListener{
          public void mousePressed(MouseEvent me){
               pressed = me;
          public void mouseDragged(MouseEvent me){
               location = j.getLocation(location);
               X = location.x - pressed.getX() + me.getX();
               Y = location.y - pressed.getY() + me.getY();
               System.out.println(X + ", " + Y);
               repaint();               
          public void mouseMoved(MouseEvent e){}
          public void mouseExited(MouseEvent e){}
          public void mouseEntered(MouseEvent e){}
          public void mouseReleased(MouseEvent e){}
          public void mouseClicked(MouseEvent e){}
}

Similar Messages

  • How do I use Adaptive Limiter to make sure bounces are same volume?

    Hi,
    I've been making ear training exercises for myself - you can understand what here:
    http://discussions.apple.com/thread.jspa?threadID=490846&tstart=0
    Here's what I need to do - and don't know how:
    I want all bounced exercises to play at the same volume.
    Each exercise has two MIDI regions. The first region (Region #1) plays at the begining of all exercises. When I look at the Output track when Region #1 plays, it is at 0.2 DB - no clipping. However, Region #2 clips in varying degrees depending on what octave an interval is being played at. For instance, a C and E played together around C1 doesn't clip - but transposed to C5 or C6 it clips anywhere from 3.7 to 4.6. I can't just lower the output volume before it clips - because it's important the Region #1 stays the same volume-wise on all of the exercises.
    Some people have said just add an adaptive limiter to the Output 1-2 track... but how do I set it?
    Any suggestions? Anyone understand this?? It's hard to explain on this end...
    Thanks.

    you don't use adaptive limiter to make sure bounces are the same volume.
    that is not the function of the adaptive limiter.
    the limiter puts a ceiling on the signal and optionally raises the gain. You'd use this on certain instruments that are known to produce loud peaks, such as Bass Guitar and Vocal,
    It is used as the last plugin in the chain on the master fader when mixing something down, to prevent the mix from peaking.
    IMO, the logic limiter doesn't destroy anything unless the mix itself has something wrong with it.
    A lot of people reach for limiter when what their ears are really looking for is to multiband compress.
    Your solution is to use a COMPRESSOR (not the multiband compressor, just the simple Logic compressor).
    Do NOT use the default setting of the logic compressor in your case, because it defaults with its 'auto Gain' turned on which will raise your volume (a lot).
    Put a compressor as the first plugin in all of your piano channels, or into a Bus, and set all your piano tracks to output to the bus with the compessor on it.
    Settings:
    THRESHOLD : -10
    ATTACK : 0 (play with it, pianos feel good with a low one,
    could try 15ms or less)
    DECAY : play with it, I'd use 50ms with a Piano track
    AUTO GAIN : off
    GAIN : +4
    RATIO : try 12.0
    This setting will attenuate anything above -10 and will raise the gain up to a healthy level to compensate.
    Anything below -10 won't be touched.
    Since the compressor will 'squash' your signal slightly,
    some frequencies will appear louder to the ear after the piano is compressed. So just AFTER the compressor on the same track, put a Logic Channel EQ and conservatively pull down some of the freq ranges to bring them back to normal.
    And that's it.
    a tip: When working in logic, no matter what the project, when it's time to mixdown put a COMPRESSOR on every single channel as the first plugin. Then play with plugins, etc.
    I do have many issues with Logic's workflow, but the dynamics plugins IMO are very good.

  • Make picture bounce in sync with music

    http://www.5min.com/Video/How-to-Make-Stuff-Bounce-to-Music---Motion-3-162040947
    I need a step-by-step instruction on how to do this with After Effects or any Adobe software that you might recommend.
    I've been browsing around the net and can't find a clear answer. The keyframes thingy are too complicated for me so I need a simple solution like the one in the video. I am using Windows 7 so I can't buy the Apple software. Can After Effects do this or should I use Premiere Pro? I'm relatively new at video and audio editing. I want the picture to bounce in sync with the drum beat or cymbals like every 4 seconds or so. Not only that, I want to control the direction to where it bounces to - upper left, upper right, center, etc.

    If keyframes are too complex for you After Effects isn't your tool of choice. I've got 10 year old cub scouts that can use AE. I'd take the bull by the horns and dive into the basics by following this link. 
    Once you have a little more confidence you can run through a tutorial, any tutorial, on using Audio Keyframes. The procedure is very easy. It goes something like this:
    Put the audio in the timeline.
    Use Animate>Keyframe Assistant>Convert Audio to Keyframes to create a null named Audio Amplitude and effects sliders named Left, Right and Both
    Put the image you want to control in the timeline and press S to reveal the scale property.
    Alt click or Option click on the stopwatch to begin an expression.
    Use the pickwhip to connect scale to the Both Channels slider.
    Open up the graph editor, select the Audio Amplitude Both Channels Slider property to reveal he range of the levels you want to use for your animation.
    In this case I want to use 25 to 60 so anything below 25 is 50% scale and anything above 40 is 100% scale
    Modify the expression created in step 5 to look like this:
    temp = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
    s = ease(temp, 25, 40, 50, 100);
    [s, s]
    You're done.
    Do a Google Search for Controlling a layer with audio in After Effects and you'll find dozens of tutorials.

  • RAID wont work.. meaning i cant drag disks to make a raid

    Hey.. is there something i dont know about? I just put 2 400gb drives in bay #3 and bay #4, and went to disk utility.. they show up, but when i click raid, i cant drag them together?

    Did you partition and format them?
    1. Open Disk Utility in your Utilities folder.
    2. After DU loads select your hard drive (this is the entry with the mfgr.'s ID and size) from the left side list. Click on the Partition tab in the DU main window.
    3. Set the number of partitions from the dropdown menu (use 1 partition unless you wish to make more.) Set the format type to Mac OS Extended (Journaled.) Click on the Partition button and wait until the volume(s) mount on the Desktop.
    4. Select the volume you just created (this is the sub-entry under the drive entry) from the left side list. Click on the Erase tab in the DU main window.
    5. Click on the Erase button.
    Repeat above for second drive.
    Note that if you have already installed OS X on one of the drives you cannot create a RAID. The RAID must be created when both drives are empty.

  • How to implement drag&move JLable?

    hi,
    I am new to swing and pardon me if I ask some real simple questions.
    Using swing, i want to be able to drag&move components (like JLable/JTextField)
    in my content pane and then get components' precise postions (in X, Y coordinates, or
    something like that). It is like moving puzzle pieces around.
    PLS note: I want to MOVE the WHOLE component, NOT only the text within the component.
    Does swing support this internally? How can I do that? Any comments/suggestions/sample code
    are truly welcome.
    Thanks a lot.
    JK

    Do the way like DnD text for Label, except you put the entire JLabel component as Transferable data object.
    - The DropTarget will get the component and add it to "parent" ( "parent" is the container component that you like add the draged JLabel component)
    - The DragSource will get the endDrop notification and call its "parent" to delete the JLabel component dragged.
    You must deal with the "parent" container to add/delete the component for this special DnD component.
    There are no default Swing DnD support for it.

  • Firefox becomes semi-unresponsive and freezes when a tab is dragged out to make it a new window.

    Basically I may have 10 or so tabs open and wish to drag one of them out of the tab bar to make it form a new window. However when I do this it takes a second or two before the new window appears, and when it does it is semi-unresponsive.
    I cannot exit it as when I hover over the red "x" nothing happens and I can't click it. I can't switch between firefox windows properly (it just keeps freezing). I usually end up killing firefox.exe in task manager.
    My list of addons are:
    2007 Microsoft Office System 12.0.4518.1014
    Adobe Acrobat 10.1.0.534
    Google Update 1.3.21.57
    iTunes Application Detector 1.0.1.1
    Microsoft Windows Media Player Firefox Plugin 1.0.0.8
    Pando Web Plugin 1.0.0.1
    QuickTime Plug-in 7.6.9 7.6.9.0
    Shockwave Flash 10.3.181.26
    I have also done the common and fast computer, fast connection tweaks on this website:
    http://codebetter.com/darrellnorton/2005/01/28/speeding-up-firefox-the-right-way/
    Thanks in advance for your help!

    That is the default action when you open a new tab. There are extensions that you can install to change it from a blank page to whatever you want.
    New Tab Homepage extension: <br />
    https://addons.mozilla.org/en-US/firefox/addon/777 <br />
    and <br />
    NewTabURL extension: <br />
    https://addons.mozilla.org/firefox/2221/

  • Dragging from iPhoto makes the screen go all weird

    Since I updated to Lion, there's a problem I have when using iPhoto in which when dragging from iPhoto onto the desktop (or anywhere else outside of iPhoto) the portions of the screen outside of iPhoto go all jittery, and are filled with random jumbled up, noisy images (which aren't always the same.) Someoe else told me that they have the same problem, I'm just wondering, how can i fix it.
    Thanks

    The screen dims shortly before auto-lock (sleep mode) engages. To change the interval:
    Settings > General > Auto-Lock > select the interval you want
    Remember, the longer the delay to dim the screen, the shorter the battery life.

  • Logc Pro X - TIME ruler  - selecting exact time for bounce.

    I often need to make my bounce exactly :30 or :60 for radio and TV work. In LP9 I was able to view the TIME ruler, without making any changes to project settings, and select the time I needed (setting the locators for the bounce).
    In LPX it seems that the to see a time scale (in musical mode) i need to view the secondary ruler, yet it is not selectable to set the locators to exactly :30 or :60 or whatever, I had success by switching the project settings to TIME, then setting the locators, then going back to musical. But that sure is a lot of steps.
    AND I hate to lose the functionality of my audio bounced files not having the tempo information embedded because I am in TIME mode.
    Need a quick workflow solution. Head scratcher, Any thoughts?
    LOVE LOGIC X
    Needs CLIP GAIN!

    The issue is one of workflow. I realize that it is in settings. The fastest way I can find to select :30 exactly is to use the project settings key command "option-P" and under general, uncheck "Use musical grid", putting LOGIC in TIME mode.
    Then highlite the primary ruler to :30. Then bounce.
    Seems fine. But  bouncing in TIME mode does not record the tempo information in the audio file, which can be a drag. So to add tempo information you have to switch back to musical mode. MULTIPLE STEPS.
    LPX seems to have added steps to what was once a simple swipe on a second ruler that could be selected, and then hit bounce.
    So I was wondering if anyone had found a better workflow solution.

  • Click and Drag feature to resize brush in PS 5

    Besides using the bracket keys to resize brushes, you are supposed to be able to hold down the Alt and Control key to drag sideways to make a brush larger or up and down to make it softer. This is on Windows.
    For some reason, when I do this command, my cursor changes to moving a selection and leaving a copy.
    When I hold down just the Alt key, I get the eye dropper tool and when I hold down just the Control Key, I get the move - four way arrow.
    I must have changed something in the keyboard shortcuts, but I don't see the option to change that command back. My Brush Resize shortcuts still work the the two bracket keys.
    Any help would be appreciated.
    M. Jackson

    Okay. I wasn't using the right mouse click as directed.
    http://adobephotoshopsecrets.blogspot.com/2012/01/dynamically-resize-brush-in-photoshop.ht ml
    It seems to work fine with just the Alt-Right Mouse drag and no need for the Control key?
    I was trying to program my Art Pen to use the commands on the front toggle button.
    Thanks to all.
    M. Jackson

  • How can I make my old Homepage take me directly to my new iWeb site???

    Is there I way I can have it so people don't first have to "land on" a .Mac homepage and then push a "button" to get to the new iWeb site?
    It would be GREAT if anyone knew a way to do this... I am so excited with my new site, but need it to replace my old .Mac homepage (or at least make it so people are automatically redirected to the new iWeb page)
    Anyone have some ideas??
    Max

    They should go all back into the green Purchased playlist when you make another purchase.
    How can I get it back into a playlist other than dragging each song
    Make a Smart playlist and set it to Kind contains Purchased, then you won't have to drag any songs.
    I have over 3500 purchased
    Really?
    3500 purchased songs?

  • How can I make my old purchases a playlist on my new computer?

    I just changed computers and have all of my music, however, my purchased music is showing in my main library where as it used to show as a playlist as well. How can I get it back into a playlist other than dragging each song...I have over 3500 purchased. I have tried syncing purchaes from my I-pod but it does not put it into a playlist. Help!!

    They should go all back into the green Purchased playlist when you make another purchase.
    How can I get it back into a playlist other than dragging each song
    Make a Smart playlist and set it to Kind contains Purchased, then you won't have to drag any songs.
    I have over 3500 purchased
    Really?
    3500 purchased songs?

  • How do I make a certain sized partition in Lion? (When I put 40.00 GB, it keeps splitting my hard drive in half)

    I wanted to make a partition like this: but when I click apply, the size keeps going back to half of my hard drive. How do I get it to stay at 40.00 GB? It also shows this when I click apply, so it doesn't work anyway. How do I fix that?

    You need to Drag the one partition Up from the bottom right hand corner (kind of a set of 45° line) until you get to the 40GB mark. Just typing in 40GB won't do it.
    EDIT:
    As to is failing first Verify the drive and Repair it, if needed. Once you drag up to make the main partition smaller by 40GB Click Apply. Then once that is done click the Plus sign to make that 40GB Un-Alocated space into another drive/partition. It is a 2 Step process. Step one making the main partition smaller. Step two creating the second partition/drive.

  • I have a seagate 1tb hard drive and a 16gb memory stick, how do i transfer avi files from one to another as the click drag and drop wont work, please help?

    i have a seagate 1tb hard drive and a 16gb memory stick, how do i transfer avi files from one to another as the click drag and drop wont work, please help?

    Greetings,
    What happens when you drag it?
    Make sure the drive you are moving the files to has enough available space to receive the file:
    Click on the movie file and go to File >  Get Info and note the "size"
    Check the drive to which you are moving the file to make sure it has enough available space: https://idisk.me.com/madisonfile-Public/web/finder-drive-available-space-and-for mat.html
    Also note the format of the drive you are copying too.  If it is not Mac OS Extended or FAT (not recommended unless you are taking it to a windows computer) then that may be the issue.
    Hope that helps.

  • Unable to drag and drop album cover art work in Itunes 10 64-bit

    I just recently installed Itunes 10 64-bit version and transfered all of my music. I wanted to add some art work to some game tracks but I can no longer drag and drop.

    Make sure your windows userid has full control and ownership over the entire music folder. Check the box to apply this to subcontainers (aka subfolders)
    This webpage has directions
    http://www.ilounge.com/index.php/articles/comments/copying-music-from-ipod-to-co mputer/P2/
    You need to restart itunes to read hte new permission settings.

  • Drag and drop between two pdf documents

    I've been using Acrobat since version 4, and (generally) love it.  However, I just re-installed it on a new computer, and seem to have an issue.
    In the past, when I had two PDF files open, I could select pages in the thumbnail pane in Document 1, and drag'n'drop them into the thumbnail pane in Doc 2.  I can no longer do that.  I'm sure it's just a setting somewhere, but i can't seem to find it.
    Any help would be appreciated.
    Thanks in advance!

    Before dragging the pages make sure you're zoomed out enough so that the
    entire page is visible. Otherwise you'll be dragging the zoom box around
    instead of the entire page.
    On Mon, Apr 6, 2015 at 12:58 PM, Test Screen Name <[email protected]>

Maybe you are looking for