JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What you are describing is a large and complex area, so you will need multiple projects to make real progress.
My advice is to start with small simple steps. Pick a simple project from the Projects for Beginners thread, and work through the UML class diagrams all the way to working code. There are many people here who will review and comment on your progress as you go. I doesn't matter much what the project is (although an MVC structure will give you some decent classes and relationships) - it's just something concrete to make a start with.
Working with others on a joint project is the ultimate goal, but unless you have already developed some relevant skills you will find it hard to get a team to welcome you.
Good luck!
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That message says it all. Why did you think that your vmpr object would be a JFrame?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hi Slavi
The solutions you link to are all a bit clunky - either a double-loop search or mis-using the button's name attribute. I would recommend setting the row & col as client properties with putClientProperty and getClientProperty (methods implemented in JComponent, so universally available).
In general, client properties should be your first port of call when you need to associate some extra info with a JComponent

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK.
If you look at your code you will see:
the setAlpha method just sets that variable. It does not do anything to update the sum. You are still missing some of the code you were supposed to write.

Maybe this is your problem (or maybe not)
sum = alpha + bravo;
this does not define sum. It's an instruction that is executed as part of the method it's in. If you change alpha or bravo you need to execute that instruction (or one just like it) again. It would be great if you could define sum to be aplpha+bravo automatically whatever/whenever alpha or bravo are set, but that's not how it works.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Code Pane

ICMA42 pete = new ICMA42();
pete.sumArgs(); <<<<<<<<<<<<<<<<<<< recognises "pete"
this.setAlpha(42); <<< if you use pete here "it" will recognise it

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I get the idea.
Your test code creates an instance of ICMA42 and uses that to call ICMA's sumArgs method. That method is nonsense, but the way you call it is 100% correct.
You need to use the same instance of ICMA42 to call your setAlpha method. Not this, which is some other instance entirely.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

setAlpha is an instance method of the ICMA42 class. To call it you need an instance of ICMA42.

In your this.setAlpha the this refers to the current instance of whatever class that code was in, which obviously isn't ICMA42. That's what the error is syaing - whatever class this is doesn't have a setAlpha method.
The way you called sumArgs is the correct way to do it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Let's take this one step at a time:
Exactly which line of code does the error message refer to? (Post the whole error message - don't edit or summarise it)

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That message was generated by some other piece of code - if you don't post that then nobody can help.
ps Your sumArgs method makes absolutely no sense whatsoever.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If there are always 8 items/row then simply divide the item number by 8 to get the row number. Then use modulo 8 to get the position in the row, eg
item number = 22
row = 22/8 = 2 (integer divisiom always rounds down)
item on row = 22%8 = 6 (remainder from division nby 8)

ps: those calulations give 0-based results - ie first row is row 0, first item on row is item 0.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, here's the code I used to confirm the problem...

       String s = "1.2 3.4";
       Scanner input = new Scanner(s); // my default Locale is UK
       System.out.println(input.locale() + " " + input.nextDouble());

       Locale.setDefault(new Locale("sv", "SE"));
       input = new Scanner(s);  // now using Sweden Locale          
       // input.useLocale(Locale.US);
       System.out.println(input.locale() + " " + input.nextDouble());

without the useLocale it throws an InputMismatch, with it it runs correctly.

The question is: why didn't OP see that Exception?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What code are you using to "use this JLabel in a JTextPane"?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

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

Nice try at some free publicity for your product!
I'm sure there's a reason why you didn't mention that it costs between 8 and 12 THOUSAND dollars.
Caveat emptor.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Then write one, and read the Daniweb member rules before posting again

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Java chars are 16 bit UniCode, ans include Hebrew, Arabic, Chinese... all kinds of symbols.
Ordinary English text can be encoded in just 7 bits (values 0 - 127 or 7f) using the ASCII codes. Java UniCode is the same as ASCII for up to 127 (hex 7f).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

English is not your first language? OK. But that sentence does not make sense. Please try to explain with more detail.

Slavi commented: lol +4
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Don't have a 87 line listing. There's an 81 line listing, but line 18 of that is whileChatting(); so if that's it, it looks like the same as the other NPE?

OK, understand your architectural design now. That should work, although handling errors and shutdown/resart coluld be interesting.
If you end up with two ServerSockets at the same time (JVMBind error) it implies the second instance's attempt to connect as a client has failed.

If this were my program I would set that aside and construct the smallest possible program to test that try-to-connect-and-open-serversocket-if-that-fails design - there's too much going on in your code to see what's happening clearly.

ps: From bitter experience of testing Server implementations I know that its easy to end up with an instance of some failed test version still running and holding on to the port, even if it will no longer handle it properly. If you get weird problems, log out and log on again to terminate any "lost" live instances.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

To read lines, just use a BufferedReader's readLine() method. Simpler, handles exceptions properly, no risk of side effects.

Did you consider the case where there are multiple 1's and multiple 0's?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

... except ...
Scanner is an overkill way to read lines from a text file
and
the algorithm you describe is in no way a solution to the requiremnt as posted.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No, no need for any of that at all... just

ServerSocket serverSocket = new ServerSocket(...
Socket clientSocket;
while (true) {
   clientSocket = serverSocket.accept();
   new Thread(new ClientHandler(clientSocket)).start();
}

then in the client handler (see previous post) open the input and output streams from the Socket and start communicating.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

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 looks like you draw all the strings at the same position. You need to draw each string at increasing y coordinates so they appear one below another

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think the original post (with example) is pretty clear that it's the signature in the first few bytes he wants, but yes, you are right that the the Java API includes classes to get a hash (MessageDigest) for a file very easily.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have an initial Thread that is a simple loop waiting for new connections to the ServerSocket.
When it gets one it opens a Socket and hands that over to a new Thread that handles the ongoing communications with that Socket. The original thread then just goes back to waiting for the next connection.
Ignoring error handling and shutting down, it's kinda like this (pseudo code):

main(...) {
   ...
   new Thread( new ConnectionListener()).start();
   ...
}

class ConnectionListener implements Runnable {
   run() {
       while (true) {
          wait for client to connect to ServerSocket
          open new Socket with client
          new Thread(new ClientHandler(socket)).start();
       }
   }
}

class ClientHandler implements Runnable {
   Socket clientSocket;
   ClientHandler(Socket clientSocket) {
      this.clientSocket = clientSocket;
   }
   run() {
      ... do whatever with the client connection
   }
} 
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What I described is a highly over-simplified version of "use case modelling", which is often used as the first step in specifying and designing object-oriented software. I use this in some form or another all the time.
It can get very technical and detailed, but even a very simple poncil and paper version can be valuable.
Here's a really simple explanation of the basics that I can recommend to you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Write down a brief description of what the game is - its rules etc.
Write down a few examples of how it would look when a user uses it.
(Use any format or medium that suits you - pencil & paper, blackboard etc)

Then (and not before) think about what methods you would have to write to implement the user examples

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Line 39, l2 is uninitialised, so its value is null - you create the scroll pane with null as its content

Lines 42,43 you initialise l2, but it's too late.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This article will give you at least one good reason...

mKorbel commented: :-) +10
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's because you replaced the original text - you didn't add it like I said

lozinka = lozinka + "\n" + "ASDFGHJKL";
Slavi commented: Only if we were listening to you more careful right? ;) +4
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The game "Scrabble" needs a list of valid English words. If you search the web you will find downloadable files with suitable word lists.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Those are the first bytes in the file, yes?
Just open a FileInputStream with that file and read the first 4 bytes into a 4 byte array where you can check the values. Then close the stream.
https://docs.oracle.com/javase/8/docs/api/java/io/FileInputStream.html

