|
Is there a way to convert the RGB value of a BufferedImage pixel into hex? Alternatively, can the value of a pixel be gotten and set using hex?
|
# ¿ Dec 19, 2008 05:56 |
|
|
# ¿ May 20, 2024 07:29 |
|
Oh, ok. I just wanted to know if there was an easier way of doing it that dvinnen said.
|
# ¿ Dec 19, 2008 06:30 |
|
dvinnen posted:So I've been working on this applet/servlet combo for a while now. The applet communicates with a servlet that collects data and sends it back to the applet via HttpsURLConnection. I'm using an unsigned cert for now as everything is on my dev machine. You're missing a variable name. Shouldn't it be code:
|
# ¿ Dec 30, 2008 00:48 |
|
The ternary operator way to do it would be quite a bit faster, too. Modulus is a pretty long operation for the CPU.
|
# ¿ Jun 16, 2011 14:37 |
|
If it's private, you do, if it's public you don't.
|
# ¿ Jun 23, 2011 03:18 |
|
It looks like it's just not getting any matches. Try a .contains("`") to see if the character is being detected properly.
|
# ¿ Jun 23, 2011 18:01 |
|
You could try a JDialog with the Modal property set to true. Execution of the parent frame pauses until the dialog is disposed of. CropDialog is the dialog you're doing the selecting in.code:
Ensign Expendable fucked around with this message at 19:10 on Jun 30, 2011 |
# ¿ Jun 30, 2011 19:07 |
|
Why is every single Swing component designed in the most obtuse way possible?
|
# ¿ Jul 19, 2011 04:18 |
|
import java.util.InputMismatchException;
|
# ¿ Jul 24, 2011 18:25 |
|
Scanner has its own imports in its source. Importing a class that imports something else doesn't import its imports.
|
# ¿ Jul 24, 2011 18:35 |
|
The "throws" clause tells methods calling that method that somewhere in your method, an exception of that type may be thrown. Those methods should either catch that exception of throw it themselves so another method would have to handle it. It's a bad idea to use recursion when you don't have to since it pollutes the stack with method calls needlessly. If the user enters a wrong file enough times, it will crash the JVM. On Java this isn't so bad, but in other programming languages this is a serious security flaw.
|
# ¿ Jul 25, 2011 18:08 |
|
When I was taught Java, the really basic stuff was taught using a package called Console that took care of the really basic IO and graphics stuff. Later on, they taught us Swing with more graphical ways to get input, and then Scanner/BufferedReader/FileWriter/etc.
|
# ¿ Jul 26, 2011 04:16 |
|
Why bother throwing anything? Just suppress it! If the stack trace is never printed, that means it never happened!
|
# ¿ Jul 26, 2011 23:53 |
|
If it gets stuck into an excel spreadsheet, you can set the formatting for those cells to have two decimal places displayed programmatically through Excel, but it's a giant pain in the rear end to get Office Interop working with Java in the first place, let alone actually doing useful things with it.
|
# ¿ Aug 3, 2011 14:04 |
|
Aleksei Vasiliev posted:it should just be return s.startsWith("/"); Wow, I never read about this feature before. Seems really useful. Too bad my workplace is using ancient versions of Java for no good reason. It's not like we have apps that rely on specific hacks to make them work, one of the devs just refuses to upgrade to new versions.
|
# ¿ Aug 20, 2011 18:26 |
|
I have never heard of instanceof being a bad idea. You could do something likecode:
|
# ¿ Aug 30, 2011 21:42 |
|
Write an interface Instrument that defines getSettings() and other stuff Instruments need.
|
# ¿ Aug 30, 2011 22:28 |
|
If the code is multithreaded, the condition may have changed. Also I guess it makes it a little more readable. Even if there are no external threads changing the condition, you still know when .doSomething() runs without having to scroll up to find out why myObject is or isn't null.
|
# ¿ Sep 1, 2011 23:44 |
|
Java doesn't change anything between versions, too much. All the major changes from 6 to 7 are either under the hood or advanced features you will probably never encounter.
|
# ¿ Sep 6, 2011 00:18 |
|
I use JDOM, and it's really, really easy. When you read in the file, it forms a tree of Elements, which have all the relevant things associated with them.
|
# ¿ Sep 9, 2011 20:15 |
|
I didn't know it could get even easier than JDOM.
|
# ¿ Sep 9, 2011 20:20 |
|
There isn't any way for the program to know the doubles ended unless you tell it, either by some terminator character (a null or something that fails the double parse and returns false on hasNextDouble()) or by knowing how many doubles there are and going through it a finite amount of times. Are you reading from a file or from keyboard input?
|
# ¿ Oct 5, 2011 23:53 |
|
The difference between .equals() and == is that the first compares the contents of the class, whereas the second compares their references. "a".equals("a") will return true, but "a"=="a" will return false, since those are two different String objects. Also, in Java, you need an Exception for a try-catch. You don't need to make your own Exception class, really. The word you're thinking of is "extends". code:
|
# ¿ Oct 31, 2011 01:05 |
|
Technically, int is a primitive and Integer is a wrapper class, but autoboxing allows you to treat them basically the same way (aside from calling instance methods from them).
|
# ¿ Dec 9, 2011 04:09 |
|
toString() is the standard method of getting a string representation from an object, so use that, even if they do the same thing internally.
|
# ¿ Dec 9, 2011 05:17 |
|
|
# ¿ May 20, 2024 07:29 |
|
Scanner is really friendly and easy to use, but it's really slow performance-wise and not as versatile. Use FileReader or BufferedReader.
|
# ¿ Jan 22, 2012 23:49 |