BestJewSinceJC 700 Posting Maven

I think this can be accomplished using

int n = 0;
printf("%d", n);

But hey, that might be because it's the only C code I remember.

BestJewSinceJC 700 Posting Maven

Or if you want to generate any old runtime error, I've learned plenty of ways to do that in my time programming. :)

One of the most common is indexing an array by an index too low or too high

BestJewSinceJC 700 Posting Maven

Not trying to be rude, but that still does not make sense to me. Maybe you should try writing a full explanation of what your program does.

BestJewSinceJC 700 Posting Maven

You forced them to input a row between 1 and 3 and a column between 1 and 3. Your array has 3 rows and 3 columns. Arrays in Java (and most other languages) are indexed from 0 to (rows-1). Which means that your array's first cell is _board[0][0], and _board[3][3] is NOT a valid row or column.

In your makeMove method, you should convert rows and columns so that they can be used to index the array. Since the first row is indexed by 0, not by 1, all you have to do is subtract 1 from whatever the user inputs.

BestJewSinceJC 700 Posting Maven

FYI, to add to what Ezzaral said, the clone method makes a shallow copy, not a deep copy. So it will just be a reference to the same object, not a new copy of the object. If you want to make a new copy of an Object, which is NOT the same reference, override the clone method or make your own method.

BestJewSinceJC 700 Posting Maven

^ No, he's saying only to print out the character the first time it is seen.

RealThinkers, what you should do is make an array of 26 booleans, one for each letter in the alphabet. True means it has been seen, false means it hasn't. Then when you see a character, if it is a letter, check the corresponding index to see whether or not it has been seen yet. Make sure to set it to 'seen'/true after you see the char for the first time.

BestJewSinceJC 700 Posting Maven

Didn't we explain to you in the last thread how to use code tags? Under 'Go Advanced' there is a button that says code tags. Use it. Also add [CODE=Java] to the first part.

BestJewSinceJC 700 Posting Maven

I would help if your explanation was coherent. Repost it but this time, make sure it makes sense.

BestJewSinceJC 700 Posting Maven

Have an update method in the class of the panel you want to show the title in. The class of the other panel should have a reference to the one where you want to show the title. Then call the update method, passing the information in, or using the update method to get the information.

Nobody is going to write this code for you.

BestJewSinceJC 700 Posting Maven

Writing programs for chess [complex calculations] can be done practicallly only by supercomputers

Sounds false to me. Who told you that? ;)

BestJewSinceJC 700 Posting Maven

No problem. Set the thread to 'solved' if you don't have any more questions. And Darkagn, you should have let him work through it by himself.

BestJewSinceJC 700 Posting Maven

You just count the number of times each one appears in the String. A simple web search would tell you that.

BestJewSinceJC 700 Posting Maven

When you use the code tags in the Java forum, where it says

, put [CODE=java] and it will give it Java highlighting and it will number the lines. This makes it easier for everyone to find and discuss things.

Also, I looked through your code, and I noticed one mistake (so far):

[CODE=Java]public static Money add(Money m3, Money m4)
	{
		return (Money m3 + Money m4);
	}

Money is your class name. The method header (the top line where it says public static Money...) needs to say 'Money' because it tells the program what type of Object to expect as a return type, and what type of Objects are going to be passed in to your method. But in the return statement, this is not allowed. But you have another error. . you cannot just add objects. m3 and m4 are 'Money' Objects. m3 has 'dollars' and 'cents' and so does m4. So add up those dollars and cents, then create a new Money Object using your constructor, then return that Money Object. If you do what I just suggested, and called the Money object "addedMoney", your code would look like this:

public static Money add(Money m3, Money m4)
	{

		//You do the adding of the dollars and cents here
//You create a new Money Object, addedMoney, here, using your constructor and the dollars and cents you just added.

return addedMoney;
	}

Your minus method has the same problem that I just described above. And your add2 …

BestJewSinceJC 700 Posting Maven

So you have times stored in milliseconds in a JTable? Then use the getValueAt(row, column) method of JTable to get the values from the cells that are next to each other. If you look at the JTable documentation for the getValueAt method, you'll notice that the return type is Object. So if you have Integers stored in each cell, then when you call getValueAt, cast the Objects it returns to Integers, then subtract them. JTable Documentation

BestJewSinceJC 700 Posting Maven

Sorry, I thought you had links that weren't showing up. But what values can the number be between? That's something you need to know before you can think about programming. Otherwise, statistically, you have a 0% chance of guessing the number (if the number can be any integer).

BestJewSinceJC 700 Posting Maven

This description is incomplete.

