How to enable/disable the finish button on the IDEA's wizard? - swing

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).

Related

how to add a new table row using netbeans ide

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.

How to use tabstrip in VB6?

I searched about tabs in VB6 over and over, but I couldn't find anyway. How I can replace buttons and other thing in which tab?
Private Sub TabStrip1_Click()
Here I found the answer. All objects in each tab must be in one frame and each frame must be for a special tab.
http://www.vb-helper.com/howto_use_tabstrip.html
Start a new project
Add a new form from availables templates: choose the Options window template
Now you have a form frmOptions which contains a TabStrip named tbsOptions, complete of code to manage the tabs using the Click event.

how to clear the little red flag in the corner of the kendo grid cell

I am allowing users to edit some cells of the grid. For example, when they enter a date cell, a datepicker pops out and they select a date. This action of changing the cell contents fires the grid's save event and it causes a little red flag to appear in the corner of the cell.
I've tried setting the dirty property to false:
save: function (e) {
// here, save the row to the database for "real-time" saves after every change
// no need to hit a Save button
// <snip>
e.model.dirty = false; // does not remove the red flag
}
but that does not clear the red flag. What is the proper way to clear it?
Contrary to it's name, the kendo grid's "save" event does not commit the modified data to the server. It merely means that the data entered in the UI widget has been "saved" to the bound data. It will still display the dirty flag because it is still volatile data which has not yet been committed to the server.
To actually commit the data you need to call the grid's saveChanges method. This method merely calls the grid's dataSource's sync method which you could do alternatively. Either way, once you do this and the post completes successfully, the red flags will disappear.
One last thing, if you set the grid's dataSource's autoSync property to true, the dataSource will perform a sync whenever any changes occur. That is, each grid "save" event will actually mean that the data was committed to the server.
I used this command to clear the flags.
$('#Grid').data('kendoGrid').refresh();
According to Telerik Support they recommend you do it using CSS.
.k-grid .k-dirty {
display: none;
}

Flex TextInput with default mobile skins automatically regains focus on callout close

