?
Solved

Can't set label

Posted on 2005-05-11
28
Medium Priority
?
269 Views
Last Modified: 2010-03-31
When I try to edit the text of a simple JLabel I get the following error:

E:\JAVA\Project\game\src\riotcity\RiotServerGUI.java:44: package org.openide.awt does not exist
        org.openide.awt.Mnemonics.setLocalizedText(jLabel1, "Port:");

What 's wrong ? I just edited the "text" field in the property window.
0
Comment
Question by:Reggie_BE
  • 12
  • 10
  • 4
  • +1
28 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979003
You may need to add that package to your project
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13979014
>> I just edited the "text" field in the property window.
of what IDE?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979059
Whatever ide you use the principle's the same - the package needs to be resolved
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Reggie_BE
ID: 13979077
NetBeans 4.0
0
 

Author Comment

by:Reggie_BE
ID: 13979094
But it's wheird cause it's just a Swing component .. normally I don't have to add any package ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979113
>> But it's wheird cause it's just a Swing componen

No - it's not in a Swing package

>> normally I don't have to add any package ?

That's because those libraries are already imported
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979138
Proably something like:

Select the Build | Compiling Sources node , and Click the Add Library button on the right.
0
 

Author Comment

by:Reggie_BE
ID: 13979166
But in other projects when I edit a textlabel the code is: label.setText("Labelname");

When I edit the textlabel now the code is:
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, "Port:");

Did I do something wrong ? Is it normally he uses awt ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979195
>>
When I edit the textlabel now the code is:
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, "Port:");
>>

That's because a special kind of label is being used. You need that package containing it in your app's classpath
0
 

Author Comment

by:Reggie_BE
ID: 13979298
But I don't want to use a special kind of label ;)
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13979308
You seem to use NetBeans Lookup Library.
Make sure that this JAR (http://www.netbeans.org/download/dev/openide-lookup.jar) is mounted in netBeans
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979324
>> But I don't want to use a special kind of label ;)

No, and i wouldn't recommend it either ;-). You need to ensure that the standard API is being used
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13979360
And you're sure it is a JTextField and nothing else?
0
 

Author Comment

by:Reggie_BE
ID: 13979378
And how can I change back to the standard API in Netbeans ?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979402
>> And how can I change back to the standard API in Netbeans ?

Not sure. Apart from the above, what indications in the source are there that there is non-standard code present? What types are declared for the labels?
0
 

Author Comment

by:Reggie_BE
ID: 13979467
>> what indications in the source are there that there is non-standard code present ?

Nothing, everything looks good, except that line where he changes the label. He does this with every text I want to edit. Tab-text, textfield-text, ...

>> What types are declared for the labels?

private javax.swing.JLabel jLabel1;
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13979504
You could leave the text empty and do it yourself in a non-generated code part following initComponents()
0
 

Author Comment

by:Reggie_BE
ID: 13979520
Now I remember. Netbeans changed something when I tried to put an ampersant in a label.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979560
You could do a regex find and replace maybe. In the meantime, set the mnemonics in the normal way for each time that occurs
0
 

Author Comment

by:Reggie_BE
ID: 13979562
zzynx: Indeed, but that would be the emergency solution :)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979576
>> Now I remember. Netbeans changed something when I tried to put an ampersant in a label.

If you're WYSIWYG editing, try deleting the label and adding it again
0
 

Author Comment

by:Reggie_BE
ID: 13979643
>> If you're WYSIWYG editing, try deleting the label and adding it again
I tried that, but he does this also with other components.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 13979660
Define your own setLocalizedText and simply find and delete "org.openide.awt.Mnemonics."
0
 

Author Comment

by:Reggie_BE
ID: 13982137
>> Define your own setLocalizedText and simply find and delete "org.openide.awt.Mnemonics."

I can't edit the code generated by netbeans. When I edit the code with a simple texteditor, he changes the code back the way it was when I load the form.
0
 
LVL 10

Accepted Solution

by:
edwardiii earned 200 total points
ID: 13982274
Hi, Reggie_BE.

To get rid of this behavior, select your JLabel, click the "Code" tab in the Properties window, and uncheck the "Generate Mnemonics" checkbox.  See the URL below for options if you want to use the org.openide.awt.Mnemonics class:

     http://www.netbeans.org/issues/show_bug.cgi?id=41155

For informational purposes, in NetBeans 4 when you add an Ampersand in a JLabel, you get the following pop-up:

"You can define mnemonics of labels and buttons by using the '&' character inside the text property instead of setting the text and mnemonics properties separately. This allows precise mnemonics definition and easy internationalization. However, this feature requires the org.openide.awt.Mnemonics class so you should turn it on only if you develop forms to be run within NetBeans IDE."

<checkbox> "Use org.openide.awt.Mnemonics for mnemonics definition."
<checkbox> "Don't show this dialog again."

"You can later turn this option on or off.  Choose Tools|Options. Expand the Editing node, and select Form Editor Settings. Then change the Generate Mnemonics Code property."

Note that changing the property in Tools|Options won't stop compile errors after you've checked the "Use org.openide.awt..." checkbox above--you must either mount the openide.jar if you want the functionality or uncheck that component's Properties/Code/Generate Mnemonics box if you don't.
0
 

Author Comment

by:Reggie_BE
ID: 13982554
Wow, thnx !
0
 

Author Comment

by:Reggie_BE
ID: 13982650
Also thnx CEHJ for your time !
0
 
LVL 10

Expert Comment

by:edwardiii
ID: 13982668
Glad to have helped:)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month15 days, 18 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question