Chris Mary wrote:Hi,
Below is the code
The problem is after the image is written, the font size is small when i opened it
Brian Cole wrote:Math.floor() is your friend.
[edit: Many edits. Replaced the original naive implementation with an ugly-ish one. Fought with the syntax highlighter.]
This does detect, to 3 places, that:
3.1756 is the same as 3.175 -3.1756 is the same as -3.175 0.0 is not the same as Double.NaN 2.3e304 is not the same as 2.4e304
Campbell Ritchie wrote:Agree. I hope there isn't some lecturer giving their students that sort of question.
Tim Holloway wrote:The whole question is bogus. . . . .
Harold Tee wrote:Methinks the string approach is simpler.
Mind you, you still have that age old problem with math operations which amplify the storage precision,
e.g isEqual ( (2.3 / 10.0) , 0.23) will not be equal.
Campbell Ritchie wrote:No, the cast rounds towards 0, so you get 5678.
value [meaning the property returned by getValue()] is the most recent valid content of the field, which may not be the current content of the field if an edit is in progress. Because of this, it is usually wise to call the field's commitEdit() method before calling getValue().*
*Especially if the focusLostBehavior property is set to PERSIST. In other cases it is likely that the field lost focus (causing its value to be committed or reverted) when the user clicked on the button or other GUI element that resulted in this call to getValue(). Calling commitEdit() is easy enough that it makes sense to do it unless you're sure that it isn't required.
Pressing the mouse on top of a button makes the model both armed and pressed. As long as the mouse remains down, the model remains pressed, even if the mouse moves outside the button. On the contrary, the model is only armed while the mouse remains pressed within the bounds of the button (it can move in or out of the button, but the model is only armed during the portion of time spent within the button). A button is triggered, and an ActionEvent is fired, when the mouse is released while the model is armed - meaning when it is released over top of the button after the mouse has previously been pressed on that button (and not already released).
Tim Holloway wrote:I ended up getting a big fat O'Reilly book on Swing and discovering the Sun Swing tutorials. Hopefully the book has been updated, since I just checked and it's for Java version 1.2!
Campbell Ritchie wrote:That could have shown return this; or return new Test3();
By the way: which section in the JLS?
Campbell Ritchie wrote:You can still write rubbish like...and it will both compile and run with the expected result.
it would have been clearer to just write Animal.staticMethod(...) and be done with it
Ricky Bee wrote:but let me rephrase my previous question (and steer it a little from the inheritance of a static method problem which originated it in the first place):
Ricky Bee wrote:is such a structure a common-place in Java programing? I mean, is it normal to instantiate an object from a superclass and then pass it an object from a subclass?