space doesn't push words in java eclipse when editing - java

I am trying to edit codes in java eclipse neon but i cant push words using the space button but instead it over rights the next letters. how do i fix this.
For instance if i want to type the word new between the word Object and rowData[][] in the code below.
Object rowData[][] = { { "Row1-Column1"...
The result will be
Object newData[][] = { { "Row1-Column1"...
It does not push the other codes forward. it just over rights the next letters instead.

Try pressing the "Insert" button on your key board, my guess is you hit it by accident, I know it happens to me all the time. If you have a mac, I believe Fn and enter (the one from the numeric pad) keys combined should give same effect as the insert key so press that to reverse it. You may need to restart eclipse after pressing it, I know I sometimes have to do that as well.

Related

Android studio text editor erases text instead of allowing normal edit

I have worked with several IDE and code editors but this android studio am using is a real mess, when I place a cursor in the code i want to edit or add code to it, instead of allowing normal edit it just deletes what ever code is there and replaces it with what I type.
For example if i the space key between the public and void it will erase the void instead of creating the space am requesting it to provide.
Maybe you have the 'ins' pressed on your keypad.
Press numlock, and then 0 to turn off the insert function. If it doesnt work, try pressing the numlock again and then press 0.
This is mostly caused by pressing Insert key in your keyboard.
To solve this just press Insert key once.
OR
make sure that NumLock is Off (light indicating num lock is off) then press 0 in numberpad.
NOTE (0 key has Insert function as secondary function - i.e NumLock key function as FN key works ===> Or less realistically as Shift key).

Can we print a word on pressing a key on android keyboard?

I have a doubt that whether we can print a word on pressing a single key on the keyboard.
For example, consider a key named as hi, upon pressing it, the word hi has to be displayed on the screen. Whether it is possible or not?
If it is possible, kindly suggest me a solution. :)

Eclipse editor code editing

First of all, I was unsure what the title of this question should be so I just gave it my best shot. I just started using Eclipse as my IDE, it's a great IDE and all but I get annoyed when I highlight a portion of code to be edited or replaced, any code after it gets deleted. So for example:
System.out.println(theScanner.nextLine());
I want to replace nextLine with nextDouble. I would highlight nextLine and type in nextDouble but then the ()()(); would be erased and I would have to type them in again. Is there a way to fix this?
Click Windows > Preferences. Type content assist in search box. Select Completion overwrites option as shown below
Keep cursor after character t then press Ctrl + Space.
Then type d then select nextDouble method press Enter

JTextArea indentation

I'm having a problem with JTextArea (not a problem though).
I want to create my own college program, one of the function is to write down and save a list of homework each day. It's text area having the main function here, which is to type everything my lecturer said. But text area will act like Windows original notepad, which is not keeping the indentation. So my questions are:
How do I have a function where I press the SHIFT+TAB key it will decrease indentation by one.
If number 1 is possible, then how do my program have behaviour when I press ENTER key, it will have a new line with previous indentation? Just like NetBeans and other IDE.
Edited: I'm a beginner in Java, in truth, I'm making this program while studying Java in my college.
How do I have a function where I press the SHIFT+TAB key it will decrease indentation by one.
You need to use key bindings to listen for the user typing Shift+Tab.
If number 1 is possible, then how do my program have behavior when I press ENTER key, it will have a new line with previous indentation? Just like NetBeans and other IDE.
Use a similar piece of logic to capture the Enter key presses. Then, check the previous line in the editor and count the number of tab characters preceding the text. Output a similar number at the start of the new line.
you could use Javascript/jquery for indenting by inserting empty space of specific line. while pressing your hot key combination call function to insert five spaces on your cursor.

Retrieving current user entered value from GWT SuggestBox

I'm new to GWT. I have a simple SuggestBox which is populated using a MultiWordSuggestOracle. Users input their data to this SuggestBox, and if they find any match with the existing Suggestions its well and good. I'm able to retrieve this value in the SelectionHandler code as below.
display.getSuggestBox().addSelectionHandler(new SelectionHandler<Suggestion>() {
public void onSelection(SelectionEvent<Suggestion> event) {
String selectedProperty = ((SuggestBox)event.getSource()).getValue();
// do something with the property value
}
});
But users are allowed to enter values which are not already in the Suggestion oracle, in which case I should read this value and do something with this,may be saving to db as a new data.(The thing which I'm looking for is something like a browsers navigation widget where we show suggestions, users can pick up any suggestion or he can type in his new entry and carry on.) What I needed is a way to retrieve this new text user has entered? Data will be read on a button click. What I tried out is this.
display.getSaveBtn().addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String selectedProperty = display.getSuggestBox().getValue();
//String selectedProperty2 = display.getSuggestBox().getText();
// Blank in both cases :(
// tried display.getSuggestBox().getTextBox().getValue(),but blank again
}
});
I tried to employ onChange() event handlers (as shown below)
display.getSuggestBox().addValueChangeHandler(new ValueChangeHandler<String>() {
public void onValueChange(ValueChangeEvent<String> event) {
String selectedProperty = ((SuggestBox)event.getSource()).getValue();
Window.alert("on change -- "+selectedProperty);
}
});
This is working fine except one scenario. Suppose there are two suggestions in the oracle,say 'createTicketWsdl' and 'createTicketTimeout'. When the user types in 'cr', he is opted with these two options, and if he selects 'createTicketWsdl' by pressing keyboard ENTER, then my alert is printing 'createTicketWsdl' which is correct. But if he selects 'createTicketWsdl' using mouse, then my alert is printing 'cr' (I tried to post the screenshot to give a better understanding, but being a new user I'm not allowed).(which I wanted to get as 'createTicketWsdl'since thats what he has selected). Soon after printing my alert, the value in the SuggestBox changes to 'createTicketWsdl'.
Is there a way to retrieve the value of the suggest box? I saw a similiar thread GWT SuggestBox + ListBox Widget, where some source code for a custom widget is available. But I didn't take the pain of trying out that, since what I want is simply get the current value from the SuggestBox and I hope there should be some easy way.
Thanks for all your help!
Your question is not very clear. You need to clarify your language a lil' bit. For example - is the following a question or an assertion? I mean, it sounds like an assertion but it has a question mark.
What I needed is a way to retrieve this new text user has entered?
Also, I do not understand what you mean by "he is opted by". Did you mean to say, "he is presented with the options ..." ?
Therefore, I am guessing your situation.
You have a listbox of existing items.
You have a textbox which allows freeform text entry
Any items whose prefix values matches the current textbox entry, the listbox items would be filtered to be limited to the matching items.
Even if the current textbox entry presents matching prefixes to filtering the listbox, the user can still perform freeform text entry. So, there are two possible cases here
4.1 the user clicks on the list box to select one of the filtered items
4.2 the user press enter key, which triggers selection of the current value of the textbox.
However, you find your widget participating in a race condition, so that when you click on the widget, the ValueChangeHandler gets triggered rather than the SelectionHandler. I do not know the structure of your widget so that is my best guess.
The problem is that you are allowing two separate modes of obtaining an outcome and you probably did not have well-defined state machine to handle choosing the appropriate mode. One mode is by the textbox and the other is by selection on the listbox - and you do not have a well-defined way of which would mode would be effective at any moment.
If my guess is accurate, this is what you need to do:
You must restrict your outcome to coming from only the textbox.
Your listbox selection must not trigger any outcome. Any change in listbox selection must propagate back to the textbox - to allow the user the chance of making further freeform entry based on that value.
only the keyboard enter on the textbox will trigger the final outcome.

Categories