David Garratt

Ranch Hand
+ Follow
since Aug 08, 2003
Merit badge: grant badges
For More
Peterborough, UK
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by David Garratt

I appreciate Swing applications are not as main stream as they once were - but I'm still creating them.

I have one niggle which I've had since "for ever" which maybe someone has worked around.

Lets say you have a frame which has a text input field on it with some text populated and you want to replace it with something else.

Now you can place the cursor at the end of the existing text and click backspace to remove it one character at a time,

or you can do what I prefer which is to use the mouse to highlight all of the text and then click backspace just once.

The problem is that if you use the second approach and then start typing then you end up with a single character which appears to be highlighted and gets overtyped each time you type a letter.

Kinda annoying

Is there a cunning way to prevent this behavoir - if I've removed all of the text then I should be able to just resume typing without this (I don't know what to call it) odd behavior.

I have other apps which I am not the author of which do the same - so it's not my Java code which is causing it.

Some peculiarity of Java Swing

Dave
2 months ago
I'm glad it's not just me who has been facing this problem. I write java applications which run as a service using a wrapper. They have not user interface, web component etc but do need to send emails. Recently Microsoft Hotmail/Outlook deprecated SMTP and I was looking at OAUTH2 but decided instead to send emails using my Apple account. I got the impression that apart from being inherently complicated to code, it also seems like it's not consistent, with Microsoft doing it slightly different than google and urrrggggggh - what a mess.

I was wondering if someone could write a program which could accept SMTP emails from a client but forward them on using AUTH2 authentication - like a proxy to help out legacy apps.

Dave
3 months ago
Thanks for the suggestion but I like coding myself and this screen is but the tip of an iceberg.

I just found this link and I'm wondering if I can use the even handler described in this link to generate a context sensitive popup menu.

Stack Overflow
4 months ago
So - I have this JTree which is populated with an Objects which have a number of fields which determine how they appear in the tree. For example the icon which is used and what the description / text is etc.

All is fine with that.

I also have a JPopup menu assigned to the Tree

What I would like is for the content of the Popup menu to change depending on the values of the underlying tree / row / object.

I suspect I'm going to have to assign a popup to each element in the tree rather than the tree itself - any ideas welcome.

4 months ago
Just a wild guess bit could the account which its running on need a default print queue ?
There are no shortage of google hits - and yet I still don't know if this can be done.

My java application is running as a service via a exe wrapper - courtesy for install4j - which is great.

Currently it send emails using Jakarta Email library to an internal company SMTP server which does not require authentication.

I have now been asked if I can send emails using the outlook account linked to the domain account which the service runs under. It's not using the default system account.

Now I'm really clued up on OAUTH and that world but I get the impression that it's something more in line with web applications.

I can send the emails using the exchange email account and the windows domain password - but I'd rather not have to store that password somewhere and change it idependently every time the windows password is changed.

Is this do-able and if so can you give me a clue as the enviroment I am targeting is remote and I don't have any visibility of the SMTP server or its logs.

To make life that more interesting I develop on a Mac.

Dave
6 months ago
I think I have found the problem and it was staring me in the face.

My application shutdown code was updating my user interface (AWT & Swing) and apparently thats a bad thing as the JVM could be closing those threads during shutdown.

When I select Quit from the application Tray Icon then JVM is not shutting down so that worked.
6 months ago
Thanks for your reply. That's what I suspected.

The reason I was hoping to be able to do this is not just cosmetic appearance.

This application is horribly complex with dozens of threads all communicating to a common goal.

The application shutdown process has to be careful to close the threads down in the correct sequence and only when they are idle.

If I use my "Quit" method from the "tray icon" it works perfectly.

However if I use my "Shutdown runtime" hook to capture the user selecting Quit from the Apple standard menu then I does not seem to work.. It starts the process but weird things seem to happen which I've not fathomed.

Boy - I've spend many days with breakpoints, debug code and logging trying to figure it out - without any success.

I won't post any code here as it's a monster - but I though I would explain my motivation.

Maybe there is something else going on when the JVM invokes a shutdown hook.

Thanks

Dave
6 months ago
This maybe a very OS specific question - I'm Mac user and I"m not sure of the equivalent in Windows.

So - take any regular Mac application and load it or change focus to it and the MacOs system menu bar at the top of the screen shows the application name and if you click on the Application name you get About and Quit for example.

I've written a Java swing application which has a Tray Icon - using windows terminology and works perfectly. On windows you only see thr tray icon and you interact with the application by clicking on that.

Now - the question. The same Application when run on MacOS creates the same tray icons - albeit on the top menu bar of the screen - BUT - I also get this System Menu which has the name of the application and the options above.

I would really like to suppress or hide that default application menu bar so the user interacts with the application using the tray icon (as per windows).

However - I just don't know if this is possible or how to search for it - I'm probably using the wrong search terms.

I have added a simple screen shot with 2 arrows on it - Green = Good and Red = the bit I want to hide !


6 months ago
Just wanted to acknowledge that I've seen your last post and I'm working on my project,

Many thanks for the wonderful support.

Dave
2 years ago
My current project does have a servlet, and what I'm trying to grasp is within my servlet code I have an



Within my servlet code I would display a list of database connections to the user and open the jdbc link to the selected database. The jdbc connection would be per user session and would disconnect when the session times out.





My webservice

extends jakarta.ws.rs.core.Application

whereas my current servlet  

extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet, HttpSessionListener, HttpSessionAttributeListener



This is where I'm struggling to accomplish the same with the WebService code.

Dave
2 years ago

But first, are you intending to use JPA, or do you want to execute your own queries using a JDBC connection by hand?



My current solution (desktop app and servlet) both use a mechanism not unlike hibernate but of my own design which uses sql statement from a xml document and executes those. It can handle mySQL, Oracle or SQL Server and picks the appropriate sql syntax as needed.

If I could use my existing solution I would prefer to do that - but I am rather unclear as to the lifecycle of the current code, the entry point, the sequence of calls, where the execution branches when there is an exception and so forth.

I would like to know where I would put my jdbc database "connection" and "close" code - the only place I can see at the moment is within each @POST @GET method - but that seems awfully inefficient - opening and closing all the time.

I realise all these Annotations are supposed to make life easier - when you know what and when to use them all - but I'm used to knowing what's going on behind the scenes and this "abracadabra" approach to making it work with little real java code is worrying me a bit.

Dave
2 years ago
So where is the entry point for this web service - Main method equivalent - is there something I need to override in order to add my initialisation code ?

Dave
2 years ago
Would adding EclipseLink dependency to my project and reading up on JPA be heading in the right direction ?
2 years ago
Do I assume that Spring JPA is only relevant if your target is Spring Boot and won't be of interest to me and my poor little Tomcat server ?
2 years ago