greptilian logo

IRC log for #friendlyjava, 2018-06-27

##friendlyjava on freenode

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

All times shown according to UTC.

Time S Nick Message
03:38 nanoz joined ##friendlyjava
03:38 nanozz joined ##friendlyjava
07:47 kirua joined ##friendlyjava
09:32 mr_lou joined ##friendlyjava
10:32 kirua joined ##friendlyjava
10:44 dka joined ##friendlyjava
15:14 kirua joined ##friendlyjava
19:02 * mr_lou struggles with old Java.
19:02 mr_lou Toolkit.createImage is putting up an attitude.
19:04 aditsu try some new java instead? :p
19:04 * aditsu is trying to use a quickbooks sdk
19:05 mr_lou aditsu, No I insist on getting this running in old Java.
19:06 mr_lou And it should run.
19:07 mr_lou java.awt.Image myImage = java.awt.Toolkit.getDefaultTool​kit().getImage("/myImage.jpg");
19:07 mr_lou or
19:07 mr_lou java.awt.Image myImage = java.awt.Toolkit.getDefaultToolki​t().createImage("/myImage.jpg");
19:07 mr_lou But myImage.getWidth(null) is -1. I.e. nothing is loaded. Have tried with different filetypes too. Running out of things to try.
19:08 aditsu is your image in the root directory?
19:10 mr_lou Yes
19:10 mr_lou Root of jar
19:11 aditsu I think "/" means root of file system
19:13 mr_lou Well I've tried with and without /
19:13 mr_lou (For MIDP and BD-J I need to use / to go to root of jar).
19:13 aditsu is it a separate file? or only inside the jar?
19:13 mr_lou Inside jar
19:13 mr_lou png and gif and jpg
19:13 aditsu then I don't think you can use createImage(String) at all
19:14 aditsu try the URL version
19:14 mr_lou hmkay
19:15 aditsu and you can use getResource from Class or ClassLoader
19:15 aditsu to get a URL for something in the classpath (which includes your jar)
19:16 mr_lou Tried those too. :-)
19:16 mr_lou getClass().getResourse()
19:16 mr_lou getClass().getClassLoader().getResource()
19:17 mr_lou Nothing
19:17 aditsu let me give it a try then..
19:18 mr_lou Nothing
19:18 mr_lou ups
19:19 aditsu ?
19:19 mr_lou Hit arrow up and return in here instead of in consol.
19:19 mr_lou I use this method in BD-J, and it works fine there.
19:20 mr_lou But apperently not now here in old desktop java.
19:21 mr_lou Ah...
19:21 mr_lou Got something now.
19:23 mr_lou Managed to get a simple test working.
19:24 mr_lou So the only difference at this point, is the MediaTracker I attach to it...
19:24 mr_lou Hm
19:24 aditsu yeah, I think it may not load instantly
19:27 aditsu you can also use the ImageObserver thing if you prefer an async approach
19:28 mr_lou I do prefer async, but I can't figure out this ImageObserver thingy.
19:28 mr_lou I think the javadoc I found is too simple.
19:28 mr_lou http://www.ad.ntust.edu.tw/course/ad5601701/jmdl/docs/java/api/packages.html
19:29 mr_lou But anyway.... it's still not the issue.
19:29 mr_lou It's not loading ever in my other app.
19:30 aditsu you can also check https://docs.oracle.com/javase/8/docs/api/java/awt/image/ImageObserver.html
19:30 mr_lou I use the MediaTracker to force my app to wait untill the image is loaded.
19:30 mr_lou Works for BD-J
19:31 mr_lou I can't use the ImageObserver to halt my application. I'll have to implement some manual waiting time then.
19:31 mr_lou MIDP was nicer this way. :-)
19:31 mr_lou It would halt everything while loading images.
19:32 aditsu sounds like you don't want async; just use MediaTracker then
19:33 aditsu mr_lou: I also want to ask.. can't you use ImageIO?
19:33 mr_lou No. ImageIO wasn't invented till much later - at least that's been my impression for a long time.
19:34 mr_lou hm... since 1.4 apparently.
19:34 mr_lou That's pretty old.
19:39 mr_lou while (image.getWidth(null)<=0) Thread.sleep(100);
19:39 mr_lou That works.
19:39 mr_lou Until I call image.getWidth(null) later on again. Then it's NullPointer
19:41 mr_lou Oh wait, that was my bad.
19:41 mr_lou :-)
19:43 mr_lou I'm a dumbass.
19:43 mr_lou Next time, just remind me of that.
19:43 * aditsu makes a mental note then quickly forgets it
19:45 mr_lou You're right about / though. I need to omit it here. But I need to include it for MIDP and BD-J.
20:09 aditsu sigh.. I hate bloated dependencies
20:13 aditsu this is what my classpath looks like: http://farm2.static.flickr.com/1223/1356857214_705c36eaa6.jpg
20:25 mr_lou :-)
20:28 mr_lou If I don't answer, I've fallen asleep.
20:28 aditsu good night
20:49 pdurbin don't let the bed bugs bite
21:57 mr_lou Damn mosquito woke me up
21:57 mr_lou That's why I often sleep with ear-plugs.

| Channels | #friendlyjava index | Today | | Search | Google Search | Plain-Text | plain, newest first | summary

##friendlyjava on freenode