Dear visitor, welcome to Jabaco - Community.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
Hide Cursor
Well I'm making a simple app to prank my dad on april fools day, where he goes on his comp, and it don't work. It's called
BlackScreen (pretty self explanatory)
Well I tried
System.Windows.Forms.Cursor.Hide() and it didn't work, can anyone help???
Be the change you WANT to see in the world!
Well, I'm a dad myself.
And I would be quite annoyed to receive such jokes.
Please try to come up with something more enjoyable.
Cheers
A1880
b.t.w.: "System.Windows.Forms.Cursor.Hide" belongs to the .Net Framework and is thus not available as such in a Java environment.
It's a yearly thing, I do a harmless prank to his comp so hey'll be expecting it.
Be the change you WANT to see in the world!
Read this one:
http://stackoverflow.com/questions/19159…-exclusive-mode
There is an example code.
When you port it to Jabaco, it looks like
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
Import java#awt#Toolkit
Import java#awt#Graphics2D
Public Sub Form_Load()
Dim myToolkit As Toolkit
myToolkit = Toolkit.getDefaultToolkit
' get the smallest valid cursor size
Dim myDim As Dimension
myDim = myToolkit.getBestCursorSize(1, 1)
' create a new image of that size with an alpha channel
Dim cursorImg As BufferedImage
cursorImg = New BufferedImage (myDim.width,myDim.height, BufferedImage.TYPE_INT_ARGB)
' get a Graphics2D object to draw to the image
Dim g2d As Graphics2D
g2d = cursorImg.createGraphics()
' set the background 'color' with 0 alpha and clear the image
g2d.setBackground(New Color(0.0, 0.0, 0.0, 0.0))
g2d.clearRect(0,0,myDim.width,myDim.height)
' dispose the Graphics2D object
g2d.dispose()
' now create your cursor using that transparent image
Dim hiddenCursor As Cursor
hiddenCursor = myToolkit.createCustomCursor(cursorImg, New Point(0,0), "hiddenCursor")
' use the hidden Cursor
Parent.setCursor( hiddenCursor )
End Sub
|
The nice thing of your wanted program is, that it is so easy and small.
So I have written it in Java, if it will help you:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
import javax.swing.*;
import java.awt.*;
import java.awt.image.*;
public class BlackScreen extends JFrame {
public BlackScreen() {
Toolkit toolkit = Toolkit.getDefaultToolkit();
// get the smallest valid cursor size
Dimension dim = toolkit.getBestCursorSize(1, 1);
// create a new image of that size with an alpha channel
BufferedImage cursorImg = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_ARGB);
// get a Graphics2D object to draw to the image
Graphics2D g2d = cursorImg.createGraphics();
// set the background 'color' with 0 alpha and clear the image
g2d.setBackground(new Color(0.0f, 0.0f, 0.0f, 0.0f));
g2d.clearRect(0, 0, dim.width, dim.height);
// dispose the Graphics2D object
g2d.dispose();
// now create your cursor using that transparent image
Cursor hiddenCursor = toolkit.createCustomCursor(cursorImg, new Point(0,0), "hiddenCursor");
// use the hidden Cursor
this.setCursor( hiddenCursor );
// sets background color to back
this.setBackground(Color.black);
// shows only the part in the window, not the frame around it
this.setUndecorated(true);
// sets the size to full screen
GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(this);
}
public void paint(Graphics g){}
public static void main(String[] args) {
BlackScreen window = new BlackScreen();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setVisible(true);
}
}
|
Thanks for the help bro.
BlackScreen's Java app is now on
Sourceforge. (It's open source btw)
Be the change you WANT to see in the world!