« first day (1764 days earlier)      last day (3401 days later) » 
02:00 - 17:0017:00 - 00:00

02:05
knock knock?
Hi @DRich
Hi Don
How's it going?
* Hi @DonLarynx
Learning about multiple-player interactions, you?
Trying to figure out graphics
Any experience w/ that?
I've got experience in using Swing, what's up?
02:12
I'm trying to build the game Arkanoid
Arkanoid (アルカノイド, Arukanoido) is an arcade game developed by Taito in 1986. It expanded upon Atari's Breakout games of the 1970s by adding power-ups, different types of bricks, and a variety of level layouts. The title refers to a doomed "mothership" from which the player's ship, the Vaus, escapes. == OverviewEdit == The player controls the "Vaus", a space vessel that acts as the game's "paddle" which prevents a ball from falling from the playing field, attempting to bounce it against a number of bricks. The ball striking a brick causes the brick to disappear. When all the bricks are gone, the...
in case you're not familiar...
Step 1: draw the bricks on the screen
I'm running into a NullPointerException error
with my graphics object
I've got a JFrame
Cool! Where's the code you are expecting to receive the error?
Post it.
okay, give me a moment to slim it down to the essentials
public class Game {

/**
* @param args
*/

public String strGameState; //Valid GameStates = Started, Paused, Stopped

public static void main(String[] args) {

//Create the play area
JFrame board = new JFrame();
JPanel boardContentPane = new JPanel();

final int brickWidth = 50;
final int brickHeight = 20;
//Brick brick = new Brick(brickWidth,brickHeight);

Graphics g = boardContentPane.getGraphics();

//Set board attributes
board.setSize(650, 850);
board.setResizable(false);
board.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Don't think I posted that correctly; did I?
@DRich use Hastebin in posting your code
plau
err
okay
just pasted there; I've got it up
how do I send the link or whatever from there?
that it?
02:18
... remove my code above...
I don't have that edit option...
Don't think I want to flag for a moderator...
nevermind your time is already expired, you could no longer remove it
sorry about that
@DonLarynx, did I lose you?
@DRich I really don't see what can cause an NPE here, everything that was used as a parameter was initialized.
Okay, well that makes me feel a bit better
I've been doing a bunch of Googling as I'm sure you can imagine
I've been reading a lot about the paint and repaint methods
but since I'm just trying to draw rectangles on a JPanel, I don't think I want that
Is that right? Or do you think I should be working with "paint" somehow... ?
@DRich try using fillRect() now afrer using setColor()
02:28
so setColor(); drawRect(); fillRect() ?
@DonLarynx still giving me an NPE
@DRich Make a class called coloredRectangle where you create the rectangle inside the constructor.
I've got a class called "Brick"
it extends Rectangle
Show Brick constructor inside hastebin
@DonLarynx by the way- thank you for your help
Even if we don't get this figured out, I appreciate that you're devoting your time to this effort on a Friday night
Well, for Brick(), you should use super(0,0,0,0)
02:40
Alright, I've made that change
never mind, it does the same thing.
=]
> Constructs a new Rectangle whose upper-left corner is at (0, 0) in the coordinate space, and whose width and height are both zero.
btw, here's something interesting
no NPE
but... no rectangle either
Is there any way to use an ObjectOutputStream to write an object to a file, but it writes to the file in plain text?
not in binary?
02:44
@DRich You're drawing a rectangle on the JPanel
You never initialize a Rectangle object
... trying to, yeah
that shouldn't be required, should it?
as long as I give the position, the width, and the height, it should be able to draw it...
am I wrong there?
Okay, so I'm starting to get confused...
Hold on.
@cp101020304 Hi- I'm trying to see if I can help you while @Don
@DonLarynx helps me
@DRich thanks ^_^
I can show you how I'm writing/reading if that helps?
@cp101020304 Are you using BufferedInputStream/BufferedOutputStream?
02:49
I'm looking through some other material I have first; Honestly, I won't be sure how much I can help until I look through it
@DonLarynx I am using a FileOutputStream and ObjectOutputStream to write the object to the file
and using ObjectInputStream to read the object back
@DRich No worries, take your time :)
@cp101020304 is there a reason you're using ObjectOutPutStream instead of PrintWriter?
Well I googled how to write an ArrayList to file, and ObjectOutputStream was the most common answer. Does PrintWriter allow for entire objects to be written to file at once? Or do you have to code the logic manually? @DRich
okay, now's the point where I'm interested in seeing your code =]
02:55
brb
back
@DRich
Pretty simple to write an entire object to a file if you ask me. You can probably see why I'm looking for a way to keep this method of writing the object to file but also make it human-readable if the file was to be opened
okay, so there's a gap here: arraylist
What's in that?
It is ArrayList<myClass> where myClass is a class that has 3 fields (one string and two ints)
okay, cool
any ideas :D
03:02
yep
give me a second though
btw
you are my saviour
if I figure this out, I'm going to ask a favor of you
that favor being: post this as a question, I'll respond, and then flag my response as correct
It will be my first =]
of course :)
so, in summary
I'd suggest using a for loop to write the pieces of your class to the file one at a time
which can be done through PrintWriter
And what about repopulating the arraylist from the file
03:08
repopulating the arraylist from the file... ? What's the scenario?
the file contains "statistics" for users
so every time they launch the application
they should be able to see their own statistics
alright
for a simple game
should i ask the question now?
err... ask what question? you just asked a question about repopulating the array list..
are you referring to my favor?
no i meant on SO
yes
03:10
no, not until you've tested it out and gotten the result you're after
oh you're writing the code?
no, not yet- I'm thinking about your other question now
so
If you want to repopulate the arraylist from the file
I think you're going to need to use a Scanner
Are you familiar w/ Scanners?
Not really
Alright, so a scanner will take a text file and break it up into tokens that you can then work with
they're a bit finicky to work with, but I think you'll be able to manage
I'm making some assumptions here, but I think this will work for you
Assuming your file for statistics has rows of info in the string, int, int order this should work
real quick side note: are you working on an online course to learn Java?
@cp101020304
nope, just in school at the moment
been using it for a little bit
so don't know too much
03:17
alright, cool
do I come off as that much of a noob xD
hahaha, no- but your questions are along the lines of someone who's studying Java
anyway
so, your records file is a text file
each line in the text file corresponds to a record
and each record is laid out in string, int, int format
so far so good?
03:20
@DRich If you put the graphics code after you set the board visible, the NPE disappears
@DonLarynx I can't believe you've been working on this the whole time
You're the man
unless you're a woman
In which case, you're the woman
Thanks! (I am not the woman. I am the man.)
@DonLarynx, you're the man
Did it solve the NPE?
I don't know, I'm trying to help out @cp101020304 =]
03:22
OK
@DRich i'll brb in about 10 mins
cool
so, @cp101020304- load up the file: FileReader reader = new FileReader(<file containing current records>);
create your arraylist: <YourClass>[] <Name> = new <YourClass>[maxArraySize];
create the scanner: Scanner inputScanner = new Scanner(reader);
create an index: int i = 0;
use a do-while loop to load the values in the file into your array
do{
<Name>[i] = new <YourClass>(inputScanner.next(), inputScanner.nextInt(),inputScanner.nextInt());
i++;
} while (inputScanner.hasNext());
You now have an array with all your values
add new values to your array
<name>[i+1] = new <YourClass>(<newString>,<newInt>,<newInt>);
now you have an array with all the original values, plus the new value
print that out to a new file
File outputFile = new File(<outputFileName.txt>);
03:39
@DRich back
PrintWriter writer = new PrintWriter(outputFile);

