Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 31087 - Newly created file does not have focus / cursor
Newly created file does not have focus / cursor
Product: editor
Classification: Unclassified
Component: -- Other --
PC Linux
: P4 (vote)
: 6.x
Assigned To: issues@editor
Depends on:
  Show dependency treegraph
Reported: 2003-02-14 21:06 UTC by Jesse Glick
Modified: 2007-11-05 13:44 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT

One log (redundant lines counted: "... | uniq -c"). Had a bunch of files open, restarted w/ flag. Caret blinking in some ed window. Pressed Alt-Left. Tab switched correctly, but no caret (until I switch focus elsewhere & back). (1.50 KB, text/plain)
2003-04-14 20:42 UTC, Jesse Glick
Different scenario. already open in editor. In Explorer, click (a tiny file). [log begins] Press Enter. IDEListener tab opens, but no caret. [log ends] (617 bytes, text/plain)
2003-04-14 20:45 UTC, Jesse Glick

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2003-02-14 21:06:04 UTC
[dev feb 13, but broken for a long time; MDI,
Linux, Gnome + Sawfish, JDK 1.4.1] Create a new
file, e.g.: Ctrl-N, select Java Main Class with
arrow keys, Enter, Alt-N, "Test", Alt-F. New
source file appears in the editor.

The editor window is now selected, yet KB focus is
not in the editor pane. It is somewhere else, I
think. There is no visible cursor. If you type a
character, it appears in the pane, and then the
cursor appears. Arrow keys do not seem to do
anything, yet if you e.g. press Page Down once or
twice, then type a letter, the new letter will be
at the bottom - so presumably some hidden caret
was moving!

Ctrl-3 does not fix it, but Ctrl-2 Ctrl-3 does.
Clicking with the mouse in the middle of the
editor pane does not give you a visible cursor,
but double-clicking does (after selecting a word
or whatever it would normally do).

Only a minor annoyance if you are expecting it and
know what to do, but potentially very confusing if
you were expecting after creating and opening a
file to have a cursor.

Same thing seems to happen after opening a file
from the Explorer by selecting it and pressing
Enter. If it is already open in a hidden tab, that
tab is fronted and the cursor appears just fine;
only when newly opening the pane does the problem
occur. Opening as a result of using a hyperlink in
the Output Window does seem to work OK, too, as
does opening using Alt-Shift-O (Fast Open).
Comment 1 Marian Mirilovic 2003-02-17 08:40:05 UTC
I cannot reproduce it on [nb_dev](20030217), [jdk1.4.2](b16)
Comment 2 Marian Mirilovic 2003-02-17 08:42:54 UTC
I am sorry, I have Solaris , CDE
Comment 3 ehucka 2003-02-17 08:55:30 UTC
I cannot reproduce it on [nb_dev] 200302170100, Linux RH 7.2, GNome
JDK 1.4.1.
Comment 4 David Konecny 2003-02-17 11:06:41 UTC
On Win2000 in today's dev build this seems to be OK for me.

What does not work for me is creating of file by keyboard: CTRL+N
shows the New Wizard, arrows choose template, but there is no way to
press Next button - Enter does not work and Tab completely lost focus.
Comment 5 Jesse Glick 2003-02-17 23:30:24 UTC
I cannot reproduce in *consistently* in today's build. But it happens
*sometimes* if you create enough files. I am pretty sure there is a
race condition because it seems to happen most reliably for files
which are small (quick to load?) when opened, e.g. new empty text
files often do it, whereas bigger Java sources don't always. Large
existing sources never do it. XML files never do it (my guess: trying
to load grammar, takes a slight bit longer). You have to turn off both
the editor toolbar and the status bar to get it to happen - these
apparently make the editor take a bit longer to come up, and will
spoil the effect.

