NetBeans - JComboBox warning - missing type arguments for generic class JComboBox<E> - swing

I am using NetBeans IDE 7.1.2. When I compile my application I get the following warning:
warning: [rawtypes] found raw type: JComboBox
city = new javax.swing.JComboBox(); missing type arguments for generic class JComboBox where E is a type-variable:
E extends Object declared in class JComboBox
So, I guess I have to declare the JComboBox as:
JComboBox<String> city = new JComboBox<String>();
But how do I do this in NetBeans, using the Matisse (Swing GUI Builder)? Please help.

In Netbeans 7.2 you can click on Code section for JComboBox, and then write type into "Type Parameters", in your case: <String>.

Java 7 introduced generics to the JComboBox. One solution to your problem would be to ust Java 6.
I'd bet the latest version of Netbeans (7.2) will have a solution for this (although I'm not positive).
Otherwise, if I remember right, you can view the code generated by Netbeans. If so, you may be able to add the generic arguement yourself. It's been many months since I tinkered with Netbeans though...
Also, if the Netbeans allows you to, you can add the #SupressesWarnings annotation above the JComboBox declaration (or even above the class declaration, although that changes it's scope). It would be something like this:
#SuppressWarnings("rawtypes")
JComboBox city = new JComboBox();
There are lots of options, but Netbeans may hold you back from implementing some of them.

Related

What should be done to get around or resolve the PrimeFaces exception requiring the definition of a lazy attribute or one that doesn't result in null?