for (int i=0;i<<name>.length;i++){
writer.println(<name>[i].getString(), + "\t" + <name>[i].getFirstInt() + "\t" + <name>.[i].getSecondInt);
}
Will try this, and report back in a bit, thank you!
writer.close();
Best of luck
fge
fge
Eh?
also as a warning: I'm somewhat new to this as well
fge
fge
03:40
Just use try-with-resources
Problem solved
What is more, use JSR 203
but what I've provided should be enough for you to work with
fge
fge
Ditch File
@DRich cheers buddy
also, fge is probably smarter than me
@cp101020304 you're welcome. Hope it's everything you need
fge
fge
@DRich not; I just happen to know a lot about Java and I/O, but that doesn't make me smart
03:44
if @cp
err
if @cp101020304 comes back with issues, maybe you'll be able to simplify things
btw
do you know much about graphics? =]
also @DonLarynx
the NPE is gone
The rectangle isn't drawn
but
no NPE
so, progress!! thank you!
@DRich btw did you mean an actual ArrayList in your response, because what you're creating in your code snippets is an array of objects
well, in the code I was referencing for the answer I had an array of objects
I figured the array list would behave similarly...
But I may have been mistaken
Ok cool, just making sure. Using an actual ArrayList simplifies the code even further
I'm writing it up now, i'll show you once I'm done
sweet
@DRich hey, if ur still having issues, let me know
03:58
@DonLarynx - I am. They're new issues though, so that's progress
basically the NPE is gone
but, still not shape on the screen
@DRich what new issues?
Ok
*still no shape
understood
I'm trying a few things, but if you have suggestions, I'd definitely try them out
03:59
ezpz
@cp101020304 hah! really?! That got the file output you were looking for?
Haven't tested it yet, but I'm fairly sure in myself that it will hahaha
still have to write the writing part of it
Alright, keep me posted. I'm still waiting to cash in that favor
I'm getting an error on this line:
writer.println(<name>[i].getString(), + "\t" + <name>[i].getFirstInt() + "\t" + <name>.[i].getSecondInt);
says the operator + is undefined for the type(s) String
oh never mind, there was an extra comma after getString() that wasn't supposed to be there
take out that comma after <name>[i]getString()
yeah
04:12
works :)
as promised
0
Q: ObjectOutputStream human-readable

cp101020304I am trying to read and write an ArrayList to a file, and currently using ObjectOutputStream to write to the file. fout = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fout); oos.writeObject(arraylist); fout.close(); The arraylist variable is an ArrayList of oje...

Awesome
@DRich
And I hate to cheat, but do you have the code that worked for you?
Just use the code from the pastebin link I posted above, I'll vote yours as the accepted answer
alright, cool
just want to make sure it makes sense for other people who might take a look, you know?
04:14
Thanks once again ^_^
no problem! I'm glad I could help! Give me 2 mins to put the answer to your question up
The only thing I changed from what you posted in the chat was the whole ArrayList thing and the PrintWriter is pretty much the same
Sure
@DRich quite a few answers already hahah
yo
@DRich
create a class that extends JPanel
@cp101020304, hahaha, yeah, I saw that
just posted mine... it seems odd though
Then put all of the properties you want on that JPanel inside that class.
04:21
1 second
Alright, my answer is ready to go
please accept/vote answered =]
@cp101020304
Says I have to wait 5 minutes to vote for it, so will do once that timer is up :)
@DonLarynx create a class that extends JPanel
so
instead of extending Rectangle I should extend JPanel?
@cp101020304 - cool, thanks for helping me get some credibility
No worries :)
@DRich Yes, and then remove new JPanel().
hmm... okay
04:25
Then make new JPanelThatIsExtended()
That JPanel will have all of the properties you give it
Make rectangles inside the constructor @DRich
alright, so if I'm understanding this correctly
If I want to have a grid of bricks 12 x 5
I'm going to have 60 different JPanels
is that correct?
No, you'll have 60 Rectangles inside the JPanel
@DRich done
@cp101020304 awesome, thank you, boss!
One JPanel per JFrame @DRich. Override paintComponent inside the class that extends JPanel. Use @Override and super.
04:29
thanks to you too! I'm off, cheers once again mate
cheers!
@DonLarynx - okay, cool.
So, I'll have one "Bricks" class
which will contain all my bricks
but the Bricks class itself will be an extension of JPanel
and the Bricks inside it will just be a bunch of rectangles
*and the individual bricks inside the Bricks class will be a bunch of rectangles
and each brick will be part of the constructor
yeah?
I Apologize. Bricks will be an extension of Rectangle. and your JPanel class (whatever you want to call it) will be an extension of JPanel.
Okay, but the important part is my JPanel class constructor will include the bricks (rectangle extension)
right?
Yes. The JPanel contains the Brick objects.
Got it
Alright, I'll work with this some more this evening
and probably tomorrow
thanks for your help!
I don't know if there's some way I can give you reputation points for this...
... is there?
04:37
Don't worry about it. I'm still working on it.
Alright, cool; don't work too hard
I'm going to head off for the time being though
I'll be back at this tomorrow, I'm sure.
Have a good evening, and thanks one last time =]
uh, wait
I'm literally almost there lol
hahahaha
alright, if you're almost there, I'm gonna sit tight
I had a project involving Swing last semester. I'm examining it now.
do have a class extending JPanel
cool
I just created a new class
ublic class GameBoard extends JPanel
04:41
@DRich In the class extending JPanel, make as many myClassExtendsRectangle from as many Rectangles as you'd like
Yeah, I'm hoping you can do that w/ an array
Still not seeing anything on my screen =\
I godda turn in though; it's pushing 1 AM
You've been a ton of help @DonLarynx
on the off chance I can help you with something in the future
well, I hope I'm in the right chat room when that question comes up
Have a good evening man
one of my printwriters isn't writing anything to my file :(
Morning
04:55
oh my lord, I didn't know that you had to close a printWriter in order for the data to actually be written :/
Well, you do now
(:
what would I do without google
always zip up your pants after peeing
@cp101020304 Probably this:
@user3781180 what if you're wearing trackpants though
they dont have zippers!
06:08
Does anyone know how to add a button to a JTable cell and action listeners to these buttons?
@DRich ??
Sorry, I do FX
06:34
Hi all... I'm trying to have a Map<String, Object> in my JPA / Hibernate Entity class. But, the value of Map (Object) can be any Boxed Primitive (Integer, Long, String) or another Customer Object. I know that we can use TypeConvertor or HibernateType to map custom java-types to SQL types. But, not sure how I can achieve this case. What would be the type of column in my join table (resulting from my Map) ?
@JohnSnow Would you know how to create an array of Objects from String/int?
i.e Object[] [] = new Object[][] { }
but I want to fill the array in a loop
That's a 2D array, is that what you want?
Sounds more like you want a list
yes I want a 2D array
so currently I am doing this
for (int i = 0;i<Main.list.size();i++){
			Object name = Main.list.get(i).getUsername();
			Object won = Main.list.get(i).getWon();

			scores[i][0] = name;
			scores[i][1] = won;
		}
list is an arrayList
You put a second for-loop inside the for-loop for the second part of the array
06:49
Shouldn't it work as it is though?
I only want two columns
It's not very dynamical though
hardcoding is bad practice
Ok, other than that do you see any issues?
Looks like you're using a static list
that's a bit smelly
yeah, im just testing if what I'm trying to do works and then I'll make the code adhere to coding standards
I just can't see the syntactical mistake here
wait
never mind
06:55
??
nothing
I just haven't done much Java lately
So I derped a little
07:23
o/
Morning ita
Morning!
Are you working on weekends?
Nope
I'm just up early
07:59
hmm
I need to write some code, but I am feeling lazy
me too
08:16
Leaving away from home has its adv's and dis-adv's!
Leaving?
living*
ah
I can imagine
Hello, I want to configure Tomcat 7.0 Server on my Eclipse Mars but I can't find the folder 'wtpwebapps' in my C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\. I been following steps in this tutorial www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html#undefined‌​.
I was on stage 6, any help
08:32
@Giovanrich where are you stuck?
@ItachiUchiha stage 6, I can't find the 'wtpwebapps' to paste ROOT
you don't have to
if you want to run your application using the server in eclipse
just add it on server and run
@ItachiUchiha but when I type localhost:8080 it is giving me a 404
I mean typing in the browser
you need to type localhost:8080/{name of the project}
6. Run Tomcat. Click on Servers tab at bottom. R-click on Tomcat v7.0, choose "Start". Open http://localhost/ in a browser (or http://localhost:8080/ if you downloaded Tomcat instead of using the preconfigured version, and then failed to change the port from 8080 to 80). Either way, you will see a 404 error message, but at least the message comes from Tomcat. Then, copy the ROOT app as described in the next section, come back, and reload http://localhost/ (or http://localhost:8080/ if using the unmodified version from the Tomcat download site). You should now see a friendly Tomcat welcome p
@ItachiUchiha I haven't created an application yet, i want to test it using my browser
@ItachiUchiha as described in the first paragraph above (that paragraph is step 5 and step 6 is the second paragraph - that is where I am stuck)
08:42
The description is correct
@ItachiUchiha but I cant see the "wtpwebapps"in my workspace to paste "ROOT"
That is where i am stuck
That is what I am seeing
@ItachiUchiha should I create the folders temp0 and wtpwebapss?
you shouldn't create anything
when you run your project on server via eclipse
eclipse does that fr ya
08:58
@ItachiUchiha Okay, so I should create a project first? I had just installed my Eclipse and there was no project; i was setting it up according to those steps
Well, I have seen it - I had to restart my Eclipse :)
@ItachiUchiha it worked very well when I reloaded, thanks
09:37
I'm thinking about making a Spring project
I wonder what's gotten into me
10:02
Morning
@JohnSnow you should
10:43
I am failing to install new software through Eclipse Market Place, it is giving me an error: repository not found for every URL. I am using Eclipse Mars when I set my network connections to Native and Direct the Eclipse internal browser begin to work but the repository not found error appears always. Any help? What could have gone wrong?
 
5 hours later…
16:03
hello
02:00 - 17:0017:00 - 00:00

« first day (1764 days earlier)      last day (3401 days later) »