ps: Although those bytes correspond to "%PDF" in ASCII, don't be tempted to try to read the file into a String. Java uses 16 byte characters with support for all kinds of local languages and scripts - reading as text may work in a machine configured for English, but could all kinds of surprising things in (say) Arabic or Hebrew. Just stick to reading the btes as numeric bytes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Time for a bit more debugging!
Try printing the important values (eg. the contents of permissions, the value of operation) and see what tells us.
ps: why not simply store the permissions as pairs of strings (operation:permission) and avoid all that indexing and array referencing?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

This is nothing to do with the compiler. The compiler has no way to know whether the array reference will be valid at run time. It's the Java runtime that checks every actual array index and throws the exception if it finds one out of range.

What is the value of "operation"? It looks like it can be >= length of the permissions array.
The code change you made will ensure that the permissions[operation] will never be evaluated for an out-of-bounds value of operation, so that supresses the exception, but may not be the result you intended.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The ServerSocket listens on a given port/IP address. When it receives a connection request it creates a new Socket that you can use to communicate to/from the client. This is done by creating one or two new threads to handle inbound/oubound mesages from/to that client.
The ServerSocket then continues listening for new connections.
So one ServerSocket can create any number of Socket connections (depending on any limits in the operating system itself).

So to send messages to multiple recipients you need to create a Socket connection with each of them. Then you can send the same message to any or all of them.

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

Your code is the solution to a different problem (count the number of odd numbers in an arbitrary list of numbers entered b the user). Looks like you copied from the wrong source.

stultuske commented: zing +13
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The map entries are just a pair of references (pointers), so the map will be a lot smaller than the existing data. Depending on how your ArrayList is updated maybe you can just use the numeric index into the ArrayList?
Java (deliberately) has no facilities for working with memeory addresses, so your C/C++ approach simply won't work.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Thanks stultuske and Search_not
One more point... please post the reported resolution as well
Thanks
J

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

See the very first topic at the start of the Java forum main page
https://www.daniweb.com/software-development/java/threads/430542/java-projects-for-learners

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I simplu doesn't work like that. If you want a reference to an object, use a reference variable of the right kind. Java references are "opaque" - you can use them but you can't manipulate them. There's no way to turn a String into an object reference.

If you want to track objects according to some related String value, you can use a Map with the strings as the keys, and the objects as the values.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

First pass through the loop you add and close, so on the secand pass through the loop the document is already closed, so the add fails

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The JDK comes with JavaDB (a fully Oracle-supported version of Apache Derby) as standard. If you use that in embedded mode you just need to add one 2.6 MB jar to your application, and the user doesn't have to install anything else. Unless you plan an enterprise-scale roll-out I can't see any reason to look any further.

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

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

See reply to post 3

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

See reply to post 3

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Time to face reality.
You have (at least) 4 homeworks due tomorrow, and you haven't done anything. That's nobody's problem but yours. You will get all the help you deserve here, which is approx zero. We're saving our time for people who are making a realistic effort themselves.