I have created a JTable in NetBeans IDE. I want to add a new row to the table when the user gets to the lower right-hand corner of the table and presses the TAB key. I have tried NetBeans IDE options of changing the property for keyPressed, keyReleased and keyTyped, but nothing happens. Here is what I tried.
private void tblInterestIncomeKeyPressed(java.awt.event.KeyEvent evt)
{
if (evt.getKeyCode() == KeyEvent.VK_TAB)
{
System.out.println("Released tab key");
model.addRow(new Object[]
{
""
});
System.out.println("Got to this point");
}
}
I am trying to teach myself. I have seen other suggestions on this website, but they don't pertain to NetBeans IDE GUI creation. Thanks for any help.
Swing components use Key Bindings to bind a KeyStroke to an Action. The default Action for the Tab key is to move to the next cell. So you will need to create a custom Action.
You can create the custom Action by extending AbstractAction and adding your logic to the actionPerformed() method. You would then need to replace the current key binding to map to your own Action. Check out Key Bindings for example code on how to replace the bindings.
Or you can check out Table Tabbing. This uses a wrapper class to help make the key bindings process easier so all you need to implement is the logic in the actionPerformed() method.
This example shows how to replace the default Tab Action with a custom Action that will only tab to cells that are editable. You would need to customize this Action to add a new row to the TableModel.
Related
I currently have a custom portal with a custom version of the form widget that doesn't have any UI Actions (OOTB inclusive).
We also have a custom widget (let's call it "actions widget") where we control all the actions we need to take in the record.
Currently I need to create a "Save" button inside the actions widget where the user, after filling the form, can click on the save button to update the record.
I am unable to find any way to make this button work. The keyboard shortcut "CTRL + S" works perfectly but I have no idea what type of functions and/or methods this shortcut calls.
If this is too complicated or not possible I can also fetch the fields one by one (there is not a lot of them) and update the record with that information.
Can you guys assist me with this?
Thank you in advance.
I have set the tabindex of TexInput controls in my Adobe Air works fine with tab key. Now I want to do the same with the enter key. I mean when I press enter key in the TextInput, next control should be selected.
In C# we can do the same with SendKeys and as per my knowledge there is not such way in Adobe Air.
Here is my added event
// get key presses only when the textfield is being edited
inputText.addEventListener(KeyboardEvent.KEY_DOWN,handler);
function handler(event:KeyboardEvent){
// if the key is ENTER
if(event.charCode == 13){
// WHAT ???
}
}
Find the instance with next/previous tabIndex
Depending on what control you are using, either call setFocus() method on this control (if it has one), or set the focus property of the stage to this instance. Set it to null if you want to remove focus at all.
I noticed that the method getFinishButton() in the class com.intellij.ide.wizard.AbstractWizard, from the Intellij IDEA Open API, is deprecated. But there is no comment on the method and I couldn't find any documentation. What I need to do is just enable/disable the button. So, any method for doing this (even of not accessing the object directly) is fine. How can I do this?
Finish button is available only on the last step of the wizard, so you should use getNextButton() on the final step to get this button.
There was a refactoring to remove the separate Finish button and now Next button becomes Finish button on the last step.
getFinishButton() must not be used as it's just a stub:
protected JButton getFinishButton() {
return new JButton();
}
To disable the Finish button override the canGoNext() method and return false when needed (or override canFinish() instead).
i have a data grid which is having two renderers. one is text box and other is dropdwon. both are mxml rendered.
My requiremnet is when user edit the textbox value in a particular row i should make the dropdown value also changed of that particular row.
Could someone help me on this.
thanks
If this is spark:
The ItemRenderer has a property owner which is the dataGrid - you'll want to add an eventlistener on this (from the combobox one) - presumably coming from the other renderer which you dispatch from the owner point of view (eg: in textboxitemeditor: owner.dispatchEvent(RendererEvent.CHANGE, value))
In this listener - when the appropriate data was edited, you can update your combo box appropriately.
The key when doing something like this, is to remember to remove the listener and any other references you create in the dispose() method.
If this is halo:
It's essentially almost the same as above, the difference is there is a baseListData object which has the owner reference from the renderer.
When a JButton is added to a content pane, we can set an action by double clicking the button or Right click->Event->Action->actionPerformed.Let say, we set somthing to happen. Then we need to remove that function.It can be done easily by deleting the code we wrote in that buttton's actionPerformed. But the problem is, that button's actionPerformed method is still there even though it is not used any more and not needed.
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
//no function here.. but this code is still remaining. need to remove this code part as well
}
How can it be removed? I got the JButton for an example. Other components'action methods are like this.
Go to your JButton properties, Choose "Events", actionPerformed and choose "none" from the adjacent combobox. Your source code is cleaned!
Recent versions of Netbeans like 7.3, do not offer "none" as an option, but allow you to delete the actionPerformed method by deleting the name of the method or by pressing 1, 2 and 3 buttons:
If the button that the action was registered to is no longer in the form (this happened to me after I manually replaced the .form file with a previous backup) then you wont be able to do Costis Aivalis's solution. In this case you can open the .java file with another text editor and delete the event handler there.
In the latest version of netbeans click the button with the 3 periods [...] just to the right ov the combo box and a new control listing the handlers is displayed. Select the one to remove and press the [Remove] button.
Identify your .java file, then close Netbeans and edit your file directly from a text editor.