David Mace

Ranch Hand
+ Follow
since May 26, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by David Mace

In order to do a server push, I think that you're going to have to open a socket on the applet which will let the server initiate a conversation with the remote applet. You could register your observers by having them send an initial call to the servlet once they have been init'd to have them be registered as observers.

Now, there are some problems here: what port are you going to use for receiving communication to the applets and is the client computer behind a firewall? If you're deploying this in a coorporate environment where you have control over these things, it may not be as much of an issue, but still the idea sounds a little error-prone to me.

You can push your data in whatever format you would like, perhaps xml or as a binary serialized object and then have your applet handle this data however you would like.

That's just my thoughts 'off the cuff' which you may or may not find useful.

Thanks,
David
18 years ago
You know, I searched a few search engines for a couple hours and couldn't find an example like this. Thanks for the link!

David
18 years ago
I'm writing an applet which will perform a basic POST for me. I have all of the drag and drop functionality sorted out and everything else for the GUI, but I'm a bit stuck on the actual POST operation.

I found a good article discussing POSTing of text data on javaworld.com, but I haven't been able to track down anything discussing transmitting binary data via POST. Any help or a pointer in the right direction?

Thanks,
David
18 years ago
I am taking a screenshot and running it through a filter to dim the image. I take this image and place it in a JLabel and show over a portion of the screen. When I do this, even though I use a MediaTracker, it shows a grey background for the JFrame for about .1s before the image is shown. I've trimmed out all the unnecessary code and I'm posting a compilable version below.

If I do not run the image through a filter, it displays instantly as it should. What could be causing this delay?

Thanks,
David

18 years ago
I've researched this topic for the past week and have not come upon anything close to a solution. I'm trying to build an overlay on top of a background image.

Environment: Java 1.1

I can do this without any difficulty at all using J2 classes, but I have not found a way to achieve this in 1.1. The Color constructor taking an alpha value as it's 4th argument does not exist and there is not .setAlpha() method to the class so I'm really at a loss for the overlay.

Using transparent images does not seem to help the situation because it seems as though in 1.1, if a pixel's transparency is set <50% then it does not get painted and it if is >=50% then it gets painted at 100%. At least this is my observation.

My LAST resort is to extend Component or Container and implement a .paint() method that adds pixel values together to get the overlay effect....although I can't say that I know about adding pixel values so if I have to go that route, I'll have to research that as well.

Does anybody out there have any ideas? I'm getting a little desperate regarding this matter...but I've learned a lot about .paint() in the process....that's for sure. And probably more than I ever wanted to know.

Thanks!
David
19 years ago
While it's possible the solution requires Applets, I think it's more of an advanced question so I've posted it here instead of the Applets forum.

I have written a Java application which captures a user-definable portion of the screen. Now what I would like to do is the following: I want to be able to display this image on the web which essentially gives me a viewable workspace for my clients. The image files themselves can be stored locally and then I can take the http requests for that particular frame on my local machine thus eliminating ftp to transfer the images....which I think would give me far less frequent refreshes than I want.

Assuming adequate bandwidth (each image is approx 50k), I would like to achieve in the neighborhood of 5 fps. I also want to avoid any problems with firewalls from my clients.....meaning I would probably require serving the images over port 80 locally. Is writing a client-side applet the only way to achieve this? I mean, it doesn't seem feasible for the client's browser to refresh 5 times per second....even if the only thing being transmitted is the image, or am I wrong here? It's a little bit of a complicated problem to achieve the 5fps which is why I'm asking here....I don't want to waste the time coding ways which you all probably know won't work.

Ideas please?

Thanks,
David
19 years ago
Thanks for the reply. I'd also like to share a link with others who may read this post. I found a rather nice book (free even) on theserverside.com. If you do a search for Falkner, you'll come up with the download page, it's really nice and does a complete walk through of setting up a web app as well as explaining setting up the environment, etc etc. Very nice indeed.

David
19 years ago
JSP
Essentially jsp seems to be the common denominator for web programming so I'm gonna post here. First off, I've been programming in Java for a little more than a year. Frist off, I was developing stand alone Swing applications which interfaced with our corporate databases and that was fairly straightforward after learning the ropes of Java, JDBC, object persistence, design patterns, etc etc etc (you get the drift).

Then we all decided we wanted something a little more web-centric so off I went doing my research and thought that since our main push for going to the web was to ease the pain of deployments and updates, well it might just be more suitable to go with JWS than actually reprogramming the user views into web pages. So that's what we did and to this day, I really like JWS for deploying apps in an intranet environment.

I'm now trying to advance the scope of my knowledge and branch out into web programming and have been diligently researching this topic for the past month just trying to get a grip on the standards used, common design methodologies, best practices, outdated technology, upcoming technologies, etc etc. To be honest, the number of choices and opinion is endless when you're looking at potential paths to take down the road.

