Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Since they're not right triangles, using the dot product of the vectors may be easier.
Given the vectors (x1,y1) and (x2,y2):
angle in radians = arccos((x1*x2 + y1*y2) / ( sqrt(x1*x1 + y1*y1) * sqrt(x2*x2 + y2*y2) )

More wiki info here: http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation

Pretty decent vector algebra reference here:
http://emweb.unl.edu/math/mathweb/vectors/vectors.html#vec4

Edit: You may need to twiddle the signs a bit. I'm not a vector math genius and always have to "play" with the numbers a little.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to use one of the inverse functions: acos, asin, or atan from Math. Which one depends on which sides you compute the line lengths for.

Edit: If you've forgotten which sides relate to which function, Wikipedia has a graph and table here: http://en.wikipedia.org/wiki/Trigonometric_functions#Right-angled_triangle_definitions

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your repaints() are going to take a long time since you are pausing 3 seconds between each element drawn and I would agree with mKorbel that doing the animation in your paintComponent() method is probably not the best idea. repaint() can be called for many reasons by the system and should be as lightweight as possible.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks reasonable to me. How are you calling ndihmesePaint() ? If you are calling it from the event dispatch thread, such as from a button click, then your repaints() may be getting blocked on the queue.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Don't use == or != to compare Strings. Use the equals() method.

Also indent you loops and if() blocks. It makes the program flow much easier to follow.

thedalek commented: Very helpful. +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you need to delete all of those constructors then and fix your entries in PayableInterfaceTest to use the valid constructors from those classes. You have used four arguments for all of them. Some require more parameters.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Who wrote the entries in PayableInterfaceTest? Did you?

I'm guessing that you had errors on the constructors and used the IDE "Create constructor..." suggestion to "fix it".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I am saying those constructors probably should not be there at all. A parameter list of (String string, String string0, String string1, double d) looks to be generated from some automated source (introspection of a class file, etc).

You could alleviate the error by creating the necessary zero-argument constructors in the parent classes, but that doesn't address why those auto-generated constructors are there in the first place.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Re-read what James wrote above about the constructor.

Edit: Looking at the code, the error is actually coming from this constructor definition

BasePlusCommissionEmployee(String string, String string0, String string1, double d) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

I'm not sure what generated that constructor, but I don't think you want to leave it there as is.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>no but...
Yes, CommissionEmployee does have a constructor defined.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It says more than that. The stack traces will indicate the exact error and the line it occurs on. Read them carefully.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do you have a component in the center region?

If the toolbar is the only component in the north region and you have a component in the center, setting the toolbar to not be visible is sufficient and the center component will expand to fill the area that previously displayed the toolbar.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I have no further idea. If it's coming from their API classes then you may have to contact them and ask about it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

start() is a standard Applet lifecycle method that you can override. You don't need to call it yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you change that line to

loggedIn = Highscore.isLoggedIn(this);

You should also move that to the start() method instead of init().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try replacing "applet" with "this". They don't have posted javadocs for the API but I would guess those are references to the current Applet instance.

Edit: I opened the Highscore class and yes, those are Applet references, so this should work.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your touch method is a void return

public void touch(Kutia[][] k)

You can't assign that to your 'c' variable.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take it out? Use or create the appropriate parameter variable?

I don't know because I have no idea what that code you copied and pasted from somewhere is supposed to do and I have no knowledge of the rest of your program. You need to read the docs more closely and figure out what that 'applet' variable is in their code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, there you go. You can't just pass around parameters that don't exist.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Exactly what are the errors? This line as written is not valid syntax

Highscore.save(applet, score [,level]);

You cannot have brackets around a parameter like that. Perhaps there are two versions of that method, one that includes level and one that does not? If you copied it from documentation, maybe they were indicated an optional parameter?

Post the stack traces of the errors.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll need to make sure the J2EE libs are included on your build classpath. You can read about doing this with ant here: http://download.oracle.com/javaee/5/tutorial/doc/bnaan.html#gexah
or perhaps you may want to look where you got the example code from to see if they have any instructions for use with their build files.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You will need to add their jar file or classes to your classpath.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you import Highscore? Where is the Highscore class coming from.

What "api" you are referring to?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Guess what happens here when 'LN1' has less than 7 characters?

LN1.substring(0,7)
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Of course it isn't. Let's say I put in "2357" as my input number. What are you expecting this statement to do?

System.out.print(convertIntegerToWords(2357) + convertIntegerToWords(2357) + convertIntegerToWords(2357));

I don't see that number in your switch statement. Do you? And why make the exact same method call exactly three times?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to set the color and draw each letter individually as you loop through them. You'll have to increment the position on the screen as you draw as well.

Note that you can specify the offset and length to draw in the method call, so your loop variable can be used like so to draw a single character

g.drawChars(element, i, 1, getWidth()/2, getHeight()/2);

You'll need to shift your x value incrementally as you go.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@tasty: Please post your code and specific questions about the parts you are having trouble with.

@saruba: The point of the forums is to help people fix their code by themselves - not write it for them.

SARUBA commented: You right in a way, thanks. But some people ask questions without the knowledge of VB.NET. That's why I use that way. +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can just echo the result of the function.
http://www.php.net/manual/en/function.mysql-affected-rows.php

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>is there any way for me to update without re downloading
Nope.

>is there and reason to either?
Bug fixes and security updates.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, the problem is that what you have written is not valid Java syntax. You cannot place commas in those expressions. What are you trying to do with those statements?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Put the println() statements after your while() loop if you just want to see the final result after the player turn.

private void waitForCompletePlayerSequence()
    {
        do
        {
            // these if you want to update as letters are clicked
            System.out.println("player sequence " + playerSequence);
            System.out.println("sequence length" + simonSequence.size());
            System.out.println("player length " + playerSequence.size());

            System.out.println("in waitForcompletePlayerSequence loop");
            Utility.pause(500);//note this is in the main thread
        }
        while (playerSequence.size() < simonSequence.size());

        // these if you want to see the final result
        System.out.println("player sequence " + playerSequence);
        System.out.println("sequence length" + simonSequence.size());
        System.out.println("player length " + playerSequence.size());
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure why you are setting up all that other stuff with the values from args. It sounds like all you need to do is loop over the args, convert them to numbers and add them up.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you just wanting it to update as the wait loop runs? Move it into the loop

private void waitForCompletePlayerSequence()
    {
        do
        {
            System.out.println("player sequence " + playerSequence);
            System.out.println("sequence length" + simonSequence.size());
            System.out.println("player length " + playerSequence.size());
            System.out.println("in waitForcompletePlayerSequence loop");
            Utility.pause(500);//note this is in the main thread
        }
        while (playerSequence.size() < simonSequence.size());
    }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

arrayLength needs to be an int.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need an explicit cast to int

int b = (int)a;
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just to clear up the confusion: Yes, this thread has been moved from PHP to Javascript.

Carry on :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Edit: Never mind, answered my own question.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There is also a doClick() method on buttons.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Capitalization matters in Java. Look up that function in the API.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> and can someone also tell me how to make a topic go to solved?
You can click the "Mark this thread as solved" link under the heading "Has this thread been answered?" heading at the bottom of the thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Initialize the variable to a default value, whichever would make more sense as a default for your usage.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your super.paint() call is causing to paintComponent() to get called again, hence the infinite loop and stack overflow.

You shouldn't really need a super.paint() call in your paintComponent() method if you are just painting the background. If anything, it would be a super.paintComponent() instead of paint(), since that is the one you are overriding.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, it's a JApplet

GameApplet extends [B]JApplet[/B]

.
I'd recommend changing

public void paint( Graphics graphics )

to

public void paintComponent( Graphics graphics )

so that you're only overriding the paint behavior of the panel itself and not affecting the the rendering of the other components.

In paintComponent() all you really should need are these

if (app.end)	{
  graphics.setColor( Color.BLACK ) ;
  graphics.fillRect (0, 0, 800, 600);
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your panel doesn't have the focus, so it's not receiving your key events. Add

content.requestFocusInWindow();

after the setVisible() call.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No one can tell unless you post some code. Are you using JApplet or the old AWT Applet?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Make sure that your fillRect call is being made before the other UI components are being rendered. Typically that would mean making it the first statement in your paintComponent() method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are somewhat right that it is exiting at "random" times - it's your generator for the computer choice that is causing the exit. The nextInt(int) function is specified

Returns a pseudorandom, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive),

So it is giving you a value from 0 to 2. You don't account for a value of 0 in your if() statements, so it will fall into your else() block where you are exiting.

Note that the computer will also never choose Scissors with that generator either.

Knowing why it's exiting, you should be able to figure out how to fix it quite easily now.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use the getSource() method of the ActionEvent to get a reference to the button that was clicked. You will need to cast it to JButton yourself to use it, since getSource() returns Object.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Not sure how to flag as answered!!
Just click the link "Mark this thread as solved" at the bottom where it says "Has this thread been answered?"

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try using just getInsets() instead of getMargin()

String label = "Really Super Extra Long String Here";
int len = jButton1.getFontMetrics(jButton1.getFont()).stringWidth(label);
jButton1.setSize(len + 2*jButton1.getInsets().left, jButton1.getHeight());