Why is my keyboard messed up in Eclipse? - java

I am trying to type in a pair of angle brackets in Eclipse, like "<>". However it shows up as a single quotation and a dot, like "'.". I tried a couple of times and found out that the angle bracket is actually located at back-slash's position.
Why is this happening? How can I change it back?
Thanks in advance.
Xi

I think this has to do with an annoying feature of Windows - I've had something similar for a long time in different programs (not just Eclipse).
If you have a non-English version of Windows, you probably have different keyboard layouts installed (for example, I have a Dutch and a US English layout installed by default). The key combination Alt + Shift switches between keyboard layouts. It's very annoying and it's a really strange feature - as if the keys on someone's keyboard would suddenly change?!
You can go into Control Panel, Keyboard Settings and remove the layouts that you don't want to use. (I removed the Dutch layout so there's only US English left), so that you can't switch to the wrong layout by accident again. Or you can go to the Advanced Key Settings in Keyboard Setting and turn off the key combination.

Hit Alt + Shift. If you don't want to spend time removing keyboard layouts like Jesper suggested, just hit Alt + Shift until you get the layout you need. It usually doesn't take more than a couple times. :)

I Am Doing This Via Windows Control Panel.
First time when changing font.I am restart Eclipse.(No solution than that to save my time) and then do this.

In windows 7 the language bar uses the LEFT ALT + SHIFT key sequence to change languages, so you can quickly change the language say to Spanish when writing a mail.
This sequence conflicts with many Eclipse shortcuts that use ALT + SHIFT, like rename!
You can remove the OS's setting by control panel > keyboards and languages > change keyboards > advanced key settings.
Julio

... Maybe you have your keyboard set for a different Locale(country)?
Also, you would probably be better asking this on SuperUser

Actually i think this must be something with Java SDK, because im having the same problem with IntelliJ. For example, in
public class MainActivity extends Activity {
/**
* Called when the activity is first created.
*/
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView iv
}
}
when i try to complete this snippet, with
ImageView iv = (ImageView) findViewById(R.id.iv_imagem);
after "iv" the character set in my keyboard is screwed, and instead of a QWERTY keyboard (i have portuguese language defined, and dont have other keyboards in control pannel) i have a AZERTY
in windows, other applications are is still normal

I had the same problem. I was editing Java code in Eclipse and the keyboard layout suddenly changed. On my windows taskbar I have a keyboard icon and I used it to change the keyboard layout between United States-International and Dutch. That did not solve my problem. My problem was solved when I had restarted Eclipse.

Keyboard handling of Eclipse is not perfect indeed: it confuses ctrl-alt with "altgr"!
So for example with Hungarian keyboard layout you cannot enter character '&', as it requires pressing altgr-C - but ctrl-alt-C was set to "SVN commit" by default...
(of course no problem in un-binding that combination in Eclipe, but it was not straightforward that ctr-alt conflicts with altgr, so what to look for)

I guess this probably happens if your script in Eclipse uses Robot class or any statements that use the combination of the keys, ALT+SHIFT OR CTRL+SHIFT. These combinations mess up with the functions of other keys after your script execution is completed or if it is stopped in between.
If you want to confirm if any of these combination is really messing up with your keys, then in your testng.xml file, just mouseover on any class name and it will be highlighted and underlined automatically, even though we have not pressed ALT nor SHIFT at this moment. It means that these keys are not released yet even though your script might have released them.
If you face this problem, then the control being in Eclipse, press CTRL+SHIFT and press ALT+SHIFT, and this resolves the above problem. Now, the keys in your keyboard work as usual.

with me, the strange thing is outside of eclipse (i use the ADT package), everything is ok. And restarting workspace, fixes the problem
this happens when i type any expression that might not be valid, like when i try to write
taskNameEditText = (EditText)findVie
of course, i want to write
taskNameEditText = (EditText)findViewById(R.id.task_name);
but after the first snippet, it changes the keyboard. And the code completion stops working too. So far the only working solutions i found where: 1 - restarting eclipse, 2 - start using IntelliJ
changing the key bindings wont work, just because i already have those unset. Also, "Alt + Shift" wont work, because this is not a windows (i use 7, 64 bits) problem

Related

Eclipse - Enclose selection instead of replacing