BestJewSinceJC 700 Posting Maven

You can use a for loop to put things into each array index.

BestJewSinceJC 700 Posting Maven

I don't think you can "make netbeans do it". I think you have to take Ezzaral's advice and learn how to do it by coding it yourself in the source code under the source button for netbeans. Which basically amounts to a loop that goes through the table indexes and sets the items there to whatever is in your array.

BestJewSinceJC 700 Posting Maven

Yehh..thanx for dat advice...will keep dat in mind next time i write somethinn

The advice I gave you applies in any situation where you want to share information from one class with another class. That includes GUIs. So. . that advice should be useful to you right now.

BestJewSinceJC 700 Posting Maven

What equation exactly are you using? distance = (velocity initial) * time + one half (acceleration)(time squared) is the equation I remember. Your site is not accessible, probably because I don't go to your school. And where in your program are you getting the wrong results? You should be able to tell us which method is not working as you expect it to simply by doing some print statements.

edit: Ezzaral beat me to it!

BestJewSinceJC 700 Posting Maven

Lets assume you have two classes, Panel1 and Panel2. You could have a method called updateFromComboBox in Panel1's class. Then, when the combo box in Panel2 is selected, you can use the updateFromComboBox method to update Panel1 based on whatever was selected in Panel2. Note that this would require that in Panel2's constructor, you have passed in an Object of type Panel1 (that way you can call the updateFromComboBox) method.

BestJewSinceJC 700 Posting Maven

And use code tags. Read the forum rules.

BestJewSinceJC 700 Posting Maven

Did you write any code yet?

BestJewSinceJC 700 Posting Maven

Nobody is going to baby you through your projects. Start by asking some specific questions. If you don't know any Java programming I suggest you read a tutorial or three.

BestJewSinceJC 700 Posting Maven

After doing ctrl+f to find your code, then doing it again to find your constructor for InventoryDialog, it seems like your GUI isn't launching because you never added the panel to the frame. Your "main" panel is called cp. You should have called this.add(cp) somewhere, since your class extends JFrame, but it doesn't look like you did. So unless I missed where you did that, when you run your code, you would see nothing but an empty JFrame. Also, make sure you called setVisible(true) somewhere after everything is added to the JFrame also.

BestJewSinceJC 700 Posting Maven

You posted much too much code. If your GUI isn't launching it is probably because you didn't call setVisible(true) on the JFrame, but who knows since I didn't manage to find your main method after scrolling through.

BestJewSinceJC 700 Posting Maven

I figured it out. Two tips for people who run into problems like this in the future:

1. Your scroll pane should be added first in netbeans. Then the JPanel or whatever should be added to it. (Think about it like this - in the how to use scroll panes java tutorial, the component that you want to make scrollable (in this case, my JPanel), is the argument to the JScrollPane constructor).
2. Setting the size of the JPanel or whatever component it is might result in some of the information not being displayable. When I set the size of the JPanel to null, I think this allowed the JScrollPane to determine the JPanel's size.

BestJewSinceJC 700 Posting Maven

I've tried a variety of things, nothing works. There is probably something easy and obvious I'm missing. I'm just trying to make it so that once my items inside the JPanel take up too much room, I can scroll vertically to see them. I can do this hard coded - I've succeeded in doing so before anyway - but I can't get netbeans to do it. If anyone knows how to make it so you can scroll in a JPanel in netbeans, please give me some tips.

BestJewSinceJC 700 Posting Maven

I tried setDefaultSize. I'm trying to learn how to use the built in netbeans buttons, such as the ones under properties, although I should have considered that it'd "listen" to me if I set the maximum size! Haha. Thanks.

BestJewSinceJC 700 Posting Maven

Bound it to the size of the table using modulus. Then you won't go out of bounds on the array. hash value % table size

BestJewSinceJC 700 Posting Maven

In netbeans I added a scroll pane + bar inside one of my JPanels. When I drag enough items into the JPanel, the size of the JPanel increases in netbeans. How do I get it so that it stays at a fixed size, so I can use the scroll bar?

BestJewSinceJC 700 Posting Maven

It sounds like you are using netbeans. If you "select" the button so that it is orange, then double click it (or click on 'source'), you will see something that says jButton1ActionPerformed (or whatever the name of it is). Assuming you've already created whatever other window you want to open, and it is in the same Netbeans project, code to open the window would look like this

public void jButton1ActionPerformed(ActionEvent evt){
new SecondScreen();
}

This is assuming your netbeans hierarchy looks like this:

MyProject
-FirstScreen.java
-SecondScreen.java
-ThirdScreen.java

I hope that makes sense. If you aren't using netbeans, my apologies (your use of 'JFrame forms' is netbeans terminology, I think). But I'd recommend reading the swing tutorials anyway, and coding some GUIs without netbeans. It will teach you a lot more than netbeans will.

BestJewSinceJC 700 Posting Maven

http://www.daniweb.com/forums/announcement9-3.html

And try reading that thread in addition to posting what errors you got. We're more than happy to help if we don't have to spend extra time doing things we shouldn't have to (like formatting your code and pasting it into our editor to run it and see what errors we get).

Antenka commented: :D yeah, that would be more comfortable +2
BestJewSinceJC 700 Posting Maven

"Made mine with eclipse instead of netbeans"

What do you mean by that? I'd suggest you don't follow any tutorials meant to be used with netbeans if you're using Eclipse. The sun tutorials are good but if you look at all of the examples they provide, they provide the full code. You should try doing some simple tasks on whatever tutorial you happen to be viewing and make sure you can perform simple tasks yourself. For example, make sure you can make a button do something when it is clicked.

BestJewSinceJC 700 Posting Maven

I don't know if this will ever be of use to anyone, but if you right click on a JFrame in netbeans, then click properties and set the title, that is the text that will appear by default instead of the default text that Ezzaral and I were talking about before. It's only useful to me since I'm not currently concerned with how the app will actually run, I'm only looking for a nice screenshot.

BestJewSinceJC 700 Posting Maven

Yeah, I should've tried that before asking. I assumed it wouldn't run without any background code for some reason. Question: why does the window look different when I run it than when I do the design preview? I have tabs on there and on the design form, it looks nice, but when I run it, two tabs appear above and two tabs appear below those. On the design, they are all next to each other like I want them to be.

BestJewSinceJC 700 Posting Maven

Yeah, this is definitely a nice tool, but it is also going to take me much longer than 2 minutes per screen. You must have been using netbeans for a while, no?

Also, is there any way to get it so that it doesn't say design preview on the screen? I doubt my professor will care much, but since the screen technically doesn't say that, it'd be nice to get a screenshot that doesn't.

BestJewSinceJC 700 Posting Maven

Fortunately it is spring break for me so I have time. Unfortunately it is spring break for me and I am doing school work.

:(

BestJewSinceJC 700 Posting Maven

Yeah I'm trying it out now. And by trying it out, I mean installing all sorts of stuff first, like a jdk, since I apparently didn't have one before. Lame.

BestJewSinceJC 700 Posting Maven

I'll try netbeans but I have never used it before. In the past I've done the GUIs by hand. I have probably 15 screens total that I have to do, all of them are more complicated than that... I'll try it out though, if this other tool I found is too hard to use.

BestJewSinceJC 700 Posting Maven

You have an 8x8 array. All you need to go through that is two for loops.

for row one through row eight
for column one through column eight{
what piece is in the current index?
}

BestJewSinceJC 700 Posting Maven

What is the error? Is it a logical error or a compiler error?

BestJewSinceJC 700 Posting Maven

I'm not sure what forum this fits into, if any, but the program itself is going to be written in Java (not that it matters much). My question is, what is the easiest software to use that I can create a drawing of a GUI with? The GUI I want to draw is going to have tabs, a scroll bar, a file menu, text fields, labels, and check boxes. I'm looking for something that can do this and make it look clean with very little learning curve. Has anyone used anything that fits this description?

BestJewSinceJC 700 Posting Maven

We don't give people code, we help them learn how to do it themselves. There isn't anything constructive that can come out of you posting that code for him. And the code you posted doesn't match the assignment by a long shot anyway.

BestJewSinceJC 700 Posting Maven

And post your code in code tags in the future. You might want to look at the forum rules/stickies.

BestJewSinceJC 700 Posting Maven

Maybe I don't understand what a chat window is, but don't you have to connect to another machine in order to chat with someone? I don't see code involving Sockets anywhere. . ?

BestJewSinceJC 700 Posting Maven

In general, using a for loop would shorten code like that. But since you don't have many lines of code anyway, using a for loop would not shorten it. Although it might be tricky to write in this case, so as an exercise, I'd recommend that you try it.

BestJewSinceJC 700 Posting Maven

I think it's mostly because his explanation doesn't make sense. Therefore the code doesn't make sense either. Lol.

BestJewSinceJC 700 Posting Maven

Try to parse the number as a double. If an exception is thrown clear the text field and request that the user input a valid decimal number.

BestJewSinceJC 700 Posting Maven

And definitely answer the question(s) Vernon posed. . what IS your experience level? What concepts do you know that he mentioned?