Do I learn struts? Well, not sure because I read opinions on both sides of the spectrum from some people claiming it's so bloated it's not worth using and yet others adore it because they don't have to "reinvent the wheel" everytime they want to get something done in the context of a web application. I look at the complexity of the jobs I would like to tackle and, to some extent, I believe they fit the fill of being large enough to benefit, but I still wonder if the alternatives are better than struts (i.e. tapestry, spring, etc).

What about web-services? I know little about xml, but it doesn't seem to be all that convoluted. What are the benefits to having a web-service in my application in the first place? Can't I just as simply do everything I want to from a servlet or client-side via a jsp or applet? I can see some potential in being able to stream data from a web-service via xml, but I'm not sure that I can't achieve the very same thing through other channels, a I wrong here?

SOAP - Have to admit, I'm not even sure what this is, but I've seen it referenced in the context of getting .NET and Java services to communicate. I guess it's just another technology that has to be learned and evaluated.

EJB - To the best of my knowledge, this seems to be something that would be great on a resume, but I'm not entirely sure I want to give this technology a go until EJB3.0 comes out. I'm in love with Hibernate as my persistence mechanism and I'm not super-willing to just give that away as it really speeds up my development time. What other container services are here that I can't find in open-source peojects which have more flexible implementations?

Almost forgot - Java Server Faces. That's next on my list to search out, but as of now, I haven't the foggiest what they are.

And on top of the technologies involved, what about the general design principles of a web-application? Ok, I've done a few simple JSPs to pull data from a db and display, but they were non-interactive. Managing sessions, cookies, etc seems like it can be a little rough at first sight, but not nearly as difficult as deciding the technologies to use.

At the end of the day, it's almost a full-time job to keep up with the tech.
Let me hear some of your experiences....or maybe even post a link or two that you think might be helpful to me.

Thanks,
David
[ January 26, 2005: Message edited by: David Mace ]
19 years ago
JSP
Check around IBM Websphere and J9. If you're deploying commercially, there is a runtime fee associated with each copy of the software sold...I think somewhere around $5/$6 or so.

There were some other JVMs available for Palm OS and Pocket PC, but when I was trying to dig up the info about 6 months ago, it wasn't looking so promising. It was sad for me to find out because Java seems as though would greatly benefit from more support in the mobile pda market.

HTH,
David
19 years ago
One thing you could consider doing is using the Absolute Layout Manager that ships with NetBeans. It seems to me that they didn't recommend packaging it with you apps, but I may just be imagining that. Anyways, it was originally intended to be used within the IDE itself so that you can layout the components visually without all the tricky-ness inherit in the different layout managers.

What I do a lot of the time is use this Absolute manager and then lay everything out. When I'm done, I switch the layout on the container to be Gridbag and it closely approximates what I had done with the other manager.

HTH,
David
19 years ago
In doing something like this, you're not actually "connecting" the buttons with the JTextFields. If you would post your code to see how you're pulling the test from the textfields, we'll have a look at it and can probably tell you what you're doing wrong.

But basically all you would have to actually code to do what you're describing is something similar to the following:

Assuming your username field and password fields are userField & passField, just call the .getText() methods on the JTextFields themselves in the action events assigned to the JButton.

//inside action listener
System.out.println(userField.getText());
System.out.println(passField.getText());

It is a simple reply to your question, but if you post the code, we could more specifically....and don't forget your code tags.

HTH,
David
19 years ago
Strings are read-only and immutable meaning that the value cannot be changed. When you change the value of the string as you have in the first example, you are making a new object.

Stringbuffers are faster than String objects and should be used when performing concats, etc. Traditionally a string object would be appended through something like:

String x = "xyz";
x += "abc";

Doing the same with a Stringbuffer would look something like:

String x = "xyz";
x.append("abc");

Hope that helps,
David
19 years ago
I'm not sure what you mean by the bean not only contains the data, but the way it is to be displayed, but I'll take a guess at your meaning. If you mean that, for instance, you have a boolean value and instead of a JLabel simply stating either true/false versus having a checkbox, then here's the solution.

You'll first want to implement a custom table model....start by extending AbstractTableModel. In order to set a column to display using something other than the default JLabel, you'll need to create a custom renderer for that column. I'll leave you with that info and you should be able to google the remaining piece of the puzzle for your answer. It's really simple to do.

David
19 years ago
I think the solution to this would be to subclass the JScrollPane itself and then override the painting functions to implement the new buttons you are talking about...and of course to add their functionality. I would suppose this isn't a trivial task, but it's doable nonetheless.

Examine the source for JScrollPane and you'll get a feel for what needs to be done.

David
19 years ago
I'm still plugging along with Swing. In fact, I like it. At first, I really didn't care for layout managers, etc etc, but after getting used to the design principles associated with the managers, I like it. I must admit though, sometimes I cheat and use NetBeans absolute layout manager and distribute it with my apps, but that is only in special circumstances. As far as SWT goes...I haven't tried it....yet.

I love the flexibility Swing brings to the table. The ability to subclass the components so easily and tune them to my particular needs is something that I'm not yet willing to give up. And IMO it's the single biggest reason people should be using Swing vs SWT....but YMMV.

David
19 years ago