"CTRL+N shows the New Wizard, arrows choose template, but there is no
way to press Next button - Enter does not work and Tab completely lost
focus" - that definitely does not happen to me; Enter advanced to the
target chooser panel.
Comment 6 David Konecny 2003-02-18 11:20:46 UTC
The problem I mentioned is reproducible only on JDK 1.3 (in my case
1.3.1_06). On JDK 1.4 it works fine. I filed it as separate issue 31165.
Comment 7 Peter Zavadsky 2003-02-19 12:06:48 UTC
David, is there anything else beside the newly created issue? If not,
please close this issue.
Comment 8 David Konecny 2003-02-19 12:29:28 UTC
Jesse's problem is stil valid. My one was filed as separate issue.
Comment 9 mslama 2003-02-21 15:22:24 UTC
I tried to reproduce as Jesse suggested with today dev build
200302210100, JDK 1.4.1_01, Linux, KDE 2.1.1 but no success. I
disabled editor toolbar and created 10 java main classes using
keyboard. Cursor is always at top left of newly pane and is visible.
If you can still reproduce it I can prepare patch with logging where
focus is going in your case. Is anyone else able to reproduce it?
(Even on Win or Solaris?)
Comment 10 Jesse Glick 2003-02-21 15:40:08 UTC
You turned off the status bar too? It may be that it is only
reproducible on certain CPU configurations, etc., according to speed
and so on.

I will try to run with a logging patch if you can make one. Easiest is
to just commit to trunk but only enable conditionally using some
ErrorManager prefix (use isLoggable).
Comment 11 mslama 2003-02-21 15:46:48 UTC
No. What status bar do you mean? IDE or just in editor? How to switch
it off? I will try it again without status bar.
Comment 12 Jesse Glick 2003-02-21 16:25:00 UTC
Editor status bar. It can be turned off somewhere deep in the Expert
tab of editor settings, I think. I guess the overhead in displaying
line number, etc. is enough to make the bug unreproducible on my
machine. But I always run with this bar disabled.

Lowering priority since the bug seems to be rare except for people
like me with small displays who disable various unnecessary GUI stuff.
Comment 13 mslama 2003-02-21 16:39:48 UTC
Yes now when I switched off status line it happens to me too. But
focus seems to be at editor pane when I start to write cursor appears
and I can write to editor. It just seems cursor is not visible from
some reason. I reassign to editor to have a look.
Comment 14 Jesse Glick 2003-02-21 16:49:36 UTC
Agreed - what I observed of key typed events etc. are consistent with
a hypothesis that the focus is technically in the editor pane where it
should be but the editor is failing to display a cursor.
Comment 15 Martin Roskanin 2003-03-04 13:33:59 UTC
*** Issue 31644 has been marked as a duplicate of this issue. ***
Comment 16 bht 2003-03-04 23:40:58 UTC
If issue 31644 is in fact a duplicate of this then the description
might need a change.

What I have been seeing for months with all q-builds on different
computers with speeds varying from 200MHz to 2GHz is very broad and
not limited to new files or having the toolbar or status bar switched off.
The only thing that makes it less likely to happen is when the target
file is already open in another editor tab.

This focus issue in SDI mode under JDK1.4 is so wide-spread across the
system - it is not funny.

I get it everywhere and it always reproduces:
1) when using Alt+G on a member e.g.
method call that links to a different source file
that is not already open in the editor
2) when clicking on links in the compiler output window
3) when clicking on links in the system output window
4) when clicking on a link in the debugger
5) when clicking on links in the search results

What helps with case 1) sometimes is pressing Ctrl+3.
It does not help a lot to turn the editor toolbar off.

However when I turn the toolbar on, then focus is completely broken:
Does not even work on Ctrl+K (return to the previous position)

IMHO under JDK 1.4, the focus system is completely broken and it
appears that fixes need to be applied to every singular little case.
Otherwise I cannot explain that so many focus issues have been closed
as fixed and I still cannot see a mayor improvement.

