Custom Cursor bigger than 32x32

Hi,
I am looking for a way to make a custom cursor bigger than 32x32 pixels of getBestCursorSize() ?
This is a urgent problem, pls help me.
Hqtrung

This is another way
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class GUIa extends JFrame 
public GUIa()
     super("Grafritare");
     setBounds(0,0,700,400);
     addWindowListener(new WindowAdapter()
     {      public void windowClosing(WindowEvent ev)
               dispose();
               System.exit(0);
     EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
     eq.push(new MyEventQueue(this));
     setVisible(true);
public class MyEventQueue extends EventQueue
     JWindow   w1;
     JFrame    f1;
public MyEventQueue(JFrame f)
     super();
     f1 = f;
     w1 = new JWindow(f);
     w1.setBounds(-99,0,32,32);
     w1.getContentPane().setBackground(Color.red);     
     w1.setVisible(true);
     Toolkit      tk = Toolkit.getDefaultToolkit();
     Cursor myCursor = tk.createCustomCursor(tk.createImage(""),new Point(0,0),"");
     f1.setCursor(myCursor);
     w1.setCursor(myCursor);
protected void dispatchEvent(AWTEvent event)
     if (event.getID() == MouseEvent.MOUSE_EXITED)
          MouseEvent m = (MouseEvent)event;
          if (m.getSource() == f1)
               if (m.getX() > f1.getWidth()-7)  w1.setVisible(false);
               if (m.getY() > f1.getHeight()-6) w1.setVisible(false);
               if (m.getX() < 4)  w1.setVisible(false);
               if (m.getY() < 23) w1.setVisible(false);
     if (event.getID() == MouseEvent.MOUSE_MOVED)
          MouseEvent m = (MouseEvent)event;
          if (m.getSource() == f1) w1.setLocation(f1.getX()+m.getX()+1,f1.getY()+m.getY()+1);     
          if (m.getSource() == w1) w1.setLocation(w1.getX()+m.getX(),w1.getY()+m.getY());     
          if (!f1.getBounds().contains(w1.getLocation()))
               if (w1.isVisible()) w1.setVisible(false);
          else if (!w1.isVisible()) w1.setVisible(true);
     super.dispatchEvent(event);
public static void main( String[] args)
     new GUIa();
}Noah

Similar Messages

  • Linux - The custom cursor is looking bad

    Creating a custom cursor using png 32x32 images. The images are displaying perfect as a cursor on Windows and Mac but, on Linux the image is bad. Below I am pasting code to test the things by using some png image.
    import java.awt.*;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.net.URL;
    import javax.swing.*;
    public class UserCursor {
         private void initComponents() {
              JFrame jf = new JFrame("Cursor Test");
              jf.setLayout(new BorderLayout());
              final JButton jb = new JButton("Change Cursor");
              jf.getContentPane().add(jb,BorderLayout.NORTH);
              jf.setSize(200, 200);
              jf.setVisible(true);
              final Cursor cur = createCursor();
              jb.addMouseListener(new MouseAdapter(){
                   public void mouseEntered(MouseEvent arg0) {
                        jb.setCursor(cur);
         private Cursor createCursor() {
              Cursor userCursor=null;
              Toolkit toolkit = Toolkit.getDefaultToolkit();
              URL icon = getClass().getResource("images/someImage.png");
              Image image = new ImageIcon(icon).getImage();
              userCursor = toolkit.createCustomCursor(image, new Point(0, 0), "My Cursor");
              return userCursor;
         public static void main(String args[])
              UserCursor uc= new UserCursor();
              uc.initComponents();
    }

    Kanni wrote:
    Toolkit.getBestCursorSize(....)
    I tried using above suggestion to solve my cursor problem. It didn't work for me.
    ThanksSo how did you try this. Did you use the result of this function to choose a suitable cursor glyph? Did you use it to scale the original using an Affine Transformation?
    How can anyone give any further help if the only feedback you provide is "it didn't work" .

  • 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

  • Change custom cursor size

    does anybody know how to change a custom cursor's size? we have created a custom cursor using the toolkit, but we can't seem to resize it so that the cursor is bigger.

    Read the API on java.awt.Toolkit
    createCustomCursor() creates a cursor of whatever size the system can handle. Generally, this is 32x32 for Windoze systems. toolkit.getBestCursorSize() will return a closest supported size for some (w,h) suggestion. You have to draw your image on a BufferedImage using the graphics object, then submit the BufferedImage object to toolkit.createCustomCursor()
    Jason

  • I am having a problem with my cs6 running very slow and when i save i am getting an error message that says, "This document is bigger than 2 gb (the file may not be read correctly by some TIFF viewers.) please help

    I am having a problem with my cs6 running very slow and when i save i am getting an error message that says, "This document is bigger than 2 gb (the file may not be read correctly by some TIFF viewers.) please help

    wen6275,
    It looks like you're actually using a camera or phone to take a photo of your monitor.
    That's not what is commonly known as a "screen shot". 
    It looks like you're on a Mac.  Hitting Command+Shift+3 places a capture of the contents of your entire monitor on your Desktop; hitting Command+Shift+4 will give you a cross-hairs cursor for you to select just the portion you want to capture.
    I'm mentioning this because I fear I'm not construing your original post correctly when you type "I am working with a large files [sic], currently it has 149 layers, all of which are high resolution photographs", so I'm wondering if there's some similar use of your own idiosyncratic nomenclature in your description of your troublesome file.
    Perhaps I'm just having a major senior moment myself, but I'm utterly unable to imagine such a file.  Would you mind elaborating?

  • PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?       /Users/jorisneyt/Desktop/Schermafbeelding 2014-11-07 om 10.04.59.png

    PS CS6 on the mac pro: the bruch in hard and soft is the circle of the bruch bigger than then the effect. How can i bring it to normale?

    Go to System Preferences>Accessibility>Display and the set the Cursor Size to Normal

  • 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

  • I used scripting brigde to add a movie that has size bigger than 5GB, exactly after two minutes iTunes return a failed, but the processing of the file is actually added to iTunes Library successfully. The copying take more than 5 minutes to complete. Why?

    I used scripting brigde to add a movie that has size bigger than 5GB, exactly after two minutes iTunes return a failed, but the processing of the file is actually added to iTunes Library successfully. The copying take more than 5 minutes to complete. Why the iTunes Scripting Brigde returned failed when it is actually success? It occurred exactly 2 minutes after submit the request to Scripting Brigde. Is this 2 minutes related to the Apple Event time out? if it does, how do I get around this problem? thx

    I can tell you that this is some of the absolutely worst customer service I have ever dealt with. I found out from a store employee that when they are really busy with calls, they have third party companies taking overflow calls. One of those companies is Xerox. What can a Xerox call center rep possibly be able to authorize on a Verizon account?  I'm Sure there is a ton of misinformation out there due to this. They don't note the accounts properly or so everyone can see them. I have been transferred before and have asked if they work for Verizon or a third party also and was refused an answer so, apparently they aren't required to disclose that information. I spent a long time in the store on my last visit and it's not just customers that get the runaround. It happens to the store employees as well and it's beyond frustrating.

  • Biztalk AS2 encryption error for file bigger than 100MB

    I am getting following error when I am trying to receive file bigger than 100 MB. I was getting same error when I was trying file bigger than 5MB and I applied windows CU5. Now I can receive big file (I tested till 60 MB). New file which is coming is 110MB
    and we start getting this error. 
    Can somebody help me to figure out this issue.
    I am using Biztalk 2010 with windows 2008 server
    A message received by adapter "HTTP" on receive location "RecLocAS2All" with URI "/xxxxxx/BTSHTTPReceive.dll" is suspended. 
     Error details: An output message of the component "Microsoft.BizTalk.EdiInt.PipelineComponents" in receive pipeline "Microsoft.BizTalk.EdiInt.DefaultPipelines.AS2Receive, Microsoft.BizTalk.Edi.EdiIntPipelines, Version=3.0.1.0, Culture=neutral,
    PublicKeyToken=31bf3856ad364e35" is suspended due to the following error: 
         An error occurred when decrypting an AS2 message..
     The sequence number of the suspended message is 2.  

    I tried passthrough pipeline and I can receive encrypted file.Now trying to write code to decrypt it but I can not. Based on certificate I can say it is RSASHAI, so using it for decrypt. But getting error at  Convert.FromBase64String(text) where text
    is encrypted test from file.
    I am getting following error 
    The input is not a valid Base-64 string as it contains a non-base 64 character,
    more than two padding characters, or an illegal character among the padding characters.
    Can somebody help me to understand it and resolve this. Mean time trying
    to convene customer for compressed file .Please help me to understand above error. 

  • 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!)

  • Custom cursor that follows mouse - JITTERS

    Hi again.
    I'm using this code to make my custom cursor follow the mouse, HOWEVER when it gets near to the mouth it goes loopy - and turns left and right in a fit. Can I put code in there for it to be smoother?
    The CODE is lower done highlighted in BLACK.
    Cheers
    // Remeber to add private to vars and public to functions that are used outside.
    import flash.display.MovieClip;
    import flash.media.Sound;
    import flash.events.Event;
    import flash.ui.Mouse;
    import flash.events.MouseEvent;
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;
    var v:Number=5;
    var varObject:String;
    var i:Number;
    var arrayObjects:Array;
    var soundClip:Sound;
    var randomnumber:Number;
    //public function game1SunnyWalk() {
    stage.addEventListener(MouseEvent.MOUSE_MOVE, myClickReaction);
    stage.addEventListener(Event.ENTER_FRAME,enterFrameHandler);
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    // populate array and initiate variables i and varObject
    this.arrayObjects=["chocolate","icecream","pizza","hamburger","sandwich","egg"];
    this.i=1;
    this.varObject=arrayObjects[i-1];
    var clickPoint:Point = new Point();
    function myClickReaction(e:MouseEvent):void {
    clickPoint.x=this.mouseX;
    clickPoint.y=this.mouseY;
    function onEnterFrame(event:Event):void {
    var xDistance:Number=clickPoint.x-this.planeAndSunny.x;
    var yDistance:Number=clickPoint.y-this.planeAndSunny.y;
    var angle:Number=Math.atan2(yDistance,xDistance);
    this[varObject].y += 5;
    //trace(this[varObject].y);
    this.planeAndSunny.x+=v*Math.cos(angle);
    this.planeAndSunny.y+=v*Math.sin(angle);
    if (clickPoint.x>=planeAndSunny.x) {
    this.planeAndSunny.gotoAndPlay("right");
    //trace(Math.abs(xDistance));
    if (this.planeAndSunny.x>=clickPoint.x) {
    this.planeAndSunny.gotoAndPlay("left");
    //trace(Math.abs(xDistance));
    //if (Math.abs(xDistance)<=10) {
    //trace("works");
    //this.planeAndSunny.gotoAndPlay("static");
    //removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    function enterFrameHandler(e:Event):void {
    varObject=arrayObjects[i-1];
    // this property refers to the mc being referenced and as it's an array you also need the square brackets
    // I tried to hitTest only the STRING whereas you need to hitTest the object
    // ie: this refers to the array object and NOT the string.
    if (this.planeAndSunny.hitTestObject(this[varObject])) {
    //starts sound
    //init();
    // spins the object
    spin();
    trace(varObject);// BUT you can trace the STRING ie: No need to use OBJECT(STRING) - which would be the actual mc.
    removeEventListener(Event.ENTER_FRAME, enterFrameHandler);// ie: You can't do a hitTest on a string BUT on an object. (The array)
    //var soundClip:Sound;
    //function init() {
    //soundClip = new Sound();
    //soundClip.load(new URLRequest("sound/chocolate.mp3"));
    //soundClip.addEventListener(Event.COMPLETE, soundLoaded);
    //soundClip.addEventListener(ProgressEvent.PROGRESS, soundLoading);
    //function soundLoaded(e:Event) {
    //soundClip.play();
    function spin() {
    //tw.addEventListener(TweenEvent.MOTION_FINISH, spinStopped);// note than when you use addEventListener - the function called uses that event as an argument in brackets after the function name
    var tw:Tween=new Tween(this[varObject],"rotation",Strong.easeOut,0,360,2,true);
    var numturns:int=8;
    this[varObject].removeEventListener(MouseEvent.CLICK, spin);
    tw.begin=this[varObject].rotation;
    tw.finish=numturns*360;
    tw.start();
    i=i+1;

    you can easily attach the cursor between the specific layers you want using an empty movieclip and add your cursor movieclip to the emptyMC using the class name. Look at the screenshot and follow the code. it works
    and here is the code:
    import flash.display.MovieClip;
    var whytehand:MovieClip=new cur();
    emptyMC.addChild(whytehand);
    emptyMC.mouseEnabled = false;
    emptyMC.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_5);
    function fl_CustomMouseCursor_5(event:Event)
        emptyMC.x = stage.mouseX;
        emptyMC.y = stage.mouseY;
    Mouse.hide();
    Thatz it!

  • Netbeans 6.1 won't use customized cursor .

    Hi , Have you guys tried the Netbeans 6.1 ?  If you have ever used netbeans ,you know what I am talking about.
    I wonder if anyone has encountered the same problem . when I expand the tree node in the project window or file window , the cursor changed into an waiting cursor , that normal ,but the waiting cursor isn't my customized cursor ,but the xorg's default black watch, I have the same problem when testing on windows , the waiting cursor in netbeans is the windows default large ugly one .
    why netbeans don't use my customized cursor instead of the system default one ? Do the developers of netbeans think all the linux users use the black watch cursor ?
    Have you encountered the same issue ?

    I just noticed the same issue with an Airport Express 802.11n (2nd) with version 7.6.3. I configured the primary and the secondary radius server on the Airport Express.
    With the primary radius server running WLAN login with WPA2/Enterprise worked fine.
    I then stopped the primary radius server and tried to repeat the WLAN login again and it failed. In the secondary radius server log there was no trace at all even when I started the radius server in debug mode.
    Because the Airport Express is in another subnet than the two radius server I enabled logging on my router firewall. I found only four retries for the primary radius server.
    This proves your result that the secondary radius server is never used.

  • How to keep the real data if number length bigger than 15 in excel format

    i have a bank card number column in report, the data type is varchar , and the data is always number , the length is bigger than 15, now if i download the report as excel format, this column's data will alwasys change to something like "5.41321E+17", and due to this, i just format this column to custom=0, but all data will change the last number to "0" like "460025198509180000", this is what i do not wanted.
    how to solve this problem? thanks in advance
    Kaymo
    Edited by: user10740102 on Jun 11, 2009 1:23 AM

    it's because Excel is thinking that it's a number....try changing the formula for the column from Table.ColumnName to the following
    '"'||Table.ColumnName||'"' (or use CONCAT - it's the same)
    This will show quotes and when you download to excel - it'll drop the quotes and keep the number

  • How to make a custom cursor

    How do you make a custom Cursor with the Cursor class, so that I can use it in my program.
    And also, how do you make a LookAndFeel??

    To make a cursor use:
    createCustomCursor public Cursor createCustomCursor(Image cursor,
                                     Point hotSpot,
                                     String name)
                              throws IndexOutOfBoundsException, HeadlessException
    Creates a new custom cursor object. If the image to display is invalid, the cursor will be hidden
    (made completely transparent), and the hotspot will be set to (0, 0). Parameters:hotSpot - the X
    and Y of the large cursor's hot spot. The hotSpot values must be less than the Dimension returned
    by getBestCursorSize().name - a localized description of the cursor, for Java Accessibility use.
    Throws: IndexOutOfBoundsException - if the hotSpot values are outside the bounds of the cursor.

  • Quality Custom Cursor (Dukes)

    I have created my own Custom Cursor that is displayed while a long task is running (in a different thread) to show the user that the program is busy.
    Cursor search1 = myToolKit.createCustomCursor(myToolKit.getImage("Resources/Images/Cursor1.png"), new Point(0, 0), "Search1");Sun says:
    Note that multi-frame images are invalid and may cause this method to hang.
    So I created a Timer that changes the icons every 500ms to give the impression of a slow animated cursor.
    This works, however,
    There are three problems:
    1. The time between changing frames is not 500ms, it seems to be very jumpy. It is running in a different thread so I thought it wouldn't be a problem. Is there any way to regulate this?
    2. The size of the cursor seems fixed, can I change it? (The size of the Image I use for the CustomCursor does not seem to make a difference)
    3. The quality appears really bad. I am using a png file that looks really clear at 100% size in Photoshop. Should I use a particular format?
    Thanks for any help
    Charlie

    Thanks very much for the quick reply.
    I have done a bit of testing on your suggestions..
    1. You could try upping the priority of that thread.Seems to work (sort of), think I'm just going to leave it!
    2. Depends on your OS. See Toolkit.getBestCursorSize.Whatever size I give it, the bestCursorSize comes out as 32x32. Do you know if any other sizes are supported or if I can override it e.g. 64x64? Using XP (Can I change the settings in the OS?)
    Would it just be best to resize my image files then?
    3. See Toolkit.getBestCursorSize API doc.Thanks!
    Think I'll give you the Dollars unless someone else comes up with a great answer soon
    Charlie

Maybe you are looking for