In Eclipse, when i select part of a text and press any key, the whole selection is replaced.
I would like to know how to make it, instead of replacing the text, add the key pressed to both ends of the selection, as it happens on visual studio code.
Example:
System.out.println(HelloWorld);
Select Hello World
System.out.println(HelloWorld);
Then press the " button. The code will turn to
System.out.println(");
Can i config the IDE so it will instead change it to
System.out.println("HelloWorld");
There is a already answered question like this one, but considering that one as 7 years and a lot of version old, and also considering that the answer on that one is kind of a work around, i would like to know if there's any new plugin or configuration that make it work better
From what I gather, you are wanting to do something like this?
Go to Java > Editor > Templates and add a new template, e. g. called quote, as follows:
"${word_selection}"${cursor}
Then, in the editor, write a text you want to quote, select it, press Ctrl+Space, type quote and hit Return. The highlighted text should be quoted now.
If you don't get template proposals when pressing Ctrl+Space, make sure you have them checked in Java > Editor > Content Assist > Advanced.
Just tried it and it works for me!
You can use this method for other things, like (${word_selection})${cursor} for parenthesis or '${word_selection}'${cursor} for single quote.

Changing the priority of markers in eclipse

When I set a break point on a row which already has a marker(The value of the local variable is not used) on it, I cannot see the break point marker; because the yellow lamp marker covers the break point marker.
Is it possible to change the priority of the markers so that the break point sits on top of the lamp marker?
As long as #Mena answer is ok, as he sais...
Use at your own risk :)
This can be dangerous in a big project.
To avoid problems with hided warnings due configurations, what I usually do is:
Leave config as is, to see warnings.
Remove all really unnecessary lines causing warnings
Add an annotation to method still having warnings but needing breakpoint at same line. You can annotate class if necessary when massive warnings or breakpoints needed.
#SuppressWarning("unused")
public void yourMethod() {
}
This will allow you to handle warnings individually and see breakpoints when necessary.
I find that incredibly annoying too.
The only solution I've found is to go to the Java editor preferences, and disable the checkbox "Report problems as you type".
This will not change the priority, it will disable the hint and only show the breakpoint.
Here's a picture to illustrate:
Use at your own risk :)
Finally a TRUE relief after years of a so annoying and tiny thing:
1) go to your eclipse install path and look for all files (filename) that contain the word "warn" and are of the format .gif or .png (because they contain transparency data), here there were 5 files whose icon/image matched, most were named as: quickfix_warning_obj.gif (or.png)
2) rename all of them to *.DISABLED like "quickfix_warning_obj.gif.DISABLED", and as soon you restart eclipse, this will force it to restore the right one as soon you open an editor that uses it and has some warning on it.
3) having detected the right file, replace it with one of identical size (width and height in pixels), I would like to suggest this image I just created, so simple and not annoying at all and still is useful!
4) restart eclipse again and clap with a smiling face!
PS.: you can try to just replace this file also, that was the right one here for Eclipse Luna:
$ECLIPSE_INSTALL_PATH/configuration/org.eclipse.osgi/478/0/.cp/icons/full/obj16/quickfix_warning_obj.gif
Obs.:
Of course you can replace all of them that look the same, change other annoying icons and so on, and experiment with your own gif/png size and image, just that these steps is what worked perfectly here.
The image I supplied is almost invisible some times, but they were never really useful to me as I let the code with warning become underlined as a highlight. A better image is welcome :)
And, of course, this is a workaround, like a theme change, that does not involve any coding/recompiling of eclipse, therefore the priority is not changed at all, but the results are good enough to me at least.
EDIT: here one for the search results: searchm_obj.gif at configuration/org.eclipse.osgi/331/0/.cp/icons/full/obj16/searchm_obj.gif on Luna

how to detect if a users keyboard is in AZERTY in Java?

There is currently a bug in JavaFX (https://javafx-jira.kenai.com/browse/RT-30669, free registration required) which makes it so that if you are using an azerty keyboard layout and specify an accelerator with Z in it, on Mac it only fires when typing a W. I need to work around this bug as I need to release my product now.
So I'd like to detect Mac+Azerty and if so change the accelerator to using W. I know how to detect Mac, and I know how to detect the keyboard's locale (using InputContext#getLocale()) but how do I know if the current locale has an azerty keyboard layout? Do I have to check against a hardcoded list of known locales which use an azerty layout? If so, where would I find such a list?
Just don't "check against a hardcoded list of known locales" as many people may have a french locale with a keyboard that does not matches the locale, if they bought their computer in the US and use it in quebec with a french interface. I am personally worst, as I'm having a dvorak layout... ;-) And I just want to imagine how many variants of spanish-based layout there may be available...
My best and more portable advice would be to not try to detect something that is hardly detectable, but give some "default" keyboard mappings for (e.g.) qwerty keyboards that would work for most of your userbase, and create a configuration panel that enables your user to change the key mapping for your application by typing the new keys, if they don't like the defaults.
edit:
ah... that can be indeed a different problem... maybe you could anyway make a combobox preference for all non-us keyboard on macosx that has keys with a modifier that get changed?
To answer your question more "straightforwardly", here are a few results I found on google:
http://www.coderanch.com/t/412482/java/java/Finding-language-setting-locale-keyboard
http://www.java-gaming.org/index.php/topic,23501.
both lead towards java.awt.im.InputContext:
InputContext context = InputContext.getInstance();
System.out.println(context.getLocale().toString());
I never tried this in java, so I can't help you more than with my google-fu, but I really hope this helps :-)

text color coding in Netbeans

I have a pretty annoying issue with text highlighting on my EL statements.
I have scrolled through every field in the Options/Fonts&Colors/Syntax Control Panel three times, paying extra attention to the Expression Language options and I can not find the parameter that controls the white background of the whole ${initParam.productImagePath} expression statement.
Try looking under Fonts&Color -> Syntax. Then select the language and check all the color settings there.
UPDATE
I would add that sometimes the settings are inherited... it can be really hard to find which setting controls the color.
You can save the color settings exporting ("Export" button) then change every setting under "Expression Language" just to see if it changes.
Also, you can look through all colors in all languages and tabs until you find the color that matches the one you are seeing in the editor.
I'm guessing you may have done all this already, but I want to be sure I give the most complete answer I know of just in case.
Did you also check the entries in the Fonts&Colors Highlighting-Tab?
Your image shows that the white expression is not in the current selected line, so my guess is that you have enabled "highlight Search" (small Editor Toolbar). Another guess: if you are using the jVi Plugin, there's another highlight search parameter in jVi's settings dialog.

InputEvent modifiers key

When I try to get (isAltGraphDown) if the ALT GR key is pressed when I click a button Java returns always false also if it's pressed.
Instead with e.getModifiersExText(e.getModifiersEx()) it returns Ctrl+Alt !!!
What's the problem?
and If I wanted to know if a user pressed a right Shift key?
When I was on the jEdit mailing list I saw a lot of these types of issues, usually when using non-US keyboard layouts. Occasionally other software on the system can also cause trouble, but most often it's a JVM bug. What keyboard layout are you using?

Categories

Resources