I am in the progress of upgrading a legacy application from PrimeFaces 6.2 to 11.0.0 (which is the newest available with maven - https://mvnrepository.com/artifact/org.primefaces/primefaces). I have had to make a number of changes, including adding Object as the parameter for RowEditEvent and TreeNode objects (which are now generic) and changing instantiations of DefaultStreamedContent to use .builder(). Now, I am facing the following error whenever I try to run the application and navigate to certain pages:
"javax.faces.FacesException: Unable to automatically determine the lazy attribute. Either define the lazy attribute on the component or make sure the value attribute doesn't resolve to null."
It looks like an exception is being thrown rather than a warning as is noted in the conversation here: https://github.com/primefaces/primefaces/issues/8436. It also looks like it was fixed, but for version 12 (which is not on the maven central repository).
I am wondering what my options are, or what could be done about this. Should I go back to an older version?
As a workaround you could create an application factory which sets the lazy attribute to false.
See: https://primefaces.github.io/primefaces/11_0_0/#/core/globalattributes
Is it a lazy DataTable which uses LazyDataModel? If yes, just set lazy=true, otherwhise set lazy=false

What is __AS3__?

Sometimes in debug mode with Flash Builder, I see something like
__AS3__.vec.Vector.<Object> (#909e219)
but when I try to store this variable in another as3 variable, Flash duplicate this variable. Concretly, I'm trying to exclude some values on dragInitiator.selectedItems property before adding them to a List but when I use splice method on it, values aren't deleted from this vector.
So how can I acces variable with __AS3__ namespace please ?
According to a Tamarin developer:
The namespace "__AS3__.vec" is an artifact of a time when we did not have good API
versioning and could not introduce new top-level names without the risk of breaking
existing code. Today we would probably have made "Vector" public & versioned.
Source: http://hg.mozilla.org/tamarin-redux/rev/817f3e019ba2#l2.30
In other words, __AS3__ is the package where are defined Flash internal classes into Tamarin VM.
To access such variables, you don't need to specify the namespace. You only have to use the FQN declared in playerglobals.swc.

getWindowHandle function doesn't exist for driver in Selenium

I need to implement switch from one window to another in IE. However, element driver doesn't support getWindowHandle function.
I assume it might be just configuration problem or settings, though I don't know how to fix it.
Please, any suggestions.
I'm working with c# - Visual Studio
You haven't said which language bindings you're using, but based on a comment you posted, it looks like you're using C#. The method names are slightly different for each language binding. From this answer:
The object, method, and property names in the .NET language bindings
do not exactly correspond to those in the Java bindings. One of the
principles of the project is that each language binding should "feel
natural" to those comfortable coding in that language.
So you have to do a little translation if you're trying to copy-paste Java code. In this case, you want the combination of the WindowHandles property (to look for the new window handle) and the CurrentWindowHandle property of the driver. You can find full API documentation for the .NET bindings at the project's Google code site.
I am going to make wild guess:
Try to initialize your driver like this:
WebDriver driver = new FirefoxDriver(); //assume you use firefox
The interface WebDriver supports that method. Do not forget to store the handle somewhere ;)
String myWindow = driver.getWindowHandle();
BTW that method should return you actual window If you need all windows you probably should use getWindowHandles() method
If this does not work, please provide more info:
what error exactly are you getting?
How do you initialize WebDriver?
What version of selenium are you using?|
What type of driver are you using?

WINRT XAML System.Void Compile Error in

after a little code change inside a Store App I ran into a compilation error:
-> System.Void cannot be used from C# -- use typeof(void) to get the void type object.
Problem is: this comes from a generated file: XamlTypeInfo.g.cs.
case "System.Void"
userType= new ... ,typeof(global::System.Void), ...
...
Rolling back the changes did not help, as deleting bin & obj, restarting, etc.
Is the actual System.Void case entry maybe an indicator that something within a XAML file could not be recognized by the code generator? Is there an System.Void entry in a working XamlTypeInfo.g.cs?
--- ADDITION ---
I can now produce the compile error when changing specific lines. I have a custom control deriving from ItemsControl. I define a regular DP which works fine. I am also providing AttachedProperties for Template, TemplateSelector and Style. Think of a Textbox that gets an Label via an AttachedProperty and its not just a string but like HeaderedControls you can define a Template etc. for the Lable.
The Problem is related to the Get/Set Methods for the AttachedProp. When I either change the Getter return type to DataTemplate or I comment out the Setter fully then the compile error comes:
public static DataTemplate GetLabelTEmplate(UIElement element)
{
return (DataTemplate)element.GetValue(LabelTemplateProperty;
}
public static void SetLabelTemplate(UIElement element, object value)
{
element.SetValue(LabelTemplateProperty, value);
}
Any ideas would be highly appreciated.
Best regards
Gope
After filing a bug complaint with microsoft they pointed me to the problem: The setter's value cannot be of type object. This information is needed for the XamlTypeInfo generation so when I changed object to DataTemplate it compiled.
Although I haven't tried it yet, I believe object is fine for plain WPF, but for Win 8 Store apps this does result in an compilation Error. Funny stuff... :)

How do you access items in an uneditable JComboBox so a method can be run upon selection?

I know a little Python but unfortunately no Java. I'm trying to get a minimal Jython example to work, where a method is executed each time an item in my JComboBox is selected. Instinct tells me I should set an actionPerformed = object for each item, where object is the name of a method I want to run. I found an example online for JMenuItems, and I got this to work:
menubar = swing.JMenuBar()
optionMenu = swing.JMenu('Option')
optionsList = ['First', 'Second', 'Third']
for option in optionsList:
choice = swing.JMenuItem(option)
choice.actionPerformed = self.doUponSelection
optionMenu.add(choice)
menuBar.add(optionMenu)
When I tried something similar with swing.JComboBoxItem, it told me no such attribute existed. Using dir() I found javax.swing attributes of JCheckBoxMenuItem, JMenuItem, and JRadioButtonMenuItem. Does anyone know how I can access the components of a JList or JComboBox?
Note: I have access to Jython 2.5.0
Edit: I've seen the Java documentation (not that I understand the code) that describes explicitly adding an actionListener but did not think that was supposed to be done in Jython. I know Jython JButtons have an actionPerformed attribute which appears to implement an actionListener and executes actions (combining Java steps). If it is the JComboBox itself that will fire the event, I'm even more confused because I tried using myJComboBox.actionPerformed = self.doUponSelection and it gave me a TypeError saying it was a read only attribute. It works fine for me with myJButton.actionPerformed = self.doUponSelection.
You must add an ActionListener to the JComboBox itself. When a selection is made, an action event is triggered. In the listener's code, just ask the JComboBox for its selected item to know which item is the newly selected one.
Read http://download.oracle.com/javase/tutorial/uiswing/components/combobox.html#listeners