How can I allow the user to draw freely on the screen - java

how do I can make the user to draw somthing by touch the screen?
in what method I use?
Does I use canvs?
Thanks (:

Yes, you will need to use the HTML canvas object. I recommend also looking into a graphics library to make things more simple. Fabric.js is a good one (http://fabricjs.com).
Here is a global drawing web app I made using node.js. Feel free to check it out.
http://node.paulkr.com
https://github.com/paulkr/pennitdown

Related

How to make a button that draws over any screen?

Apps like Floating Toucher or Link Bubble proves how useful a floating button can be. And no, I'm not talking about FABs as per Material Design guidelines here, I meant a literally 'floating' button that draw over any screen in the system that can be dragged around and clicked.
Take a look at these examples:
(source: boatmob.com)
Now, I tried to Google a way to do this but I'm afraid I'm still at lost here. How can these apps draw over screens outside their own?
I've come across this SO question which more or less asking about a similar question. But to be honest, I wasn't able to gain much information from it. Said question mainly addressed how to intercept a touch for a floating view; Not how to specifically make one.
I really hope that somebody out there could enlighten me on this. Thanks in advance for your time!
If you are talking about an activity's view (not Widgets), 'floating' on screen, like Facebook ChatHeads. Then you should create a background service and attach a view with it. Though it is not recommend by Android.
See below links
What APIs in Android is Facebook using to create Chat Heads?
http://www.piwai.info/chatheads-basics/

Add KeyListener and Draw To Screen in All Apps on Android

I have a pretty nice idea to implement.
What I need is to somehow add a keylistener to the keyboard at all apps and to draw on all app's screens, including the browsers. Which means that I need to override the native keyboard and the native screen. Preferably in Java (I don't know if there is another language for Andoird, Java is the best one I know).
Could someone suggest me a way to override native keyboard\screen on Android? (OR just to do what I need, whichever is correct.)
Here's a way to do it on Windows. Not tested though. http://kra.lc/blog/2011/07/java-global-system-hook/
Edit: TextFieldListener is OK too and even better as long as it's global. I haven't thought about possibility to make a keylogger with such thing.
Edit 2: Here is the link for drawing on top of everything, I haven't reviewed it too yet: http://www.piwai.info/chatheads-basics/
Fortunately, it is not possible to "somehow add a keylistener to the keyboard at all apps", for blindingly obvious privacy and security reasons. Such things are called keyloggers, and they are primarily the province of malware authors.
You would need to create a custom keyboard by implementing an InputService

Explanation of JetBoy example for dev.android.com?

I have developed many applications for desktop or web in java, but never for android.
What little I have practiced with was weird because I am used to SWING. Since it uses .xml files for applications I was wondering if you needed this also in games?
For example there is a a good example at http://developer.android.com/resources/samples/JetBoy/index.html. I was hoping someone could explain two things for me.
How is the image drawn to the screen?
How do you listen for user input? (Eg. Clicks, drawing, swiping, ect...)
I have made games on the desktop so you don't have to get in depth, but I found it hard to understand the code. (What I was suppose to do special for android.)
(Another way to put it:)
I guess basically what I am asking is how to I draw an image that will in turn listen to clicks and such without adding a button? Or do I need to add an invisible button? Then if I did have to add a button how would I listen for swiping and drawing?
Also I saw some methods like doDraw(), but did not see where they were putting the image so it would appear on the android device.
JetBoy is rather complicated for a beginner, check these simple examples which are based on the same principles as JetBoy: How can I use the animation framework inside the canvas?
Everything is done by drawing bitmaps on the view's canvas and an event which detects when and where the sreen was touched.
I think this will tell you everything you need to know, in a comprehensive, 31 part series detailing the creation of Light Racer 3d for Android.
If you are not going to use any Game Engine ,
basically you extend android.view.SurfaceHolder
and then overide these methods,
public boolean onTouchEvent(MotionEvent event)
protected void onDraw(Canvas canvas)
go through
these articles.It teaches everything you need from the scratch

Get input from keyboard with Canvas

I want to create an Upwords application for desktop and so I think that the game table should be displayed as canvas. In the beginning of the game I want to ask the user to make some input about the players that will play, but I don't have any ideas. Could you please help me on that?
Also, if there are better implementation ideas than to use canvas, I would be grateful to hear you.
Thanks in advance.
No it's not my first GUI application but I have very little experience.I think it's a good idea to make my own class but I was't sure because I want to use GUI builder(deadline issues) and in the past I had some problems on this.I will try it.For the input I thought about JDialog but I have to simulate a mobile environment so the prompt must be shown on the "screen"(the canvas on our case).
You have a pretty broad question, and I'm guessing this is your first (or one of your first) graphical programs in java. Instead of using AWT components (like Canvas), I would strongly, strongly recommend using Swing, or really, any other graphical library. I would start by looking at the documentation for javax.swing.JFrame. You will probably end up creating a custom component (extending JComponent?) and overriding its paintComponent() method to provide the custom graphics of your 'game table'.
As far as user input at the start of your game, you may want to look at a dialog box. Look at the documentation for javax.swing.JOptionPane which can create a wide variety of simple dialog boxes for gathering user input, taking care of the keyboard input automagically.
There are plenty of java Swing 'Hello World' type programs out there that can help show you how to create a basic Swing app. The Java Tutorials is a good place to start.
Good luck!

Detect repainted area of screen in java

I am creating an applet which will do something like screen sharing . For that I am using Robot class to capture screen area . I want to capture the dirty / repainted areas after first screen shot. I think RepaintManager manager can be used for that. but i dont know how can I use it. I am a novice so a java code will be helpfull. thanks
Check out this custom repaint manager for checking if repaints happen on the EDT to see how it overrides addDirtyRegion.

Categories

Resources