I'm working on a simple auto complete function for my Flex mobile app. For that I've got a CalloutButton that triggers a Callout.
The Callout holds some lists from which the user can select items. On item select, the callout gets closed (calloutButton.closeDropDown()).
The very same behavior is done for a TextInput. The user inputs text, the callout opens and according to the entered text, the lists change. Works fine so far. Now, when the user selects an item from any of the lists, the callout closes. Also fine.
Now the issue, after the callout is closed, the TextInput automatically regains focus.
On a mobile device this is more than disturbing.
I narrowed this behavior down to the mobile TextInput skin (spark.skins.mobile.TextInputSkin) since a TextInput without this skin class doesn't show this behavior.
Now you might say just use the default skin instead but unfortunately I can't. The default skin has a bug with Android devices that doesn't pass though the enter event. That I could live with since I'n not necessarily dependent on the enter event, however, the spark mobile skin allows be to continue entering text in the TextInput even after the callout has been opened, which is desperately needed as the lists change according to the entered text.
I can't provide any code as the problem has been narrowed down to the skinClass, thus should not be in my own code. Believe me, I tried every nice and not so nice method to prevent the TextInput from getting focus again, but nothing worked.
So, totally stuck here!
Hopefully you guys have some ideas on how to solve this.
Edit:
Below the steps of my application's behaviour. (to be fair, the workflow inside the callout is a little more complex, I'm working with several lists and a SplitViewNavigator here (thus can't use the Flextras autocomplete), but that doesn't affect the TextInput focus issue I'm facing).
Enter text in TextInput
On key change a Callout with two Lists is opened.
The first List receives results according to the entered text from a webservice
User selects item from list
Second list receives results according to selection from first list from webservice
User selects item on second list
Callout closes
This all works fine, except that the TextInput receives focus after the Callout closes.
I really don't know what triggers this behavior.
Edit2: Code to further illustrate the issue.
Naturally, this is stripped down to the very basics, but it mirrors the behavior of the component and focus.
First the CalloutButton and TextInput that can both control the Callout:
<ui:SearchCallout id="detailSearch"/>
<s:TextInput id="searchInput" skinClass="spark.skins.mobile.TextInputSkin"
enter="historySearch(searchInput.text)"
focusOut="searchFocusOutEvent(event)"
focusIn="searchFocusInEvent(event)"/>
The TextInput's focus handlers don't do anything related to the callout, they just set current states of another component, so I'll leave them out here.
Function historySearch closes the CallOut (I forced it to close as it wouldn't close with the usual closeDropDown()), formats the search text, handles a searchHistory and eventually triggers the search function that passes the formatted search text to the selected component.
Here are the parts that matter for this case:
private function historySearch(val:String):void {
detailSearch.forceClose=true;
detailSearch.closeDropDown();
searchEvent(_searchSyms, true);
}
Note: 'val' (the TextInput's text) is trimmed and whatnot, eventually it will result in an array of strings, represented by '_searchSyms'.
Further eventListeners are as follows:
searchInput.addEventListener(KeyboardEvent.KEY_DOWN, onKeyEvent);
searchInput.addEventListener(FlexEvent.VALUE_COMMIT, onKeyEvent);
searchInput.addEventListener(TextOperationEvent.CHANGE, onTextChange);
KEY_DOWN and VALUE_COMMIT don't have anything to do with the Callout, they are used to handle stuff for the searchHistory, hence I'll leave the onKeyEvent function out here.
onTextChange triggers the string search on the server and closes the Callout in case the TextInput's text is an empty string:
private function onTextChange(event:Event):void {
if(searchInput.text=="") {
if(detailSearch.isDropDownOpen) {
(detailSearch.rightView.activeView as RightView).clearDetailList();
detailSearch.isCloseable=true;
}
}
_searchManager.getRicsByChar(searchInput.text);
}
Eventually the server will respond and passes an array of responses. The Callout gets opened and it's lists are filled with the responses.
I won't paste all the Callout content's code here as it would be way too much. Basically, the user selects an item from any of the lists, the Callout is forced to close and the search function that passes the value to the component (not yet pasted here, be patient ;), is given the item's value. That basically looks like this (never mind the FlexGlobals stuff, this gets all refactored once the focus issue has been resolved):
var search:String = String(event.currentTarget.selectedItem);
FlexGlobals.topLevelApplication.detailSearch.forceClose=true;
FlexGlobals.topLevelApplication.detailSearch.closeDropDown();
FlexGlobals.topLevelApplication.searchEvent(new Array(search), true);
Allright, now the final step of the whole functionality, the searchEvent. As already said, this function basically only passes the formatted search value to the selected component. This either happened on 'Enter' of the TextInput (as the code above shows), or on selection of an item from one of the Callout's lists.
public function searchEvent(_searchSymbols:Array, setText:Boolean):void {
if(setText) {
var _searchString:String="";
for each (var _sym:String in _searchSymbols) {
_searchString += _sym + ", ";
}
searchInput.text = _searchString.substring(0, _searchString.length-2);
}
stage.focus=null;
if(selectedWindowContainer) {
// set the array of search items to the selected component here
selectedWindowContainer.setFocus();
} else
trace("[MAIN] no component selected");
}
And that is basically it. This function is the last step of my search routine, and the selected component (that will get the search items), is getting the focus.
Yet, it automatically loses focus again and the TextInput will receive it. I have no idea where and why this happens, and I need to get rid of this behavior asap!
Wow, what a post, anyone still reading this? ;) Well, I hope so.
Well, after hours of testing several ways to prevent the TextInput from automatically gaining focus, I (kinda) solved the issue, although I think it's more a dirty hack than anything else.
Setting the TextInput's focusEnabled to false works fine, even though the focus indication (border around the TextInput) won't work with this any more (an issue I can live with for now).
Still, I'd really like to know what exactly is going on here, especially in the mobile skin class.

How to remove actionPerformed methods in NetBeans

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.