How can I truncate a double to only two decimal places in Java?
If you want that for display purposes, use java.text.DecimalFormat: If you need it for calculations, use java.lang.Math:
If you want that for display purposes, use java.text.DecimalFormat: If you need it for calculations, use java.lang.Math:
If I’m not mistaken, the “ffmpeg wrapper” project you linked to is out of date and not maintained. ffmpeg is a very active project, lot’s of changes and releases all the time. You should look at the Xuggler project, this provides a Java API for what you want to do, and they have tight integration … Read more
this should be an internal file of JRE and in general you shouldn’t deal with it when you’re running/compiling java. Here you can find an explanation of what exactly this file is intended for. Bottom line, your Java installation is somehow corrupted, so as a first resort to resolve this issue, I suggest you to re-install … Read more
Usage depends on whether the component’s parent has a layout manager or not. setSize() — use when a parent layout manager does not exist; setPreferredSize() (also its related setMinimumSize and setMaximumSize) — use when a parent layout manager exists. The setSize() method probably won’t do anything if the component’s parent is using a layout manager; the places this will typically have an … Read more
The real message is that Ant can’t find com.sun.tools.javac.Main. Which, together with the fact that the latest “Sun” (Oracle) JDK is 1.7.0_13 (or maybe _14, but definitely not the “_52” that your install dir indicates), makes me think that you’re not using a distribution that Ant recognizes. You can verify this by running jar tvf $JAVA_HOME/lib/tools.jar, and … Read more
This is a bug inside JRE. You can do nothing about this, just send a bug report to the link provided: http://bugreport.java.com/bugreport/crash.jsp Try to use 32-bit version instead of 64. Try to use another JRE version (not 6.0_27-b07).
I have to ask a question in return: is your GenSet “checked” or “unchecked”? What does that mean? Checked: strong typing. GenSet knows explicitly what type of objects it contains (i.e. its constructor was explicitly called with a Class<E> argument, and methods will throw an exception when they are passed arguments that are not of type E. See Collections.checkedCollection.-> in that case, you should … Read more
The repaint() refreshes the view (component), so whenever you make any change on the component, you must call it. For instance, if you rotate the graphical component, you must make a call to repaint() in order to see the change on the containing component
Like this: or (The latter syntax can be used in assignments other than at the point of the variable declaration, whereas the shorter syntax only works with declarations.)
You may use Graphics.drawPolygon(int[], int[], int) where the first int[] is the set of x values, the second int[] is the set of y values, and the int is the length of the array. (In a triangle’s case, the int is going to be 3) Example: Output: