Win a copy of Machine Learning with R: Expert techniques for predictive modeling this week in the Artificial Intelligence and Machine Learning forum!

Robert Ingmarsson

Ranch Hand
+ Follow
since Jan 12, 2015
Robert likes ...
Java Netbeans IDE PHP
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Robert Ingmarsson

Hi, again!

Its working now I think, one should never say never though. Weird I had to use a SwingUtilities.inovkeLater method for the action to enable properly
in the calling actionPerformed method like below:

Now my setActionEnabled-method seems to work finally.

Oh, I am sorry for the code spam earlier in this post, mr Camick. I will do better in the future, but thanks for the advice and guidance.

Best regards,

6 hours ago

Stephan van Hulst wrote:Have you already debugged your application to ascertain that the action is not null after you retrieve it from your action map?

Please also show us the code where you populate the action map.

Best, Mr van Hulst!

I have tried to debug the application using Netbeans 8, but that one shows no error from my point of view that is. It's a small media manager application
that I have just started on and so far the code is very simple and embarasing small, but it's that Action error that is messing things up big. But here is the code for
the JMainFrame class that extends a JFrame class. I have populated the actionmap in the method installActions(); in the JMainFrame constructor.

Very kind regards,

1 day ago

Stephan van Hulst wrote:Why aren't you using the setEnabled method on the action?

Best, Mr van Hulst!

I have tried that also in the setActionEnabled(String name, Boolean isEnabled) - method, but it didn't worked.

Thanks for the reply! I have checked over my framework very thoroughly and I can't see why that method above shouldn't work.
I have an actionPerformed method within a JDialog in which i wan't to enable the Action when the user clicks the "insert"-button in the
dialog but the JMenu refuses to activate.

Very kind regards,

1 day ago
Hello, world!

Im so bad at posting here please forgive me! I have encountered a somewhat fantastic problem concerning Action objects in jmenus,
I can't set them to be enabled again after having disabled them. My Action objects are attched to an ActionMap in a JFrame. I have a method
in which I call them by their key name like below

This is how a populate my ActionMap with Action objects

Can anyone see why this is not working? Am I missing something here? Is there something special with Action objects in jmenus that I have missed out?
I have also tried

But that one fails as well. Hence I am stuck here. Any kind of enlightment are greatly much appreciated in advance.

Very kind regards,

1 day ago

Joe Ess wrote:Have a look at this tutorial.  You don't manage the property files themselves.  You set a Locale and let Java determine what properties are correct.

Best, Mr Ess!

Sorry for a late reply. I know how ResourceBundles work in theory but not in the "real world" so to speak. I am trying to
learn how to internationalize a program and how to "reload" ResourceBundles or Properties object. It's so difficult for me to
get a grasp on. My goal is to have an actionlistener that let the user select languages from a group of JMenuItems.

This is driving me crazy. I realize the solution must be simple, but i am blinded at the moment of confusion. I would be very
glad if anyone could help me out here. I have read the tutorial on localization but i get stuck when it comes down
to the practical part.

Very kind regards,
5 days ago
Hello, world!

I have an application that i wan't to translate into several languages, by now its only in swedish. I have never done this before.
I am using a Properties file to store my text. I wan't to select languages with a combo box but i don't know the procedure after
the selection has been made. How do you update an application after you have selected another language? Do you restart the
application and how do I accomplish that?

This is how a load my Properties file. The method load(Locale loc) resides in a class called "Localizer"

And this is how I wan't to select each language:

And also, what is the best way to load a Properties file and where? Im trying to load the Properties file at the top of my appliacaion,
but it is not working well. Is there a certain guideline for this? Sorry for all the bombardment of questions in this post, but I'm
very in to the subject at the moment.

Very kind regards,

2 weeks ago
Best, ranchers!

I need to come up with a good star rating system that uses decimal values with a range from 0-10 hence incremented with a step size of 0.1
Is this even possible? Most rating system uses a range of 1-5 stars.

What technologies out there do i need to accomplish this? I've seen that the most rating system uses JQuery, a part of javascript I don't
wan't to use in this case also many uses Ajax, which is a whole new science to me. I wonder if someone could point me in the right direction?
Maybe post some good links on tutorials or examples out there or some small code examples that can inspire me.

I am using php and mysql as main back end technologies.

Very kind regards,
  I give up. I have tried everything but like in everything else in life i fail. Im a semi rated beginner, not on javascript but on regex,
so i think im going crazy on this one. I can see the solution before me if I close my eyes so clearly. I must look in to more RegExp. I can't make any of the
provided regex on this page work.

Al Hobbs wrote:The pattern bear was referring to was the pattern attribute.  You put the regex in there.     That regex I gave you wont allow 10
You can do this: (?:10|\d (?:\.\d)?)
The extra 10 in there looks a bit hacky though

Best, Mr Hobbs!

When i look at the syntax of the regex you wrote I can see what it is doing, but how do I use it in a working example?
I have tried the following:

But nothing seems to work. I have read that every regex must start with a "/" and be terminated with "\" so i'm not sure
about parenthesis in a if statement. Could you show me what i am doing wrong?

Very kind regards,

Al Hobbs wrote:A regex for that might be \d (?:\.\d)?    

Something like that

Thank you so much for your reply. I shall test it. But the input number in the textfield should be limited to 10.
Can you accomplish this in the same regex string?

Kind regards,

Bear Bibeault wrote:Is this not something you can simply use pattern for?

At the moment im in a pre-google state when it comes to this answer. Thank you so much by the way. But how could a
pattern be used as an example in this case? I am a beginner when it comes to regular expressions, i am aware of them
and know how they works and know only some basic letter oriented syntax. Has a pattern something to do with regex?
Thank you so much for your replay to this post, Mr Bibeault.

Kind regards,
Best, ranchers!

I wonder if anyone could help me with a number formatting issue that i have dealt with for quite some time now.
I wan't to format an input value from a textfield to a decimal pattern as the user types the digits in the textfield.
Also i want to limit the input value to 10 so the range would be from 0.0, 0.1, 0,2 (and so on ... ) - having a step
size of 0.1 up to 10. The input value should be set back to 10 if the user enters a value of 11 or higher in the textfield.

I don't wan't to use the component <input type="number" /> from HTML 5 in this case.

I know a procedure like the above requires some regular expressions where hence i am a beginner. So far i have
this very, very little sample code:

Thank you so much in advance and very kind regards,

Hi, Piet!

This is my MouseListener method that i use on the JButton object in question:

The MouseListener is implemented by a class called CompanyInfoPanel. Many thanks for the reply.


4 months ago
Hi, ranch!

I just solved it!

Weird, that one must use getRootPane() on the object before calling setCursor ...

4 months ago
Best, forum!

I have encountered a huge problem. I am trying to set the cursor on a JButton object to Cursor.HAND_CURSOR from the default state when the mouse
enters the object in question but somehow it fails. The buttons enability is set to false and at first i was wondering if the cause to the problem had
something to do with that but previously in the application i have managed to set the cursor to different states but in this case it doesn't work anymore.
I am just wondering  if anyone else has encountered this very same problem and what would be the general solution for this?

The code for my JButton object looks like this:

Any hints or thoughts are greatly much appreciated!

Kind regards,

4 months ago