|
Ranma4703 posted:They also do multiple return statements in methods often, which I thought was another no-no.
|
# ¿ Mar 18, 2008 23:42 |
|
|
# ¿ Apr 27, 2024 07:29 |
|
Fehler posted:Also, is it correct that Swing is the one with that ugly blue-silverish GUI? Any way around that? Edit: beaten
|
# ¿ Mar 30, 2008 23:26 |
|
Whilst farting I posted:but I can't find any information on how to make the program wait on a non-input dialog basis. code:
|
# ¿ Apr 9, 2008 11:37 |
|
Drumstick posted:this is what i have right now. My hope is that this will assign a random boolean to each location within the array. Will this function how I would like it to?
|
# ¿ Apr 10, 2008 22:59 |
|
clayburn posted:It looks like I have another problem with my HashMap involving collisions. Looking at my data set, I know for a fact that collisions are happening, and this is causing problems for me. Every time that I search for a value at a specific key, I only get one of the values, where sometimes I may want the other value. For example, if "foo" and "bar" are stored at the same key, I will only ever get "foo" even though sometimes I may want to find any string that is not "foo." Is there any way to go about this? I have read the API entry for HashMaps over and over and cannot seem to find a solution to this.
|
# ¿ Apr 23, 2008 17:03 |
|
triplekungfu posted:I'm not entirely clear on what you're trying to do, is that part of a JSP?
|
# ¿ May 21, 2008 18:17 |
|
The easist getaround for this is to move all your code from main() into the constructor, and then add a call to new ABC() in main().
|
# ¿ Jun 9, 2008 18:14 |
|
http://www.devdaily.com/java/jwarehouse/jazzy/src/com/swabunga/spell/event/SpellChecker.java.shtml?
|
# ¿ Jun 10, 2008 18:25 |
|
fletcher posted:ArrayList<Double> pointsList = aggregatedPoints/dataSetSum;
|
# ¿ Jun 19, 2008 23:21 |
|
code:
oh no computer fucked around with this message at 14:11 on Aug 23, 2008 |
# ¿ Aug 23, 2008 13:58 |
|
Ahh, it just seems to be a problem with writing stuff that big onto the console I think. I just created a text file and used a FileWriter to write the result to that and it works fine for much larger numbers.
|
# ¿ Aug 23, 2008 16:16 |
|
MEAT TREAT posted:I'm not sure if that's a real warning or just a false positive.
|
# ¿ Aug 28, 2008 20:13 |
|
Mill Town posted:That won't catch a NullPointerException though. You'll have to add a second catch block for that.
|
# ¿ Aug 28, 2008 21:16 |
|
Capc posted:For a small project at school we're supposed to round a number to the nearest 5 using Math.ceil().
|
# ¿ Sep 21, 2008 21:20 |
|
Try it using the full path, like "C:\\Images\\pumpkin.jpg" (or whatever) if you're on Windows. I think if you don't it needs to be in the same directory as the .class file (bin?)
|
# ¿ Oct 19, 2008 11:08 |
|
Lazlo posted:Basically if you want to be able to print the object in a way that makes sense, you need to define your own toString() method in Calc: public String toString() { return name; } or whatever best suits your needs.
|
# ¿ Oct 27, 2008 23:44 |
|
Collections.shuffle() shuffles a List object. You'll probably want an Arraylist.
|
# ¿ Nov 4, 2008 18:57 |
|
Not at a compiler so I can't check this, but something along the lines of:code:
|
# ¿ Nov 4, 2008 19:00 |
|
While that's true, it won't necessarily stop the same number coming up more than once.
|
# ¿ Nov 4, 2008 19:47 |
|
In my example (assuming it works) you're creating an array of [1, 2, 3, 4, 5...] and then shuffling it so you know the numbers are different. I think that's what he was asking, maybe I'm reading the problem wrong.
|
# ¿ Nov 4, 2008 19:57 |
|
I completely agree with what you are saying, I'm just saying that as far as I understand the problem, he needs to permute a list of distinct integers (or objects) to seed a tournament. You can't have the same team playing twice at the same stage, or leave teams out. Like I say I might be completely misunderstanding him. I think #cobol (who uses IRC in this day and age?!) probably suggested he shuffle an array to get around this without noticing that he had his Random inside the loop. There are other ways to achieve this, I was just showing him how to use Collections.shuffle(). oh no computer fucked around with this message at 20:36 on Nov 4, 2008 |
# ¿ Nov 4, 2008 20:32 |
|
List is an interface, you can't instantiate it. What errors was my code throwing out of interest?
|
# ¿ Nov 4, 2008 21:12 |
|
Really common beginner error, never use == on Strings. Use .equals() Edit: as in if (choice1.equals("yes") || choice1.equals("Yes"))
|
# ¿ Nov 28, 2008 22:33 |
|
I haven't seriously coded in Java for about 10 years, but I'm looking for a new job in the next few months so I'd like to get back into it in case any Java Dev jobs come up (that I'll still probably get rejected for due to the aforementioned lack of recent experience). I still have a couple of Java programming books I could use to refresh my memory, but they are for Java 5, and a cursory Google shows that Java is now on version 10. Has the language changed enough that it would be worth me looking into using some more up-to-date learning materials, or would I be alright re-learning from the books I have and then just learning about the more recent changes afterwards?
|
# ¿ Jun 18, 2018 21:16 |
|
I have Core Java by Cay Horstmann which is written for people already familiar with programming, though not necessarily OOP so it does go over those concepts again. It also has lots of notes throughout as to how Java differs from C++ if that's helpful. There are two volumes (Fundamentals and Advanced Features) and they are quite big but most of it is code examples that can be skimmed. He also has a version which apparently combines the two volumes into a condensed version called Core Java for the Impatient, though I don't know if that's any good.
|
# ¿ Oct 1, 2018 17:47 |
|
FYI if you do go for that Heads First book note it's currently in a humble bundle with a bunch of their other books in the $15 tier: https://www.humblebundle.com/books/head-first-books?hmb_source=navbar&hmb_medium=product_tile&hmb_campaign=tile_index_2
|
# ¿ Oct 1, 2018 21:36 |
|
I have a class GameTile that extends JPanel and whose paintComponent method that just draws a String (which is the value of the tile) and a thin rectangular border. I have a GameBoard which extends JPanel and is set up to use a 4x4 GridLayout, this panel is then added to a JFrame's contentPane. GameBoard stores the state of the board as a 2D GameTile array where each element either points to a GameTile object or null. The paintComponent method of the GameBoard is below: code:
GameBoard also implements KeyListener to listen for up, down, left or right arrow keys, and calls the move method for that direction before repainting: code:
I know that this means that the call to repaint() above isn't doing what I think it's doing and I should be calling repaint() somewhere else but I really can't think where. Since resize and minimise fix it I thought that maybe I should be repainting the JFrame, but I tried adding a manual call to that but it didn't help. edit: revalidate() you loving idiot oh no computer fucked around with this message at 16:33 on Feb 20, 2019 |
# ¿ Feb 20, 2019 16:18 |
|
Yeah I'm not trying to make games only getting some general practice in with GUI stuff. Although on a related note I haven't really coded in Java since version 5 - is Swing completely dead now? If so I'm guessing JavaFX has replaced it? I guess I should probably look into learning that?
|
# ¿ Feb 21, 2019 18:22 |
|
|
# ¿ Apr 27, 2024 07:29 |
|
Edit: nevermind, worked it out
oh no computer fucked around with this message at 13:51 on Apr 10, 2019 |
# ¿ Apr 10, 2019 13:48 |