Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Programmers Guide to Apache Thrift this week in the Open Source forum!

Sam Ritter

Ranch Hand
+ Follow
since Jan 23, 2018
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 Sam Ritter

Yes, I guess I will have to develop one. There are only 2 windows open. The main JFrame and this JDialog.
1 week ago
Quick question. Does it matter where in the code the getInputMap is placed? That is before/after setVisible?
1 week ago
Thanks. That got me over the syntax issue but it does not always detect the space bar. I need to play with that a bit to see what is wrong.
1 week ago
I want to take some action on my JDialog when the space bar is pressed. After reading the documentation it seems like I there should be methods named "getInputMap" and "getActionMap" to do the binding. However, they do not seem to exist for a JDialog object. How to I accomplish this using JDialog. TIA.

1 week ago
Sorry about the confusion. It started as what I thought was a simple issue of static methods. It evolved into more details about what I was doing. Responses made it clear my entire approach was wrong (i.e. poor programming practices). I'm working on rewriting the code following the suggestions here, so as far as I'm concerned this question has been answered. Thanks to all.
2 months ago
Yes, I need to rewrite the code.
2 months ago
I have multiple buttons that need to use a different instance of the dialog. I used the suggested JFrame but I guess I need to rewrite it to use a different JDialog for each button so it is not static. When I choose a color, it changes all the buttons not just the one being used. Back to the drawing board.
2 months ago
Nope, that didn't really fix it either. Still working on it.
2 months ago
I figured it out but I don't understand it. The problem was that color was declared locally. I added the color declaration in the class itself rather than in the action listenter and that solved the problem.
2 months ago
I've already looked at that and that is what got me where I am.
2 months ago
Yes but I think we are talking abut 2 different things at this point. I get the static part but I don't get how to set the parameters if I don't get the instance (chooser=new).
2 months ago
Thanks but that does not address the core question. If I use it that way, how do I customize the JColorChooser display? I still somehow need the instance to set parameters.
2 months ago
Could I declare chooser as static? Is it static to this particular instance of the JFrame? Since there would be only 1 chooser per ColorChooser instance I guess that would be OK.
2 months ago
Thanks. In this case if I use JColorChooser.showDialog, how would I set the location? Eventually I will need to set other customizations before displaying the dialog. I need the instance of JColorChooser to do that, right? Obviously I am still missing something.
2 months ago
For some reason I cannot seem to get my head wrapped around "static" references. I have a class that I created and my IDE complains about static references. I don't understand how to make the class non-static since I expect to have multiple instances. Here is the class:

My IDE wants to declare a static version. I don't see this on other classes that I've created so why this one? It also wants the reference to chooser.ShowDialog to be "accessed in a static way." I'm guessing that warning is because it thinks the class itself should be static. Can someone explain why this class cannot be "non-static?" TIA.
2 months ago