Adding a custom cursor to a panel

HI, I am making a game where i want clicking a radio button to change the cursor image. I have figured out how to create a custom cursor, and even change the current cursor to it. The problem im having is i want to change it while the program is running. I can say somthing like frame.addCursor(cursor) but that sets it permenantly. What i would like is to add it to a panel during run-time. If anyone knows how i would go abou this i would be gratefull.
Thanks

Do u mean, upon selecting the radio button, the cursor must be changed to the customized one?
If it is so,
u add the snippet in the itemStateChanged() event....of the radiobutton
i.e.,
public void itemStateChanged(ItemEvent ie)
if(ie.getStateChange() == ItemEvent.SELECTED)
myPanel.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(CursorImg, new Point
(0,0), "MyCursorImg"));
CursorImg - the image to display when the cursor is actived
new Point(0,0) - hotSpot
MyCursorImg - a localized description of the cursor, for Java Accessibility use
else
myPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

Similar Messages

  • How to load and increase size of a custom cursor on a certain monitor (1st or 2nd)?

    In my application I need to load a custom cursor, make it big and display it on the my second monitor in a dual monitor setup to let user click with an additional mouse. I found this thread able to solve the first 2 questions, however the cursor only changes within the VI panel. I had tried but couldn't get a handle to the second monitor, in face, not my primary one as well since I'm not familiar with winapi. I also want to restrict when the user can use the second mouse and only in the second monitor if possible. By the way I am using windows 7 64 bit with Labview 9 32 bit.
    Thanks,

    Ishi,
    More than likely, you are going to have to use Windows OS APIs for this. It sounds like you would like to integrate your program at the operating system level, and will have to make calls to Windows to accomplish this in the proper manner.  You can make calls to Windows in LabVIEW through several methods. Check out this example that sets the position of the cursor via a Call Library Function Node to the Windows SDK.  
    http://zone.ni.com/devzone/cda/epd/p/id/2315
    Cheers,
    Aaron
    National Instruments

  • Custom Painting in Swing Panels.

    I am trying to implement a custom painted panel on a JFrame. The panel performs custom painting in a separate thread. In additon, the frame also adds other swing panels (containing standard components) dynamically as per menu selection. I use box layout on frame to add / remove panels.
    The paint panel doesnt render properly whenever other panels are added or replaced. The paint panel is rendered only when no other are panels added to the frame.
    There is no problem however with adding / replacing components-only panels containing no custom painting.
    Please help me understand what I am missing. Any clues / suggestions most welcome
    sridhar

    Hi,
    You have problem only when adding custom painting JPanel to the same custom painting JPanel??? Are you layering your painting methods??? Like the most upper JPanel paints and then the childs??? What do you get for drawings??? Do you use invoque later method??? What is your priority on the Threads you are using???
    JRG

  • How to create custom cursor??

    I want to create a new cursor using Toolkit.createCustomCursor(Image,Point,String),
    but Image can only accept .gif,.jpg file,it cannot know .cur,
    so if image's background's color is not equal to panel's background's,
    the cursor that show in the panel looks like malformed rectangle.
    so is there any better way to create a custom cursor??

    Create the cursor as a transparent gif if you need it to be transparent.
    nes

  • Blink custom cursor

    Hi to all.
    I'm having problems changing the look of the cursor of my app. Sometimes, when the user let the mouse pointer on certain areas of the principal panel, the cursor look must change for a custom look that I have created. The problem is that when I change the aspect of the system cursor, for my custom cursor, it start to blink sometimes, and it stays blinking when I move it on areas where the cursor have to have this custom look. I'm using a code like this.
    All this is into a class that extends from JPane.
    public void paintComponent(Graphics g) {
            Toolkit toolkit = Toolkit.getDefaultToolkit();
            Image image = toolkit.getImage("CrearTransiciones.gif");
            Point hotSpot = new Point(15, 15);
            Cursor cursor = toolkit.createCustomCursor(image, hotSpot, "CrearTransiciones");
            if (cursorIsOver().equals(ZoneOver.Zone1)) {
                setCursor(cursor);
            } else {
               if (cursorIsOver().equals(ZoneOver.Zone2)) {
                   setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
               } else {
                  if (cursorIsOver().equals(ZoneOver.Zone3)) {
                      setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
    }I have also proved to set the hotSpot into the (0, 0) point, but I'm still having the same problem.
    Someone knows what I have to do to avoid the annoying blinking?
    Thanks for read.

    I think the problem may be the fact that you are changing the cursor in paintComponent() regardless of what the cursor currently is; I would change the code to check if the cursor is already the cursor you want it to be; if so then skip the setCursor().
    You are fetching the image every time a paintComponent() call is made. That is not very efficient. I would fetch the image once (in the constructor perhaps?), store the cursor in a member variable and just use it whenever you need it. The rule is that a paint() or paintComponent() call should take as little time as possible, loading and decoding an image from disk is not exactly a fast action.
    Also, you are aware that you can do "else if" in stead of nesting the if statements like that?

  • Custom cursor

    I thought this was simple. I need some custom cursors.
    Created the cursor as a movieclip object on a new layer's first
    frame and on its actions I have
    onCLipEvent(load) {
    this.startDrag();
    when the movie loads, the custom cursor moves alright except
    its some distance from the standard cursor so its of course not
    working as expected and if I hide the cursor it will be unusable.
    Tried setting the movieclips _x to mouse x and that did not help
    either. What amd I missing?

    jgn2006 wrote:
    > Thanks Erick and kglad for your quick responses. Erick
    your suggestion seems
    > to work very well. Better than using a mouse listener. I
    had tried adding
    > that to a mouse listener and there seems to be a split
    second of delay between
    > mouse movement and my custom cursor.
    Peter already said.. using the global function
    updateAfterEvent he will
    work like you wants. The problem is caused by FPS, the
    updateAfterEvent
    function updates the coordinates of the mc independently of
    FPS.
    //Mouse.hide();
    mcCursor.onMouseMove = function():Void{
    this._x = _xmouse;
    this._y = _ymouse;
    updateAfterEvent();
    Regards,
    Erick Souza
    www.ericksouza.com

  • Error while adding a custom field with Input help via AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running  and Autopopulating seocnd field while I am testing it
    While adding second field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Secondly,not getting getter and setter methods for the attrributes in BTAdminI.
    Last,please tell me if i create zhelp and activate it,would it automatically appear in the list on AETwhile assiging it to input field?
    Please help me out.Kindly be detailed as I am new to SAP CRM.
    Thanks,
    Shivani

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

  • Custom cursor using image gets resized bigger

    I have created a custom cursor using the following code:
    ClassLoader cl = this.getClass().getClassLoader();     
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    Cursor Custom_Cursor = tk.createCustomCursor(im,new Point(9,9),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The cursor is loaded and it works, however - the image I use for the cursor is resized so it gets too big. Any clues on why this happens?
    btw; draftGrid is one of my own classes that extends JComponent.
    - bjorn

    Thanks for your replies guys.
    I tried your code KPSeal, and it works in resizing the cursor image back to its original size. However, a gray square of size 32,32 (which is returned by getBestCursorSize()) is shown round the cursor.
    Here is the updated code (yours hade some minor bugs)
    Image im = tk.getImage( cl.getResource("images/wallcursor.gif"));
    try {
           tracker.addImage(im, 0 );
           tracker.waitForID(0);
    } catch( InterruptedException ie ) {
           ie.printStackTrace();
    int w = im.getWidth(this);
    int h = im.getHeight(this);
    int pw = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).width;
    int ph = Toolkit.getDefaultToolkit().getBestCursorSize(w, h).height;
    System.out.println("w="+w+", h="+h+" - pw="+pw+", ph="+ph);
    Image cim = createImage(pw, ph);
    cim.getGraphics().drawImage(im,0,0, this);                     
    Cursor Custom_Cursor = tk.createCustomCursor(cim,new Point(0,0),"Drawing wall");
    draftGrid.setCursor( Custom_Cursor );The System.out.println statement prints: w=18, h=13 - pw=32, ph=32
    If I try to do the createImage with w and h instead of pw and ph the same gray square (32,32) is created, and in addition the cursor's size is too big which was the probem to begin with ...
    - bjorn

  • Custom cursor using startDrag

    Hello everyone,
    I have a movieclip following my mouse to act as a custom cursor.
    I am using startDrag on the movie clip and mouse.hide()
    What I am trying to resolve is the following:
    I have several hidden simple button objects in the background of my flash movie. ( I am using these to detect when the user has the mouse in certain areas of the flash movie)
    When i go to move over these simple buttons, my custom cursor movieclip stops following the mouse cursor.  Normally my cursor would also then change to the Hand cursor, but i disabled that.
    Can anyone think of any method or hack that would make this work for me?  I would like my custom cursor following the mouse pointer at all times even when hovering over a simple button.
    thanks in advance.

    The cursor changes to hand cursor yet?
    When you say "single button Several hidden objects", the number is?

  • How to install custom XMP Get Info Panels in Adobe Bridge CC

    Adobe changed their way they store the custom XMP Get Info Panels in Adobe Bridge CC. Check out this blog to see how you can install the XMP Get Info Panels that you used in Adobe Bridge CS6 in Adobe Bridge CC:
    http://www.databasepublish.com/blog/installing-custom-metadata-panels-and-get-info-panels- adobe-bridge-cc

    Check your Bridge preferences.  It seems that you have the "Don't process images larger than…" option set to a lower amount than some of your files.
    So, don't blame it on Bridge, but on the user who neglects that setting. 

  • Adding a custom webpart to webpart page not a safe control issue

    When I am adding a custom web part to web part page I am getting below error as a popup. Plz help if any body resolved the same issue.
    Unable to add selected web part(s). (Web Part Name): A Web Part or Web Form Control on this Page cannot be displayed or imported.
    The type could not be found or it is not registered as safe
    Regards.
    Avinash.
    Avinash

    Hi,
    Here you go. This should help you.
    ow many times have you guys faced an issue like this ?"The type could not be found or it is not registered as safe." .To resolve this, make sure that you add safe controls around your web part assembly in web.config.
    <SafeControls>
    < SafeControl Assembly=”WebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdeddf23232″ Namespace=”Mywebpart.WebPart” TypeName=”*” Safe=”True” />
    < /SafeControls>
    The above ensure that your web part code is secured and wont let any anonymous users to access the web part.
    Happy SharePointing ;-)
    http://www.c-sharpcorner.com/Blogs/15024/
    Please remember to click 'Mark as Answer' on the answer if it helps you

  • Custom cursor is too slow in FULL_SCREEN_INTERACTIVE

    My custom cursor is fast in window mode (even maximized) but not in fullscreen where it is really slow.
    Is there a solution to this?

    Dear Rob,
    Thanks for your answer.
    I have put together a simple test case (see attached zip file) and the custom cursor is still "too slow to be usable" in fullscreen mode. Run it and see that the cursor is fast in window mode. Then hit ctrl+enter to go into fullscreen and see how slow the cursor becomes.
    Code:
    package
    import flash.events.MouseEvent;
    import flash.events.KeyboardEvent;
    import flash.ui.Mouse;
    import flash.ui.Keyboard;
    import flash.display.StageDisplayState;
    import flash.display.MovieClip;
    public class Main extends MovieClip
    private var _mousePointer:MousePointer;
    public function Main()
    super();
    Mouse.hide();
    _mousePointer = new MousePointer();
    addChild(_mousePointer);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardDown);
    stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoved);
    private function goFullscreen(fullscreen:Boolean)
    if(fullscreen)
    stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
    else
    stage.displayState = StageDisplayState.NORMAL;
    private function onMouseMoved(evt:MouseEvent)
    _mousePointer.x = mouseX;
    _mousePointer.y = mouseY;
    evt.updateAfterEvent();
    private function onKeyboardDown(evt:KeyboardEvent)
    if(evt.controlKey && evt.keyCode == Keyboard.ENTER)
    goFullscreen(stage.displayState == StageDisplayState.NORMAL);

  • I added a custom ringtone . Then later I tried to add another three set  but now after sync . Am not able to get rid of the first one... It's still there as my custom ringtone. But my iPhone in iTunes shows all four... But the phone shows only one...?

    I added a custom ringtone . Then later I tried to add another three set  but now after sync . Am not able to get rid of the first one... It's still there as my custom ringtone. But my iPhone in iTunes shows all four... But the phone shows only one...?

    Paul--you are a life-saver!! Worked great. I did have to look around to make sure I was getting 4.9 instead of 4.7 (even when the file was named 4.9 at techspot.com), but I finally got the right file, did the install as you suggested, and everything is now fine. One note, though, that I haven't seen mentioned in any of this thread: when I first tried to open up iTunes after getting back to 4.9, the following message appeared: "The file iTunes Library.itl cannot be read because it was created by a newer version of iTunes." I merely went to the old .itl file that was created when I did the update to iTunes 5, renamed it, moved it over to my now new 4.9, and iTunes opened fine. My library was a few days out of date, because of the few days' lag from the time I did the iTunes update, but that was easily taken care of, and everything's now working fine. Thanks again!!!

  • Custom Cursor and Drag Image in 1.4 DnD

    What is the proper way to provide a custom cursor and drag image in 1.4 DnD? Say we initiate the drag on a component that supports data transfer (such as a JTree).

    Well, this is strange. My app was locking up (100% CPU) when using DND from windows Explorer.
    I noticed that another part of the same appliction was working perfictly. The difference: JFrame .vs. JDialog. I switched the offending JDialog to a JFrame and all works perfictly now!
    java version "1.4.0"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
    Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
    I would like to switch back at some point, but my g.setXORMode() problem is a much bigger issue for us. (That is, once you enter the XOR mode, you can not go back!)

  • CS6 - Custom Cursor & Button's icon

    I am trying to display a custom cursor when mouse is moving on a button which has icon.
    But the button's icon is always in front of my cursor image.
    How to make my cursor image on top?
    Belows is my code. Please tell me what's wrong.
    Thank you!
    <mx:Application... creationComplete = "init()>
    private var MyCursor:Shape = new Shape();
    private function init():void{
        // draw custom cursor
        MyCursor.graphics.clear();
        MyCursor.graphics.lineStyle(2, 0xFF0000, 1,true);
        MyCursor.graphics.drawCircle(0,0,6);
        MyCursor.graphics.moveTo(-3,-3);
        MyCursor.graphics.lineTo(4,4);
        MyCursor.visible = false;
        // add to the layer
        CursorLayer.addChild(MyCursor);
    private function ShowCustomCursor(e: MouseEvent):void
        Mouse.hide();
        MyCursor.x = e.stageX;
        MyCursor.y = e.stageY;
        MyCursor.visible = true;
    private funtion HideCustomCursor(e:MouseEvent):void
        Mouse.show();
        MyCursor.visible = false;
    <mx:UIComponent id = "CursorLayer" x ="0' y="0" width ="1000" height = "1000" blendMode="layer">
    <mx:Button id="btnTest" x="50" y="5" width="28" height="20" buttonMode="true"
    icon="@Embed(source='assets/btnTest.png')"
    mouseFocusEnabled="true"
    mouseMove="ShowCustomCursor(event)"
    mouseOut="HideCustomCursor(event)"
    tabEnabled="false"
    useHandCursor="true"/>

    that's because your cursor is sporadically moving over your interactive objects interfering with their mouseevents.
    to remedy, disable the mouseEnabled property of your cursor.

Maybe you are looking for