One of those closed cases is issue 28416 which I can confirm that it
works now, but it has only fixed the special case where open source
files are swiched via clicking on the tabs in the editor window.
No other focus improvement resulted from this fix.

This is fundamental and I can't understand that it is given priority 4.
Comment 17 Martin Roskanin 2003-03-05 13:34:51 UTC
Unfortunatelly, I cannot reproduce this problem. I commited additional
debug messages to the trunk. They can be enabled via setting
"netbeans.debug.editor.caret.focus.extra" property to true since
tomorrow's build. For now there is "netbeans.debug.editor.caret.focus"
property for simple detecting of gaining and losting the focus. If you
can reproduce the problem, please attach a debug output.

Bernard, if you think the issue #31644 is not duplicate, please reopen
it. Also try to run ALT+G action with debug messages (with
"...focus.extra"). It is very important to find out if the editor's
BaseCaret really gains the focus.
Also, please try to run additional focus lost cases you have
reproduced and compare the debug message info for them.

As for the priority, it is up to you:
In accordance with
it should be P3 IMHO. 

Comment 18 bht 2003-03-05 21:59:19 UTC
Thanks Martin for the explanation. I will help pinning this down. It
could be a rewarding exercise because I can reproduce this always.

Where do I set the property netbeans.debug.editor.caret.focus.extra"?
I haven't done anything like this before. Many thanks.
Comment 19 Martin Roskanin 2003-03-06 08:56:47 UTC
You can set this property via command line parameter during starting IDE:
runide -J-Dnetbeans.debug.editor.caret.focus.extra=true
You should see the debug messages on the console and they should be
written in your ide.log file also.

Comment 20 Jesse Glick 2003-03-06 13:03:35 UTC
I believe that whatever Bernard is reporting is probably a separate
bug. (1) My bug occurs only haphazardly under certain conditions that
appear to relate to the time required to open a file. (2) I use MDI
only, he uses SDI. My bug is P4, not P3. Perhaps these should be filed
separately, though the same debugging system property might be useful
for diagnosing both.
Comment 21 Martin Roskanin 2003-03-06 13:18:17 UTC
OK, I have reopened the issue #31644
Comment 22 Jesse Glick 2003-04-14 20:42:00 UTC
Created attachment 9937 [details]
One log (redundant lines counted: "... | uniq -c"). Had a bunch of files open, restarted w/ flag. Caret blinking in some ed window. Pressed Alt-Left. Tab switched correctly, but no caret (until I switch focus elsewhere & back).
Comment 23 Jesse Glick 2003-04-14 20:45:45 UTC
Created attachment 9938 [details]
Different scenario. already open in editor. In Explorer, click (a tiny file). [log begins] Press Enter. IDEListener tab opens, but no caret. [log ends]
Comment 24 pfelenda 2004-03-16 22:06:29 UTC
I can't reprocude it on latest build NetBeans 3.6 RC1, jdk1.4.2_03 on
Linux RH9 KDE.
Is anyone able to reproduce it ?
Comment 25 Jesse Glick 2004-03-24 12:24:06 UTC
Haven't seen it recently, I think.
Comment 26 Jesse Glick 2004-03-24 17:48:50 UTC
Sorry, I take that back - it just happened to me in a trunk build. Of
course it is not reproducible.
Comment 27 Jesse Glick 2004-04-01 15:44:26 UTC
This continues to happen to me intermittently in trunk builds. Not
reproducibly, and not very commonly, but sometimes.
Comment 28 Vitezslav Stejskal 2006-12-22 03:23:30 UTC
Has anybody experienced this problem in recent builds?
Comment 29 Jesse Glick 2007-01-05 21:11:03 UTC
I do not remember seeing this any time recently. I think it can be closed.
Comment 30 Vitezslav Stejskal 2007-01-07 20:34:54 UTC
Ok, anybody please reopen this if you spot it in dev build. Thanks.

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo