JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you don't want to use a server then yes.
Somebody has to be listening for any connection to be made!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The target "client" has to be listening on ServerSocket for the other client to connect, but that's the same as the code in our existing server.
The problem is usually to find the target client's IP. Having a registered domain name is one way, or a dynamic DNS solution like noip.com
Otherwize you can run a small server that clients register with, and can get each other's IP from

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Start by indenting your code properly and fixing the compile errors.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I doubt very much that the HTML support in Swing will ever be updated for HTML 5.
The future of rich graphical GUIs in Java is JavaFX, so maybe you should be doing this in JavaFX not Swing. The JavaFX docs do refer explicitly to HTML 5.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You are stopping and starting to switch between two timers, so the timing keeps changing.
One solution:
Have 1 Timer that just moves block 1. Start this and leave it running
Have another Timer that just moves block 2. Stop and start it however you like because that won't affect block 1.

However, I would prefer to have all my blocks moving at the same time interval - fast enough for smooth movement (eg >=25/sec) but not so fast that it justs burns CPU pointelessly (eg <= 60/sec). If a block isn't moving at some given instant then simply return from its move method without having changed the coordinates.
I think this scales better, and is a lot easier of you ever need to think about collisions between blocks.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Why the duplicated code in the two BattleShipX classes? At a quick look it looks like you should have an abstract superclass with all the common code, and have those 2 classes as subclasses, with pnly the methods that are different. (Or if the differences are just in data values, have 1 class with different instance variable values.)

Anyway, you can add a setButton(int cellNumber) method to those classes, then when you need to set a button you can do it in either or both panels by calling
h.setButton(cell);
and/or
c.setButton(cell);

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you don't put them in an array (or some other container eg ArrayList) then you would have to re-read the file for each user input, which would be a messy and inefficient solution.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have a toString() method in you Pizza class(es). Java will automatically use that when you try to print a Pizza - ie it will print the result of calling toString() for each Pizza.

    for(Object bp : pizzas) {
        System.out.println("Pizza: "+ bp);
    }
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Not quite gone yet...

yes, thebname variable is private (that's good), but you have a public getName() method to access it (also good). Use the public method.

In your compare method you need to compare the names, you can't just subtract one from the other. The String class has a conpareTo method that will do the trick.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Never just say "I get an error". Help us to help you by copy/pasting the complete error message!
Anyway, without knowing what code you tried to put where nobody can say why it's wrong.

ps: I'm away now until tomorrow, but maybe someone else can step in, thanks. J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It doesn't really matter, as long as its somewhere where you can access the array. Inside the Inventory class would be an obvious choice.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No (unless you want to keep the original order as well). Arrays.sort will just sort the existing array according to your comparator. It doesn't create a new array.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes.

Anyway, rather than blindly copying some random code from the web, learn how to sort arrays of objects and write it yourself. The key to sorting objects is a Comparator - which defines the order in which the objects are to be sorted (eg by name, price weight etc). Here is a very good tutorial that will teach you what you need to know (you can ignore part 3 of that for now).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Let me re-phrase that...

The code starting at line 173 is not Java code.

stultuske commented: nice one :) +13
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 173 etc... is that Java?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Disagree. Never start with the GUI; always get the model first. Anyway - who said this was a GUI application?

Vardaan:
DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It copies two elements starting with element 2 (NB: zero-based) to positions starting at 3. Ie it copies the values in indexes 2 and 3 (values 3 and 4) to indexes 3 and 4, overwriting the previous values of 4 and 5

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The requirement seems incomplete to me, but I think it means:

read an array of 100 numbers from a named file
then read numbers from stdin. If each number matches, write an index/value message to the output file, OR, if the number causes an Exception then write an exception message to the file. Keep reading numbers from stdin, and writing one line per number (one of those 2 messages), until the user enters -1

Maybe the numbers the user enters are intended to be used as indexes into the array of 100 numbers - it seems to imply that, but is woefully hopeless at saying it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This web site has an excellent article on how to store passwords (and how not to, and why). There's nothing I can add to what it says.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I wasn't suggesting a "second server" as a separate program necessarily. I was just making the logical distinction between the two types of "serving" that are going on. I see no problem having one "server" program that is always runing and communicting with clients, and has a print queue that can be stopped, started etc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There's no way the client should be starting or stopping the server that is handling the communications with the client! Maybe your problem comes from confusing the server that talks to clients with the server that talks to the printer? In my mind they are two different things.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Like I said, RMI will do it, but it's hard
Writing your own little command handler is much easier.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java RMI would do that. It provides a version of the server's interface at the client end. Have a look at it, but be aware that it's pretty complicated and the learning curve is steep.
You may find it a lot easier to build you own simple protocol where the client sends one of a limited number of requests and the server replies as appropriate.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You can't draw things in Swing by just drawing to some random Graphics. You have to fit your drawing into the existing Swing mechanisms. This tutorial explains what you need to know.
If that leaves you with any further questions, just ask them here.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What exactly do you expect anyone to do with that information? Did you have the owner's permission to reproduce that complete document on the web? Have you read the DaniWeb Rules that you agreed toi when you joined?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you have a compiler or runtime error message post the complete message plus the actual code it refers to. If your code is giving an incorrect result explain what result you get and what the correct result should be.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

and the code that creates nf is...?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What graphics are you using - Swing?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In the sort, instead of swapping names and gpas, just swap the two Student objects. That's easier, and it won't break when you add another field, eg date of birth, to the student class. It's also very bad practice for a sort to change the values in the objects its sorting, suppose the Student data is backed by an SQL table, when you change the name or gpa you will trigger a database update!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... the doStuff(x,y) case is a little more interesting:
because there's no method that takes an int and a boolean, the best fit the compiler can find is to auto-box the int into and Integer object and the boolean into a Boolean object, then use the Object... method.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yup. The multiply version is the same as the shift version, obviously the fastest and cleanest way to do it. The subtraction thing is just for fun :)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Interesting...

You could start by subtracting higher powers of 2 and do that in just thirty passes of the loop. Pseudo-code:

int pot = 2 to the power 30 (hex 40 00 00 00)
while (pot >= 2)
   if (i > pot) i -= pot;
   pot = pot >> 1  // 2 to the power 29, 28, 27 etc
return i

ps; anybody thought about negative numbers?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The normal way to create a menubar as part of the frame and without confusing the content pane's layout, is

main.setJMenuBar(menu);

see http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Shift 1 bit to the right... the rightmost bit will be lost.
Then shift back 1 place to the left and a zero will be used to fill the last bit.

A small eg: consider these two numbers (4 bits for simplicity)
0111 (7, an odd number)
0010 (2, an even number)
shift 1 right...
0011
0001
now shift one back to the left
0110 (was 7, now 6)
0010 (2 again)

So those shifts just replace the last bit with a zero, leaving even numbers unchanged, but odd numbers changed to a 1-smaller even number, ie

0111 == 0110 false, number is not even
0010 == 0010 true, number is even

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The (definitive) Java Language Spec describes 'bitwize" operators in section 15.22, but shift operators in section 5.19, which to me confirms that shift operators are not "bitwize" operators, so are not forbidden for this exercise.

So: shift your number one bit right, then back 1 bit left again, and if its value is still the same then last bit must have been 0, so the number must have been even.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Can you use shift operators?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I guess you didn't read the bit about not using %

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No.
We don't do your homework!
Read the DaniWeb Rules, and start again.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Please read the information in the link at the end of ~s.o.s~ post.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

He guesses right.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Do the keys really have all those newline characters embedded like that?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

In that case your system is perfectly capable of running multiple threads at exactly the same time (plus see ~s.o.s~ comments above).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Each of your get methods calls the next get method, despite the fact that the original actionPerformed calls them all anyway. This will result in multiple calls to the later get methods, and thus mutiple error messages

kayleigh0411 commented: Thank you for your help! I deleted those lines calling the next method, and it no longer pops up the error message several times. However, it is still putting text in the output text fields when it should not. How can I fix this? +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What is the processor in your PC. Does it have 2 or more cores?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Maybe your computer is capable of running two threads at the same time?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'll try... (watch carefully for "thread" vs "Thread")

A normal Java program runs in a single OS process. It has one or more threads that all share the process's resources. Your program starts running in a "main" thread, and from that thread you can start other threads, and other Java classes (eg Swing) can also start threads for you, and those threads can start other threads...

In the Java language, all those threads are represented by Thread objects - instances of the Thread class. You use the methods of the Thread class to query or control the execution of the programs' threads.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The link I gave you is a very clear, very accurate answer. I can't do any better than that. Did you read it?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The Oracle tutorials are very good... start here

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Did you look at the links stultuske posted? What specifically about SimpleDateFormat are you having trouble with?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

and stack is LIFO not FIFO i think qeues is FIFO

OK, it's a FIFO queue.