- import java.awt.*;
- import java.net.*;
- import javax.swing.*;
-
- /**
- * bon ben rien a dire ;o)
- * trop simple ... ;o)
- * @author ludo
- */
- public class FrmC extends JFrame
- {
- JEditorPane txt;
- /**
- * Constructor for FrmC.
- */
- public FrmC() throws HeadlessException
- {
- super();
- setSize( 300, 300 );
- setLocation( 300, 300 );
- txt = new JEditorPane();
- txt.setText( "\n\n\n\n\n\n\nElle est pas belle ma souris ;o)!!??? " );
- getContentPane().add( txt );
- getImages();
- txt.setCursor( getCursor( im[ 0 ], new Point( 0, 0 ) ) );
- }
-
- public Cursor getCursor( Image im, Point spot )
- {
- return Toolkit.getDefaultToolkit().createCustomCursor( im, spot, "magicCursor" );
- }
-
- Image[] im;
- // charge lensemble des image JPG ds la liste
- public void getImages()
- {
- try {
- im = new Image[ 1 ];
- im[ 0 ] = getToolkit().getImage( getURL( "cursor.png" ) );
- MediaTracker mTrack = new MediaTracker( this ); // load les image avan de les afficher
- mTrack.addImage( im[ 0 ], 0 );
- mTrack.waitForAll();
- } catch (Exception e) { System.out.println( " getimages : " + e ); }
- }
-
- // methode pour obtenir le chemin des fichier image
- public URL getURL( String file ) throws MalformedURLException
- {
- URL documentBase = new URL("file:///" + System.getProperty("user.dir") + "/");
- return new URL( documentBase, file );
- }
-
- public static void main(String[] args)
- {
- new FrmC().setVisible( true );
- }
- }
import java.awt.*;
import java.net.*;
import javax.swing.*;
/**
* bon ben rien a dire ;o)
* trop simple ... ;o)
* @author ludo
*/
public class FrmC extends JFrame
{
JEditorPane txt;
/**
* Constructor for FrmC.
*/
public FrmC() throws HeadlessException
{
super();
setSize( 300, 300 );
setLocation( 300, 300 );
txt = new JEditorPane();
txt.setText( "\n\n\n\n\n\n\nElle est pas belle ma souris ;o)!!??? " );
getContentPane().add( txt );
getImages();
txt.setCursor( getCursor( im[ 0 ], new Point( 0, 0 ) ) );
}
public Cursor getCursor( Image im, Point spot )
{
return Toolkit.getDefaultToolkit().createCustomCursor( im, spot, "magicCursor" );
}
Image[] im;
// charge lensemble des image JPG ds la liste
public void getImages()
{
try {
im = new Image[ 1 ];
im[ 0 ] = getToolkit().getImage( getURL( "cursor.png" ) );
MediaTracker mTrack = new MediaTracker( this ); // load les image avan de les afficher
mTrack.addImage( im[ 0 ], 0 );
mTrack.waitForAll();
} catch (Exception e) { System.out.println( " getimages : " + e ); }
}
// methode pour obtenir le chemin des fichier image
public URL getURL( String file ) throws MalformedURLException
{
URL documentBase = new URL("file:///" + System.getProperty("user.dir") + "/");
return new URL( documentBase, file );
}
public static void main(String[] args)
{
new FrmC().setVisible( true );
}
}