sirlink99 56

A quick look at the documentation suggest to me that there is a getInputValue() function that you might want to look at.

I hope you can figure it out!

sirlink99 56

Then you have a String of size 0 which means the input probably isn't being read properly. Print out the read text before you do stuff with it.

sirlink99 56

I'm not sure. Try breaking it up into multiple steps and print it out step by step to see where it might be going wrong. What happens when you change it to charAt(1), does it return the second character or throw an error again?

sirlink99 56

Drink coffee and or another caffeinated drink, and listen to upbeat music, while singing to it as well as I can (which is sometimes difficult because I like music that isn't English). Moving my feet and streaching also helps. I also make it as bright as I can, and I try to think as much as I can to keep by brain going. If I'm just trying to stay up for the fun of it, watching an intense movie or playing a fast paced game also helps.

sirlink99 56

The try-catch statement is a way of handling errors in your program. the throws causes an error to pop up. Like in the example if you have a method called divide, then you would need some error to indicate if the user is dividing by zero. Then the user could andle this error in a try-catch with something like "You divided by 0! Please enter the denominator again", and then this would allow the user to correct their mistake.

So in short the throws keyword creates an error, and the try-catch statement can allow for rectification of the error.

As for your question in the OP. When you use nextInt() and someone enters a text, then the scanner class will throw an InputMismatchException, and then the creator of this program is handling the error with his try-catch. The same thing goes for the arithmeticException exception. When it is thrown by the method, the user handles it.

I hope this clarifies.

sirlink99 56

It wouldn't matter, since the Random class return a number between 0(inclusive) and specified number (in this case 10)(exclusive). I would put it as gen == 9 just incase someone didn't know this(or programmed it wrong), and then place an else saying that "The generated number " + gen + " does not fit into any of the above ifs". This way the programmer would know something was wrong with the generated number before they realized that the probabilities were sqewed.

sirlink99 56

generate a number between 1 and 10, then use an if statement to check which number was generated

gen < 7 
    gen = 1;
gen < 9
    gen = 2;
gen == 9
    gen = 3;

sirlink99 56

Hello! Long time no see. I believe the code you are looking for is the setDelay() command for the timer.

Here is the documentation:

Also if you wish to have multiple timers for different monsters then set an actionCommand for each timer

sirlink99 56

You could do it in java, however php would probably be easier.

Here is how you can send an email using php:

with java you would have to use the JavaMail API:

In both cases what you want to do is run through your database using the primary key as your indexing and then checing if the stock is 0 or at a low number depending on your wishes. Then probably the best way to do it is to add the low items to a string and then send the whole string in an email.

PHP has the built in ways of traversing a database, bowever with java you will want to take a look at JDBC:

Hope this helps you achieve your goal.

sirlink99 56

As James Cherrill said. you are making the player, but you are not painting it. Also is your map01 a grid for your snake to go on, or are you going to make levels like in my snake game?

This is the snake game I made a year or so ago, and I have recently started to remake it.

My new version has these classes - creates the frame, and runs the game loop which repaints the and moves the snake (calls a meethod) - the JPanel which holds the graphics that is added to the frame. Gets repainted from and repaints the snake - Holds the key listener which has been added to the frame( Changes variables to moves the snake - holds the snake (a Vector or points) which then moves according to boolean variables changed by the Listeners - holds variables that need to be accessed from many different classes. - a system of adding high scores to a database (for future use).

I technically also use a 2d array to do my movement, but I do not have it defined in an array. Instead I just set the content pane of the frame to be 500 by 500, and then I move the snake 10 at a time (so it works out to a 50 by 50 grid) which controls the snake. Then I use rectangles to check if the snake is out of the screen (in which ...

sirlink99 56

if you assigned a variable called inputSum and then called the average method with the parameter inputSum then you could do the same thing, except you wouldn't need to add your numbers in the average method.

sirlink99 56

you could use a vector.

sirlink99 56

I am sure if you made a chart that just replaces letters with other ones you would do something like that.

lets say again that you message was hello if you swapped the letters like this

h = z
e = t
l = m
o = q

your message would look like

if you do not have the chart then it would be difficult to decode the message, but not impossible. It would make it easier if you had more words, because then you could reference the letters with other ones for example if you had a message like

m fmsn ntaskgvpwq

you would know that the m = a or an i because those are the only single letters that are used in a sentence

so you would know this
i fisn ntaskgvpq
a fasn ntaskgvpq

then you would know that n needs to be the same for both. As you can tell the more words you have the more references you have and the easier it is to decrypt the message. This is why numbers are used.

and lets say you tried multiplying the matrix example that I gave

encryption matrix
[a g]
[x q]

and your message was hi

[a g] . [h i]
[x q] [z z]

your new matrix would be

[ah+gz ai+gz]
[xh+qz xi+qz]

it would look like that. now if you see what is in common for the rows
first row has in common an 'a' and a 'g'. The ...

sirlink99 56

maybe try reading this [url][/url]

What I know of encryption so far is that it uses matrices to hide the message. for example
[ = one large [

lets say your encryption matrix is
[1 2] [a b]
[3 4] [c d]

your decryption matrix would be

1r(ad-bc) [d -b]
----------[-c a]

so if you use the encryption matrix to encrypt a message hi

you would need to arrange the message into a matrix

[h i]
[z z]

the 'z' is nothing. If you wanted you could use key codes and replace the 'z' with a -

then you want to convert the message into either key codes, or alphabet values

[8 9]
[26 26]

once you have that you will want to multiply it by the encryption matrix (think of it as a 2d array. multiply row 1 by column 1 ([1][1] [1][1] + [1][2] [2][1]) would be your first value)

[1 2] . [8 9]
[3 4] [26 26]

which would give you

[60 61]
[128 131]

That is your encrypted message. if you were to find out your original message you will need to find the inverse or the encryption matrix, and then multiply the decryption matrix * encrypted message to get your original message back.

This is a simple encryption, but finding the inverse of a 3x3 matrix is much harder. This is the way I will try to encrypt. The other way is to think of a random algorithm to multiply each ...

sirlink99 56

couldn't you do
public double (double number1, double number2){
return (Math.pow(number1, number2));


sirlink99 56

if you are using if statements then I would suggest you store the last value in each textfield then you compare them to see if they are not equal (has been changed) then you can recalculate the rest of the values using the one you used in the if statement. Then all you would need to do would be to set the new value into the text fields.

sirlink99 56

gender is a string use .equals (); put the "m" into quotes inside the brackets to compare the two strings

sirlink99 56

You can just use the code I posted. All you would need to do is change the package and the name of the class and it should work.

My jar file works. it takes me a little while to load though.

sirlink99 56

That is correct

sirlink99 56

no I suggest you try to create another project, or package and try again. if that doesn't work then just use your original, or paste my current code into your original and then change the class name. You can change the name of the JAR file if you single click 2 times on the icon, or right click it and rename, or right click > properties and then change the name from there. the only way you can see the class files in the project are if you extract the jar file using winzip, or win rar or another archiver program.

sirlink99 56

It could be. I don't use netbeans, so I can't tell you for sure. And what is the i button. it changes the color of the OK button.

sirlink99 56

I changed the look and feel to numbus. It has the least amount of sharp edges. I have changed the color of the text to white, the background to red, and the button to a purple. See if you like it. If not then change the colors

package Surprise;

import java.awt.Color; // needed to set the color
import javax.swing.JOptionPane; // needed to display the frame
import javax.swing.UIManager; // needed for look and feel
import javax.swing.UIManager.LookAndFeelInfo;// needed for look and feel

public class Surprise {

public static void main(String[] args){
    UIManager.put("control",; // changes background
    UIManager.put("text", Color.white); // changes text
    UIManager.put("nimbusBase", new Color (9445584)); // changes button
    try { // attempts to set the look and feel
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName()); // sets look and feel
    } catch (Exception e) {
        // If Nimbus is not available, you can set the GUI to another look and feel.
    String[] messages = {"message1","mesage2","messag3","mesage4", "message5", "message6", "message7", 
    "message8", "message9","message10","message11"}; // stores messages
    JOptionPane.showMessageDialog(null,messages[getRandomIndex(messages.length)]); // prints out one of the messages
public static int getRandomIndex(int max){  // gets which message to print out
    int messagePrintNumber = (int)(max*Math.random()); // generates a random number in the array

    System.out.println("Messages " + (messagePrintNumber + 1)); // tells you which message it is printing. the +1 is to account for the array beginning at 0

    return messagePrintNumber; // returns which message it should print out


did you use the default exportation method of netbeans, ...

sirlink99 56

It is. I don't know what you did. It works for me.

Make sure your class and package names are exact. Java is case sensitive.

sirlink99 56

did that fix your error?

Also what would you like the application to look like (GUI)?

sirlink99 56

did you change the Class name from the file to the new class name?

where it says

[CODE]public class Try1 {[/CODE]

replace it with

[CODE]public class NewClassNameHere {[/CODE]

you wrote in the class name when you made the class (if you are using netbeans or eclipse) or it is the name of the file (if you are using notepad, or another text editor)

if that doesn't fix it send me the code. maybe you have a small error that is correct, except misused.

sirlink99 56

All of this code will be written inside the main method before the OptionPane

sirlink99 56

I have figured out how to make the inside change. Using this reference


and here is a list of all the possible areas to change (I did not find one for the external frame)


Also when it says new color(....) you can replace all of that with, or you can write the Hexadecimal for the color you want. You can get the codes from a chart like this


You also want to put the codes with the UI before you make the JOptionPane

sirlink99 56

You would need to change the Look and Feel. I have not yet figured out how to do this, but here are some starting points:


I will see if I can find more, or figure it out. There are basic ones you can change it to, there are also ones you can download, but I do not know how you can implement those.

Maybe you could use something like this:

Have a look around that site. you can download quite a few of them.

sirlink99 56

you want to keep the print statement inside of the method, just move it above the return. I have modified your code a bit. I have also added in comments to help you.

[CODE]package try1;

import javax.swing.JOptionPane;

public class Try1 {

public static void main(String[] args){
    String[] messages = {"message1","message2","message3","message4", "message5"}; // stores messages
    JOptionPane.showMessageDialog(null,messages[getRandomIndex(messages.length)]); // prints out one of the messages

public static int getRandomIndex(int max){  // gets which message to print out
    int messagePrintNumber = (int)(max*Math.random()); // generates a random number in the array

    System.out.println("Message " + (messagePrintNumber + 1)); // tells you which message it is printing. the +1 is to account for the array beginning at 0

    return messagePrintNumber; // returns which message it should print out


I have made it so that it uses the max value of the array in the random calculation.

Note that the random message generation is separate from the print statement. This way you can return the generated number.

sirlink99 56

It is because you put your print statement after you returned a value. When you return it ignores everything after it.