I'm writing program in Java, using Sikuli. I'm using sikuli-standalone***.jar, and ScreenRegion class inside of it. The problem is in documentation: http://doc.sikuli.org/
I can't find class ScreenRegion there, but I can find Screen, and Region, which have better methods (concluding by their names) than ScreenRegion. But unfortunately I don't have these classes in my library.
Acctually this does not result in compiler error:
Screen screen = screenRegion1.getScreen();
But this does:
Screen screen2 = new Screen();
Error is: "Cannot instantiate type Screen"
ScreenRegions seems OK, but because there is no documentation I don't know how to move/create new ScreenRegion that is moved 50px to the right on global screen.
What should I do?
What I'm doing wrong?
Is there Java documentation for Sikuli?
OK it seems that I haven't seen it first time. This is what I should you (I think):
http://doc.sikuli.org/javadoc/index.html
http://doc.sikuli.org/faq/030-java-dev.html
But these classes does not work with classes in sikuli-standalone, and I'm now totally confused about what should I use. But that's topic for another question.
And this seems to be documentation for sikuli-standalone:
http://code.google.com/p/sikuli-api/w/list
Related
I am testing a new aspect of java, by attempting to make a custom cursor for my game, but it seems as I have run into a problem where in my code setCursor(); is bringing up a compiler error, for the reason that it is not seen as a proper piece of code. I was following tutorials and different guides, which all led to the same problem and I have found no answer for my query.
Toolkit toolKit = Toolkit.getDefaultToolkit();
Image img = toolKit.getImage(getClass().getResource("/res/cursor.png"));
Point point = new Point(0, 0);
Cursor cursor = toolKit.createCustomCursor(img, point, "Cursor");
setCursor(cursor);
Hope someone might be able to assist me, thanks in advance.
Notes:
I am running the latest JRE as of now (1.8).
The compiler error being recieved is as follows:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved
compilation problem:
The method setCursor(Cursor) is undefined for the type Main
The problem was solved thanks to MadProgrammer's last comment:
Then, you need to call setCursor with the instance of JPanel - A runnable example would make it easier.
The problem I had encountered was that I had used a JFrame as my container, instead of a JPanel. To fix my previous code I changed my main container to a JPanel, which in return allowed me to use: JPanelName.setCursor();
Edit: With further testing, I also found that a JFrame can still be used the same way as previously mentioned. The problem with my code above was that I was calling for it as JFrame.setCursor();, which was a static call to a non-static method. This then gave me the impression that I should only use setCursor(); (As seen in my query above). Hope this helps anyone who might have some misunderstandings on the setCursor(); method. Thanks again to MadProgrammer for solving the problem.
I'm new to Java and OOP. I have a strange disorder that makes me extremely curious how things work. So I copied this code that use normalize() and I'm trying to get the source code of it but all I found is
public abstract String normalize(String path);
In:
FileSystem.java file
Of course, know what it does. But I'm curious how and why i cant find the code behind it.
Thank you
Michal
If you are using an IDE (like Eclipse), you can use it to find the concrete implementations of that method.
In Eclipse:
Ctrl + Shift + T and type java.io.FileSystem; click "OK"
Hover over the normalize method name. A menu will appear like below.
Click "Open Implementation"
If there is more than one implementation available, you will see a list. Click on the one you want to open.
If there is only one, then that single implementation will be opened automatically.
Well I have a problem with one of my classes in Eclipse. In there I define an inner Enum type.
In the picture you can see one of the enum-Constants:https: //www.dropbox.com/s/z9shh52au35mkzy/Pict1.JPG
Now I wanted to add some code to the "setup()" method. Sadly the syntax coloring for the new code doens't show up and even if I create a syntax error inside, it doesn't recognize it. (it works at other places)
https://www.dropbox.com/s/0t6que0pg1hr1tw/Pict2.JPG (can't put pictures in the question yet, I hope you don't mind if I put links there)
Finally, when I save the file and reopen it, the error behaviour is the same, but my pour code looks like this: https://www.dropbox.com/s/9lqzchv4xrnpau6/Pict3.JPG
As you can see, even in the other enum constants, there is just color at keywords and things outside of methods. (If I remove the added code and reopen, it works as if nothing hab happened)
So my question is, how can I fix this?
Thanks in advance.
I'm trying to use the standard auto-scroll code I've been seeing copypasta'd everywhere:
DefaultCaret caret = (DefaultCaret)textarea.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
It's placed in the same place I've seen it placed in other codes, right after the creation of the textarea it's associated with.
However, when I compile the code, it gives me the error "cannot find symbol", and points at all instances of DefaultCaret, much like if I had not imported the proper thing into my code.
I have imported ALL of javax.swing, after doing some researching it seems like the code works fine for everyone else.
Seems like I'm missing something simple, but I have no clue what it could be.
Am I supposed to define it earlier in the code?
The DefaultCaret class is not in the javax.swing package. It is in the javax.swing.text package.
Reference: http://docs.oracle.com/javase/7/docs/api/javax/swing/text/DefaultCaret.html
If you're still having problems, please post a Minimal Complete Example that demonstrates the problem. The code snippet you provided is likely not enough for others to help you should your problem persist.
I'm using the android version of cocos2d located here:
https://github.com/ZhouWeikuan/cocos2d
I'm an iPhone guy checking out android who already has familiarity with cocos2d iPhone. Ideally i would be able to create the particle from a plist file in the package/bundle. I can't seem to even get the "premade" default style particles working ie CCParticleFireworks (I've only tried in the simulator though). I was disappointed that there is very little sample code out there for cocos2d android so if anyone has a good resource on this I would be interested as well. I'm just learning java as well so it may be something simple just looking for some code snippet I can use basically.
The behavior im seeing with all my attempts is just a crash as soon as i try to instantiate and add the particle to the scene. I'm not too great at debugging in eclise either so i can't say exactly when the app is dying. sorry. I'm trying to suck less. I'd put my code in but ive tried it a bunch of different ways and I don't want to look like an ass. but here goes anyway, so here's how i think it should work:
public boolean ccTouchesBegan(MotionEvent event)
{
CGPoint location = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));
CCParticleSystem part = CCParticleSystem.particleWithFile("0.plist");
part.setPosition(location.x, location.y);
addChild(part);
return true;
}
0.plist is in my assets folder, i feel like i need to turn this into a hash or something. also i feel there might be a problem with the ccparticlesystem vs ccpointparticlesystem vs ccquadParticleSystem.
You should try WiEngine . It is the Best Cocos2d java android port. Cocos2d-android don't even have 3d implemented. The classes are there but empty. Also check Wiengine's api Demo from the android market
Last time I checked with the author he mentioned that scene transition, grid actions, and particle systems on cocos2d-android-1's 3D are flawed.
I would recommend trying cocos2d-x if you have cocos2d-iphone code to port or coding your own thing extending View.