|
Aleksei Vasiliev posted:I also need the examples, which are apparently in a separate JAR. com/sun/jna/examples has empty directories in these. There are some demos under the contrib dir in the repository but I'm not sure if those were the examples that were in the distribution.
|
# ? Feb 11, 2011 05:59 |
|
|
# ? Apr 19, 2024 05:44 |
|
Found the examples in svn/tags/3.2.7/jnalib/contrib/platform/src/com/sun/jna/platform/win32 I think. That's not complicated at all. Thanks! edit: Wait, no I didn't. I found code that the examples need. Fuuuck. At least the examples are probably somewhere in this, though. editedit: wait I think these are what I needed, whatever edit3: Yaaay. Now I can load User32 and do GetWindowRect and GetClientRect so I can find a window's position and size. Malloc Voidstar fucked around with this message at 06:24 on Feb 11, 2011 |
# ? Feb 11, 2011 06:05 |
|
I'm trying to make a calculator for this assigment, and I need to have a class that sends the button's value (text) to the display field. I can't seem to figure out how to retrieve this text; I assume I need to pull it from the event.getSource(); but getText doesn't work on that.
|
# ? Feb 12, 2011 03:17 |
|
Oxyclean: Let's have a look at the Javadoc. EventObject.getSource() returns an Object. If it is a JButton, we can call getText() on it. code:
Internet Janitor fucked around with this message at 03:33 on Feb 12, 2011 |
# ? Feb 12, 2011 03:31 |
|
Oh, ok, that works, the example I saw of getSoruce didn't call the object type (it was just comparing the source to an object) I was trying to do code:
Thanks a ton.
|
# ? Feb 12, 2011 03:39 |
|
Not sure that this warrants its own thread, but I'm not sure if it's a Java problem I'm having, more than likely it's my understanding. I'm implementing (or trying to) a Gaussian filter for greyscale images in Java - I don't want to use the ConvolveOp class as it's for University work so I'll probably lose marks in that respect. The problem I'm having is that the resulting image is about half the brightness that it should be, as shown by the classic Lena: from I'm extending an ImageFilter class (which just sets some basic variables like isColour, loads the image, etc) as I'm going to be implementing a few different filters. I can't tell whether it's my implementation of the Gaussian function, though I'm not sure as that's straight from my lectures, or whether I'm using it incorrectly! Would really appreciate anyone point out where I might be going wrong My source is here - I'm using a 3x3 maskSize (just set to 3) Edit: Interestingly, If I change the 3x3 matrix to consist of just (1/9) at each location I get a similar ouput, in that it's a bit blurry (yay) but the brightness has been reduced (boo) - most odd! Edit 2: The bottom right pixel (255,255) on the original should be 106 after shifting to get the R component (R=G=B in greyscale) it says it's 173 - which is wrong! Hmmm... \/ Woahhh, I wonder what I broke! Guess I'll have to look at the rest of the program then, thanks! amr fucked around with this message at 15:40 on Feb 13, 2011 |
# ? Feb 13, 2011 14:59 |
|
closed: WORKSFORME (seriously, I just got your code runnable, gave it lena, and it blurred it) edit: fixed paste link to not point to code that causes a nullpointerexception Malloc Voidstar fucked around with this message at 15:39 on Feb 13, 2011 |
# ? Feb 13, 2011 15:35 |
|
What is the deal with preCalc in getGreyGaussianPixel()? If you're just going to sum the list in the end and never access any elements of the list, why aren't you simply accumulating in a double as you go?
|
# ? Feb 13, 2011 15:49 |
|
Internet Janitor posted:What is the deal with preCalc in getGreyGaussianPixel()? If you're just going to sum the list in the end and never access any elements of the list, why aren't you simply accumulating in a double as you go? Oh that was just left over from when I was doing something differently, I'll change that eventually - well spotted though thanks, added to my list of things to fix.
|
# ? Feb 13, 2011 15:54 |
|
Just tried using a JPG image instead, and it worked! I was originally trying with a BMP image, which I think was natively B/W and the way I was accessing it wasn't working - relief to know it works alright! Thanks
|
# ? Feb 13, 2011 16:45 |
|
I've decided to try to make a small home budget program in java to teach myself some new stuff. But I'm kind of stuck because I have no idea what would be the best/easiest/smartest way to store the data that gets put into the program. (user would enter data into table and then just click a "Save" button) Would storing the data in an xml file be the right way to go ? That's the only idea I have and my google-fu keeps failing me.
|
# ? Feb 15, 2011 17:40 |
|
Howmuch posted:I've decided to try to make a small home budget program in java to teach myself some new stuff. The simplest approach would probably be a comma delimited file like: code:
CSV files are pretty basic, and will really start to buckle when you're dealing with a lot of data. Anything but the most basic applications will probably need to store data in a relational database. Relational DBs let you quickly retrieve individual records or groups of records, and they do a lot of the heavy lifting of indexing, sorting, etc. I recommend something lightweight like JavaDB. "Lightweight" means you can embed the database directly in your application; no need to startup a separate process like MySQL.
|
# ? Feb 15, 2011 18:48 |
|
You could also play around with automatic serialization to file with ObjectOutputStream/ObjectInputStream, and from there experiment with manually serializing/deserializing your objects in a custom format with DataOutputStream/DataInputStream, and then for a more advanced exercise, go back to using Object*Stream and implement custom serialization through implementing the Externalizable interface.
|
# ? Feb 15, 2011 20:32 |
|
Awesome, I'm definitely going to check out JavaDB and then later on dive into what Paolomania posted. Thanks for the tips.
|
# ? Feb 15, 2011 21:57 |
|
Help me guys. I have a tool used by a few people where I work. Someone's asked me if it can read the SIM number from a USB GSM/3G modem attached to the PC running the tool. There's an AT command for this so I thought it would be quite straightforward, but I'm running into some issues. I've found javax.comm and thought I could use it to send the AT commands, but I'm not sure if it will work for a USB COM port and also, because it's a USB COM port, it's not going to have the same number (e.g. COM1, COM2 etc.) every time. I've found javax.usb but I'm not entirely clear if I could use that either. It's looking at the moment like I could maybe use javax.usb to locate the USB modem by device name and then work work out what COM port it's on, then hand off to javax.comm to do the AT Command work. Does this sound feasible? Is there an easier approach I'm not seeing? I'm getting a bit lost in API documents at the moment. edit: Hmmm, ok maybe I could just send "AT" on every COM port until I get an "OK" response. That would work round the problem of having to forceClaim the the interface from Windows, since Windows is going to need to use the device after the tool is done with it. That might work except there is also an old school analog modem on one of the serial ports. chippy fucked around with this message at 14:17 on Feb 18, 2011 |
# ? Feb 18, 2011 14:14 |
|
chippy posted:edit: Hmmm, ok maybe I could just send "AT" on every COM port until I get an "OK" response. That would work round the problem of having to forceClaim the the interface from Windows, since Windows is going to need to use the device after the tool is done with it. That might work except there is also an old school analog modem on one of the serial ports. Though when I was doing something similar with GSM modems with Java we found out hard way that Java serial port support at least on Windows was somewhat unreliable and we had to rewrite serial comms componets with C#.
|
# ? Feb 18, 2011 19:42 |
|
Yeah, that would be the best idea I think, there's going to be max 2 modems present and it should be easy enough to tell them apart with a couple of choice AT commands. You're right though, javax.comm apperas to have been officially discontinued for Windows.
|
# ? Feb 19, 2011 12:09 |
|
I'm trying to write an application that uses TCAP network transport. The problem is that TCAP seems to be inextricably linked to SS7, whereas we're supposed to be using IP. Are there any libraries that allow me to use TCAP over IP?
|
# ? Feb 22, 2011 22:02 |
|
I want to use a ThreadPoolExecutor to maintain processes sent to the server. However, I would like the logging output to show which thread in the pool performed which actions. 1. Is there a way to synchronize the running of the thread run() with the runnable object's run()? That is if I had the thread print it's ID to the log could I guarantee it to be immediately followed by its runnable process? 2. Is there a way to pass the threadID to the runnable object? 3. Is there some way to do this that I haven't thought of?
|
# ? Feb 23, 2011 21:45 |
FamDav posted:3. Is there some way to do this that I haven't thought of? Is Thread.currentThread().getId() what you are looking for?
|
|
# ? Feb 23, 2011 21:50 |
|
FamDav posted:I want to use a ThreadPoolExecutor to maintain processes sent to the server. However, I would like the logging output to show which thread in the pool performed which actions. Log4j (and I assume other logging frameworks?) can tell you which thread in a pool is logging which output. If you have a pool named 'foo', the output could look something like this: code:
|
# ? Feb 23, 2011 23:04 |
|
I just want to express how much I hate apache source code. Seriously its like Dark City in there - everything keeps looping back in on itself.
|
# ? Feb 24, 2011 07:19 |
|
Example?
|
# ? Feb 24, 2011 07:32 |
|
"We're an Apache project, therefore we must use Apache Commons Logging!" would be an excellent example of that. Just no.
|
# ? Feb 24, 2011 17:36 |
|
Parantumaton posted:"We're an Apache project, therefore we must use Apache Commons Logging!" would be an excellent example of that. slf4j or
|
# ? Feb 24, 2011 17:39 |
|
epswing posted:Example? Currently I'm trying to trace the flow of data from a HTTP request in Tomcat 6 all the way from the socket to the point of dispatch to a servlet's doGet method. It is an obfuscated mess of abstractions including a dizzying array of wrappers, pipelines, filters, and custom NIO-like classes. There are probably good reasons for their intensive use of abstraction, but it sure as hell makes it a pain in the rear end to read the code.
|
# ? Feb 24, 2011 21:10 |
|
MEAT TREAT posted:slf4j or We've got adapters for log4j, slf4j, and commons in our code base. Maybe more. It all gets converted to our own logger that predates them all, but our logger is kind of nice since it will output to multiple places, such as our logging database, and writing converters is easier than spitting. So in the end who cares?
|
# ? Feb 24, 2011 21:11 |
|
Right but you're not an Apache Project. That's who my comment was directed at.
|
# ? Feb 24, 2011 21:27 |
|
MEAT TREAT posted:Right but you're not an Apache Project. That's who my comment was directed at.
|
# ? Feb 24, 2011 21:35 |
|
Because a lot of Apache projects already switched.quote:Apache Archiva
|
# ? Feb 24, 2011 22:16 |
|
gastownlabs posted:How can I get java.awt.Robot createScreenCapture to give me the correct colors? Is it applying the color profile on my Mac before taking the screenshot? Something like that. quote:It was saved as a PNG and this PNG matches up with any getRGBs I perform on the BufferedImage. However, the colors don't correspond to the hex codes next to them. If I take a normal OS X screenshot, they match perfectly. Ask on java-dev and include what you're actually trying to do.
|
# ? Feb 25, 2011 15:10 |
|
MEAT TREAT posted:Because a lot of Apache projects already switched. Seems fallacious, different people on different projects use different logging. Who could possibly give a gently caress?
|
# ? Feb 25, 2011 16:55 |
|
covener posted:Seems fallacious, different people on different projects use different logging. Who could possibly give a gently caress? I gave a gently caress when I had to include 5 projects and each one used a different logging API. Thankfully now I've consolidated all of that poo poo using slf4j adapters and redirect it to whatever my container uses. My point was that now that slf4j exists there isn't any reason to use the commons logging API in new projects. Parametrized logging is loving awesome and you don't have to deal with the classpath issues of the JCL.
|
# ? Feb 25, 2011 17:12 |
|
Those drop-in slf4j bridging jars look pretty cool.
|
# ? Feb 25, 2011 19:28 |
|
They're a God-send when you're using multiple third-party libraries - without them, a deployer would have to configure JDK logging, Log4j logging, and Commons Logging for a single application.
|
# ? Feb 25, 2011 19:54 |
|
Paolomania posted:Those drop-in slf4j bridging jars look pretty cool. Implementing your own (for whatever purpose) is also laughably easy.
|
# ? Feb 25, 2011 20:36 |
|
A lot of posts about logging when pros just use System.out
|
# ? Feb 25, 2011 20:53 |
|
|
# ? Feb 25, 2011 20:54 |
|
Paolomania posted:Finnish logging supremacy.
|
# ? Feb 25, 2011 23:04 |
|
|
# ? Apr 19, 2024 05:44 |
|
After a few years of doing nothing, I've decided to get back into Java. I want to redo some dungeon crawler game I made for a final project in high school. I'm off to a somewhat decent start as NetBeans easily created a nice GUI for me (the one I made in high school was some sort of Frankenstein's monster I created out of frantic googlings of Swing and AWT). But I've fallen into an old habit where I want to try something that I probably will never use but I can't move forward until I've made it work. Basically I want to type something in to a JTextField, press enter, then it appends the text to a JTextArea, then it sets the text field to uneditable, sets the textfield to say "wait" and then three seconds later clears that field and sets it back to editable. I've successfully been able to do everything except the wait three seconds part. I've tried using Thread.sleep(), but no matter where I put it, it seems to do the sleep before all the other parts. I tried to use the Timer class but NetBeans says there aren't any constructors for it. I've tried moving all the different parts into their own methods. It seems that if I call my waiting method, it will always do it before any method before it or something. Just another case out of many where my brain doesn't work the same as whoever designed whatever language I'm using.
|
# ? Feb 27, 2011 19:58 |