|
Reminds me of my favourite eclipse bug: Only on windows! https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514
|
# ? Nov 5, 2010 06:00 |
|
|
# ? May 9, 2024 13:23 |
|
tef posted:Reminds me of my favourite eclipse bug: Only on windows! https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514 I ran into that when upgrading to u21 too, ended up fixing it with a shortcut argument. Really dumb. Other then that eclipse is pretty stable. Mine stays open for weeks at a time usually till I restart the pc.
|
# ? Nov 5, 2010 06:16 |
|
tef posted:Reminds me of my favourite eclipse bug: Only on windows! https://bugs.eclipse.org/bugs/show_bug.cgi?id=319514 Sorry tef, but the best bug is the one where the forward Delete key stops working in Eclipse after the machine has been up for about 3 weeks, only on OS X: https://bugs.eclipse.org/bugs/show_bug.cgi?id=283415
|
# ? Nov 5, 2010 14:01 |
|
tef posted:... or writing a web app in one of the myriad frameworks (i'd recommend python+django fwiw). You know, what I'm planning to eventually create would work well as a web app anyway. It's going to be a few simple learning tools for some of my Electrical Tech. students. I'll look into this option. Thanks everyone! At the very least, I can now write simple code in Java too...
|
# ? Nov 5, 2010 14:45 |
|
Probably hilariously dumb question, but I've stumped myself on it: I'm trying to get a Java program where I put up a JFrame with a button, then start a timer. If the button isn't clicked within a short time, the program moves on. I can't seem to get this to happen; I can run a timer before or after the JFrame, but not during. How do I set up a button where other things happen while listening for a click? Even better if I can interrupt on a click, but I don't need that nearly as much.
|
# ? Nov 6, 2010 02:59 |
|
ZeeToo posted:Probably hilariously dumb question, but I've stumped myself on it: What is happening in the JFrame when you start the timer? Can you post some code because it's really difficult to know what is happening by your description.
|
# ? Nov 6, 2010 03:14 |
|
Action Jackson! posted:What is happening in the JFrame when you start the timer? Can you post some code because it's really difficult to know what is happening by your description. Sorry, I thought that that would be enough. I copied an example out of a book and tried to adapt it as proof-of concept. Build2 sets up a pretty ugly, basic menu system. When you press one of the buttons, it spits the counter onto the screen. What's missing, because nowhere I tried to put it works and so I didn't see a reason to clutter this up further by leaving it in, was a do-while or the like with a counter++ line in it; the idea was just to have that running so I could see when I hit the button how long it had been running. What I was trying to do was find where in here it would be waiting for a click, and have some sort of timer or counter running (hence the counter variable that doesn't seem to be used). That doesn't seem to be how it works, so I'm asking for help. code:
|
# ? Nov 6, 2010 03:35 |
|
You can't use a while() { } loop because it's going to run on the same thread as the display, so it's going to block any ability for the Swing code to do anything until the while() { } loop breaks (inclusively, it will block your ability to interact with the JFrame). You may want to look into implementing a TimerTask[1] object that closes the JFrame and kick it off using Timer[2]. When the user clicks the button, just use the TimerTask object's cancel() method. I'd recommend using a class-level boolean to indicate whether or not the TimerTask has been cancelled. cancel() sets the boolean to true and the run() method will check that boolean before trying to execute. Because it's a multi-threaded application, I would recommend synchronizing around a lock object. If you're on Java 5 or greater, you can probably use a ReentrantLock object[3], or just declare a class-level Object and use it in a synchronized() { } object. 1. http://download.oracle.com/javase/1.4.2/docs/api/java/util/TimerTask.html 2. http://download.oracle.com/javase/1.4.2/docs/api/java/util/Timer.html#schedule(java.util.TimerTask, long) 3. http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/ReentrantLock.html
|
# ? Nov 6, 2010 15:50 |
|
I figured I couldn't use it, but I didn't know why. That looks like exactly what I needed; thank you!
|
# ? Nov 6, 2010 17:10 |
|
try-catch-finally is confusing me. So I have all this crap (some crap removed because it's irrelevant): code:
But 1) br is outside the scope of a finally block. 2) br's new FileInputStream() throws an exception, so if I move it outside the scope I need to put in a new try-catch block... and then that's outside the scope of a finally block. Help Commenting that my code is terrible is acceptable. Or link me to a good guide on try-catch-finally, thanks
|
# ? Nov 8, 2010 12:30 |
|
It's a stylistic pain in the rear end, basically:code:
|
# ? Nov 8, 2010 14:38 |
|
It's even worse when you want to declare an instance variable as final but its constructor can throw an exception.
|
# ? Nov 8, 2010 16:49 |
|
It's even worse when close() can throw an exception. So you have a try/catch/finally in your finally. I'm sure there's an xhibit joke I could be making here. Edit: I heard you like to close resources, so I put a try/catch/finally in your try/catch/finally so you can close resources while you close resources? epswing fucked around with this message at 17:02 on Nov 8, 2010 |
# ? Nov 8, 2010 16:58 |
|
Internet Janitor posted:It's even worse when you want to declare an instance variable as final but its constructor can throw an exception. code:
|
# ? Nov 8, 2010 18:19 |
|
Or just use this method: http://commons.apache.org/io/apidocs/org/apache/commons/io/IOUtils.html#closeQuietly(java.io.Closeable)
|
# ? Nov 9, 2010 01:27 |
|
Chairman Steve posted:Or just use this method: http://commons.apache.org/io/apidocs/org/apache/commons/io/IOUtils.html#closeQuietly(java.io.Closeable) code:
(everything must be final!!)
|
# ? Nov 9, 2010 02:34 |
|
Guys, please help me out. Why is the "America/Anchorage" timezone returning an offset of -10 hours from GMT? It's -9 usually, -8 in DST. It is never -10.code:
|
# ? Nov 9, 2010 11:02 |
|
Pivo posted:Guys, please help me out. Why is the "America/Anchorage" timezone returning an offset of -10 hours from GMT? It's -9 usually, -8 in DST. It is never -10. Looks like a straightforward bug. It also doesn't recognize "AKDT" or "AKST" at all. Historically, wikia tells us that some of the state is still in -10 and a large portion of the state used to be.
|
# ? Nov 9, 2010 11:08 |
|
Pivo posted:Guys, please help me out. Why is the "America/Anchorage" timezone returning an offset of -10 hours from GMT? It's -9 usually, -8 in DST. It is never -10. Are you running the absolute latest dot-release of the JRE? The time zone stuff does get updated from time to time in those.
|
# ? Nov 9, 2010 13:24 |
|
Ok, so i have just started learning java and wanted to make a app that uses swing to create a GUI interface. Anyway I encountered a problem with it that I can't really figure out. So first here's the interface: What the buttons does: Legg til: Allow you to add a triangle to a array.(Max 5) Areal: Calculates area for a given array. Roter: Rotates a triangle. Vis Data: Show's data. Avslutt: Exit's the program. The radiobuttons allows you to select a given triangle and draws it like this: The problem: Well the problem occurs when i follow these steps: 1.Draws a triangle by selecting its radiobutton. 2.Select the Show data or Area button. 3.Selects a new triangle from a radiobutton. Now I have to press the Show data or Area button twice before they will display data, the first time I select a triangle and then selects the show data/area buttons everything is fine. Anybody know what is causing this and how to prevent it? Here is the code for the Area button(Identical to the Show data button): code:
code:
code:
If you have any questions don't hesitate to ask! HKBGUTT fucked around with this message at 22:15 on Nov 9, 2010 |
# ? Nov 9, 2010 22:12 |
|
Flobbster posted:Are you running the absolute latest dot-release of the JRE? The time zone stuff does get updated from time to time in those. Yep. The problem was, in my web application, I need to store a time in a MySQL TIME column. To generate the time to store in that column, I create a Calendar object, set it to Jan 1 1970, set the HOUR_OF_DAY/MINUTE/SECOND to the appropriate time, and then write the timeToMillis() value to the database. This works for all cases EXCEPT where the time zone has changed. In 1970 America/Anchorage was GMT-10, nowadays it is GMT-09. I fixed the issue by using today's date, but in case DST is active, setting DST_OFFSET to 0. We need to store the time in the database to be DST-agnostic, since we apply DST after-the-fact (since the column stores a TIME it does not refer to a specific date and would not make sense to be stored adjusted for DST at the time it was recorded) Time zone sensitive code sucks so much. Now I need to comb through all my code that uses that table to make sure it doesn't make the Jan 1 1970 assumption. Everything worked for time zones that don't change! Why did those drat Alaskans have to screw with my poo poo
|
# ? Nov 9, 2010 22:56 |
|
I think the solution to that is to store it as a timestamp which MySQL stores internally as the number of miliseconds since Jan 1, 1970. Then when you ask it for the time it will return it untouched, and in your Java program you can apply the correct offset.
|
# ? Nov 9, 2010 23:51 |
|
MEAT TREAT posted:I think the solution to that is to store it as a timestamp which MySQL stores internally as the number of miliseconds since Jan 1, 1970. Then when you ask it for the time it will return it untouched, and in your Java program you can apply the correct offset. When I designed this feature, I was thinking about data integrity/correctness. If we store a timestamp in MySQL, there is an implied year/month/date there. This is incorrect, we are storing a time of day e.g. 5:00 PM. We later use this time and extrapolate it to multiple dates, e.g. this action occurs every Tuesday from this day on at 5:00PM. So storing any implied date in the database is incorrect in this case. As a hack it can be done but I don't like it. Using Jan 1 1970 as the date when working with Calendar was a hack in itself but it worked. I guess it was foolish of me to assume no timezones have changed in the past 40 years. Pivo fucked around with this message at 00:33 on Nov 10, 2010 |
# ? Nov 10, 2010 00:30 |
|
Aleksei Vasiliev posted:or just use this Why does everything need to be final here? Pivo posted:
Why bother shoehorning what you want into Timestamp or Date objects at all? Why not store it as a number representing milliseconds past midnight? The Java Date/Time APIs are pretty deficient here because, as you noticed, they force everything to be a Date; you can't just have a timespan or HH:mm:ss. Once you have millis past midnight, you can construct a Date or Calendar that represents whatever day you want at midnight in your desired timezone. Then just add the millis past midnight.
|
# ? Nov 10, 2010 03:04 |
|
Outlaw Programmer posted:Why does everything need to be final here?
|
# ? Nov 10, 2010 03:33 |
|
Outlaw Programmer posted:Why bother shoehorning what you want into Timestamp or Date objects at all? Why not store it as a number representing milliseconds past midnight? The Java Date/Time APIs are pretty deficient here because, as you noticed, they force everything to be a Date; you can't just have a timespan or HH:mm:ss. That's pretty much what I'm doing. SQL TIME column is millis past midnight, or at least JDBC gives you an object that returns millis past midnight. The only issue with this is that the millis past midnight have to be normalized to the same timezone before being inserted into the database, which is what I was doing with my Jan 1 1970 Calendar object. From an architectural point of view I probably screwed the pooch there, I should have just stored the time in the input timezone, but I have to live with the decision that for example if you give me 3PM Alaskan time, it's gotta be stored in the database as 7PM Eastern time. Pivo fucked around with this message at 10:03 on Nov 10, 2010 |
# ? Nov 10, 2010 09:56 |
|
I need to parse a document that has the following structure:code:
code:
|
# ? Nov 10, 2010 16:54 |
|
Carthag posted:But I can't find any methods on Element for iterating sequentially on them like this? Element is a subclass of Node, so your code should work just fine? Edit: the reason your code is not working is because you can't get the text contained in an element by calling getNodeValue() on it - that always returns null. The text you want is in the child of that element node as a text node, so what you want to do instead is: code:
aleph1 fucked around with this message at 17:45 on Nov 10, 2010 |
# ? Nov 10, 2010 17:34 |
|
I'm having a problem with type erasure on two of our Intel Macs that isn't occurring on any other machines, Linux or Windows. Somebody checked in some code that looks about like this: php:<? class User { public static int updateUser(final List<Product> products, final Connection conn) {...} [...] public static void updateUser(final List<Organizations> orgs, final Connection conn) {...} } ?> Here's the Java version from the OSX machine: code:
code:
|
# ? Nov 10, 2010 22:47 |
|
oRenj9 posted:I'm having a problem with type erasure on two of our Intel Macs that isn't occurring on any other machines, Linux or Windows. Somebody checked in some code that looks about like this:
|
# ? Nov 11, 2010 00:14 |
|
I'm in need of a little java help for school. We're currently working on Programming Othello/Reversi whatever the gently caress you choose to call it by using recursion. Now I've gotten mine to work for the most part however the left column and bottom row aren't playable because my recursion decides to check out of bounds and eclipse returns an error. I haven't for the life of me a clue on how to fix it. My other problem is that we're required to have some form of A.I to play against. It doesn't have to be smart but I haven't a clue on how to program any form of A.I and our teacher for the class didn't teach us how to do it either. So I'm coming to the goons for help. Anyways, Here's my recursion for checking to the left it works for every column besides the last one. Obuttons being the name for my game board array, everything else should be somewhat self explanatory? code:
code:
code:
|
# ? Nov 11, 2010 01:23 |
|
oRenj9 posted:I'm having a problem with type erasure on two of our Intel Macs that isn't occurring on any other machines, Linux or Windows. Somebody checked in some code that looks about like this: That shouldn't compile. Generics are only checked at compile time and are then discarded so the bytecode produced actually looks like this: code:
|
# ? Nov 11, 2010 02:18 |
So I'm trying to write my first Swing app and I'm a bit confused on how I switch between panels and how they are supposed to talk to each other.code:
|
|
# ? Nov 11, 2010 02:29 |
|
Contra Duck posted:And since you can't have two methods with the name and parameters, the compiler should fail. While this is indeed a restriction on the Java language which OpenJDK's compiler apparently doesn't enforce correctly after type erasure, the JVM itself allows overloading based on the return type, which is presumably why the erased code loads and runs.
|
# ? Nov 11, 2010 03:08 |
|
aleph1 posted:Element is a subclass of Node, so your code should work just fine? poo poo, of course. This works: code:
|
# ? Nov 11, 2010 09:21 |
|
Diametunim posted:(...Othello stuff...) If that's not correct, I'd need to see some more code.
|
# ? Nov 11, 2010 15:53 |
|
_aaron posted:I'm not sure what your fleft method does, but you pass the value at the actual clicked row and column to that method, but when you do if check for different, you're using the column - 1 (or the row + 1). I'm obviously not familiar with the rest of your code, but my guess is that clicking the far left column gives you a column value of 0; when you subtract 1 from this, you get -1, and that's not a valid array index, hence your exception. Same thing for the bottom row - adding 1 will put you outside the bounds of the array. code:
I think? I hope I'm explaining that right. But I solved my problem. Thanks for your help.
|
# ? Nov 12, 2010 03:49 |
I'm running into a problem with input. When doing this, sometimes my player entity will simply stop moving for reasons I can't explain. It didn't seem to happen with any other style of input polling. Are there any glaring logic errors here?code:
|
|
# ? Nov 12, 2010 06:43 |
|
Either max acceleration is being set to zero or the directionQueue is empty after a key release event from what you've shown here. Is this threaded? What class is directionQueue?
|
# ? Nov 12, 2010 08:30 |
|
|
# ? May 9, 2024 13:23 |
baquerd posted:Either max acceleration is being set to zero or the directionQueue is empty after a key release event from what you've shown here. Is this threaded? What class is directionQueue? DirectionQueue is local to the InputMan class. Yes, this is multithreaded. I do not know where acceleration could be changing. Max acceleration is constant. EDIT: Whaaa? Added some more print statements: jo@Euclid:~/source/tilegame/dist$ java -jar Tilegame.jar KEY DOWN:S KEY UP:S KEY DOWN:S KEY UP:S ... This is from HOLDING the 's' key. Why would multiple key events be generated from a single key hold?
|
|
# ? Nov 12, 2010 08:54 |