-
Replied To a Post in Circle Rectangle Side collision.
You can check for the two `Shapes` (ellipse and rectangle) intersecting. Which side is then just a tedious testing of the x and y coordinates. Bouncing off a side of … -
Replied To a Post in GUI Layout Manager
It looks like you have been experimenting with a variety of layout mangers! Firstly - have you seen the Oracle tutorials - they are excellent. They start here: https://docs.oracle.com/javase/tutorial/uiswing/layout/using.html In … -
Replied To a Post in Circle/ball collision problem....
Yes, in my code dx and dy are the speed in the x and y directions. If things stop moving that may be a result of using int calculations rather … -
Replied To a Post in Circle/ball collision problem....
> he nice thing about circles is that it's extremely easy to determine if/when they collide with each other ... Collisions at an angle are much more involved. Not too … -
Replied To a Post in Circle/ball collision problem....
No time for a proper answer now, but here's some code I use that I modified from something on the web that bounces balls a and b that have position … -
Replied To a Post in Automatically moving a Bot trough a Maze using the right hand rule
> If I let the programm run it prints out an infinite number of the maze I choose It looks like the program wil print the entire maze each time … -
Replied To a Post in Different printers
Can’t you just use the page width that the PrintFormat parameter will give you? -
Replied To a Post in Renderer Not updating
The "first version" is from your "I've changed this..." post - where you have one class for the game JPanel and another class (extends JFrame) for the main window, For … -
Replied To a Post in Renderer Not updating
Leaking in constructor... The language spec only guarantees that the new object will be in a complete and consistent state *after* the constructor has finished. When you add the key … -
Replied To a Post in Renderer not updating
> first time the renderer gets called i get a null You create a BallGame before you create a GameThread, but BallGame creates the window and makes it visible, which … -
Replied To a Post in Renderer not updating
I'm not sure, but my best guess is... you add gamePainter to the JFrame after makingthe JFrame visible and don't pack() or invalidate() or anything else, so gamePainter may well … -
Replied To a Post in Renderer not updating
ps: I don't think ypur class structure is helping here... your GameThread class 1) Isn't a thread 2) Extends JPanel, but is never visible 3) Has lots of painting code … -
Replied To a Post in Renderer not updating
Like he said... plus specifically: do you get "in here" printed 30 times per sec? -
Replied To a Post in Renderer.repaint(); null pointer
Interesting link - one man's opinion even if it's not so mainstream. What he says about java,util.Timer and javax.swing.Timer is basically right, which is why the [ScheduledThreadPoolExecutor](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ScheduledThreadPoolExecutor.html) is the recomended … -
Replied To a Post in Renderer.repaint(); null pointer
No, you call `run` directly in the constructor and that calls `repaint`, which results in a call to `paintComponent` - which may be before the constructor is finished, depending on … -
Replied To a Post in Renderer.repaint(); null pointer
Looks l;ike a very interesting bug starting with `ballGame = new BallGame();` in main. First, `new BallGame()` is called. That constructor calls `Renderer.repaint()` which executes `BallGame.ballGame.Repaint(g); ` then, and only … -
Replied To a Post in Renderer.repaint(); null pointer
We don't know which line is the 16th in your editor! Please be more explicit. > comment out the while (running) { and } ...Thats exaccly what i dont want … -
Replied To a Post in Is DW alive?
It seems there's a problem where Google has been failing to give enough prominence to sites like DaniWeb when people search for IT help, so please tell all your friends … -
Replied To a Post in Renderer.repaint(); null pointer
> public Renderer Renderer; You have a variable with exactly the same name as a class. Surprisingly this is valid Java, but it's making your code imcomprehensible. It would be … -
Replied To a Post in What is latest version of Oracle ERP Cloud Solution ?
We are here to help people who are trying to work hard and learn. We are not here to do Google searches for people who may be too lazy or … -
Replied To a Post in Payment Integration
I think the obfuscation/hacking issue is much over-rated. Although decompiling and modifying a jar is possible, few people have the necessary skills and even fewer can be bothered unless it’s … -
Edited Java. Can you explain me this sorting function?
It sorts names in ArrayList, but how exactly does it happen? public void sortStudentsAlphabetic() { int i, j; Student temp; Student[] array = new Student[studentsList.size()]; for (int k = 0; … -
Replied To a Post in Java. Can you explain me this sorting function?
It's called a "bubble sort" - just Google for details. Apart from tjhat it just copies a List of students into an array so the sort will be fast, sorts … -
Replied To a Post in Subtraction of amount (DecimalFormat) from textField and insert it to db
That's what you get if the text field does not contain a correctly formatted decimal number ie it must contain exactly one decimal point and at least one digit and … -
Replied To a Post in Subtraction of amount (DecimalFormat) from textField and insert it to db
Yes, that was just an example of how to use the constructor. You get the String from the JTextField, then pass it to the constructor, eg BigDecimal vbd = new … -
Replied To a Post in Subtraction of amount (DecimalFormat) from textField and insert it to db
If you want to convert a String (eg from a JTextField) to a BigDecimal you can use one of BigDecimal's constructors... String s = " 1234.56"; BigDecimal bd = new … -
Replied To a Post in JSP code to delet file in client side
> It would cause quite some security concerns if it did. Indeed. Do you really think browsers and users will have zero protection against some random web site deleting their … -
Gave Reputation to stultuske in Help on trying to print a return statement...
the `else` is not needed, since either the `if` condition evaluates to true, and `return 5.00;` is executed, or it skips the if-block and goes to the next statement. With … -
Replied To a Post in Help on trying to print a return statement...
OK, redundant keyword? -
Replied To a Post in Find numbers divisible by 3 and 4
Thats 100% pure standard Java SE. It uses Streams, lambdas, and method references, all introduced with Java 8 in spring 2014. Most Java courses are still waiting to be updated … -
Replied To a Post in Find numbers divisible by 3 and 4
Which post/code are you referring to - there's Java, Ruby, APL and English so far. -
Replied To a Post in Find numbers divisible by 3 and 4
Ah yes, APL. In 1970 I was given my own APL golfball for coding on a 16kB IBM 1130 computer. I used it to write an assembler for an IBM … -
Gave Reputation to Reverend Jim in Find numbers divisible by 3 and 4
Just for fun, if you have two values, lo and hi, the following line of APL displays the required values: ((0=3|r)∧(0=4|r))/r ← lo, lo + ⍳ hi - lo -
Replied To a Post in Find numbers divisible by 3 and 4
Well.... yes. It was inspired by the Ruby `each_slice(5)` thing that pty posted. It looked like a neat and useful thing that Java doesn't have. So I started out trying … -
Replied To a Post in Find numbers divisible by 3 and 4
> I haven't been able to come up with a really elegant way to print 5 values per line... OK, a bit off-topic, but I wanted to share this with … -
Replied To a Post in Find numbers divisible by 3 and 4
No worries - "praise where praise is due" If I were to write that the only changes I would make would be: 1) Some kind of very simple validation on … -
Gave Reputation to John_165 in Find numbers divisible by 3 and 4
Thanks all . I finally solved it. import java.util.Scanner; public class Chapter4 { public static void main(String[] args) { final int NUMBER_PER_LINE = 5; Scanner input = new Scanner(System.in); int … -
Replied To a Post in Find numbers divisible by 3 and 4
Conmments are attached to up and down votes, so unless yiu want to up/down vote, a simple reply is fine. -
Replied To a Post in Find numbers divisible by 3 and 4
Yes, I'd say beautiful. The equivalent in Java is quite pretty too... int lower = 16, upper = 99; IntStream.rangeClosed(lower,upper) .filter(i -> i%3 == 0 && i%4 == 0) .forEach(System.out::print); … -
Replied To a Post in Find numbers divisible by 3 and 4
OK folks, getting a bit off-topic here?... it's Java. John: I don't see how you got from the problem definition to that code. It looks like you have tried to … -
Replied To a Post in Java update
There's no need to be rude. A polite request will get a better response. -
Replied To a Post in Please help me with this homework
> heyy can anyone please help me with this homework yes, there are many people here who will help you. But that means "help you to learn how to d … -
Replied To a Post in Anyone can tell me why the int "Underflow" and "Overflow" does not occur?
The C++11 Standard says that signed integer overflow/underflow behaviour is "undefined", so any compiler can legally do whatever it wants, including ignore it. Ignoring it (on normal computers) is a … -
Replied To a Post in Project C++: A player engine for RPG fighting
Sam: You have not asked a sensible question. We have no idea of what you already know or what help you need. Please read the link RJ gave you and … -
Gave Reputation to Reverend Jim in Project C++: A player engine for RPG fighting
You might as well have said "I have the following code:" int main() { } "I just need a little help with the middle." Please read [this thread](https://www.daniweb.com/programming/threads/435023/read-this-before-posting-a-question) for suggestions … -
Replied To a Post in Memorable Quotations
> Half of the U.S. population reads a newspaper. Half of the U.S. population votes. Let’s hope it is the same half. Ironic. Half the UK population reads the Daily … -
Replied To a Post in Theater GUI
No, changing the names of the local variables will still leave the class variables uninitialised! The mistake is to re-declare those fields/variables in the constructor. You do not want local … -
Replied To a Post in Need find words in a given set of letters
Yes. I was amazed by the performance. Loading the map with over a quarter of a million words from an official scrabble list takes under a second. Searching for anagrams … -
Replied To a Post in Need find words in a given set of letters
After that discussion I implemented a general version that works correctly. It takes each word in the dictionary and sorts its letters into ascending order then adds that to a … -
Replied To a Post in Why can't I get all of my student records to print out using the methods?
Given the simplicity of the showAll loop, there really are two instances of Carol, so either that's what the test run input data had, or its a bug in the …
The End.