Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
VegasGoat
Nov 9, 2011

SperginMcBadposter posted:

It still works, but something about it being threaded now is making that java.util code poo poo out that exception whenever the stream doesn't have anything to be read.

Did you change the socket to non-blocking at some point while troubleshooting? If so put it back to blocking mode.

Like Janitor Prime said you also need to update the GUI from the event dispatch thread. So in your ReadThreaded class instead of calling displayString() directly you'd call SwingUtilities.invokeLater() with a different Runnable object that calls displayString(). It might seem like overkill, and the program may even seem to work without that but at some point you will see weird behavior like parts of the GUI not updating, or text being cut off or something like that.

Adbot
ADBOT LOVES YOU

VegasGoat
Nov 9, 2011

samcarsten posted:

I'm not sure what the difference between the two is, though.

Might help if you read the description of those methods on the Collection interface you’re implementing for this assignment. It explains how they should work.

https://docs.oracle.com/javase/8/docs/api

Choose Collection from the list on the left to see the info for that interface and you’ll see those same toArray methods.

You can literally use “T” as a type in the second one if you weren’t aware.

VegasGoat
Nov 9, 2011

Tesseraction posted:

On my phone but from a glance it looks like here


Java code:
teamStats.put(team.get("Team"), elementStats); }
you're assigning the elementStats Map to every entry in teamStats, which is why the printed output is the same printed object's position in memory.

I might be misunderstanding but could you either comment or pseudocode what you're trying to do there and also what you expect it to print instead of what you showed in your post?

Yeah probably just needs to move the elementStats = new… inside the records loop so each team has its own elementStats.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply