wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes FocusListener problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "FocusListener problem" Watch "FocusListener problem" New topic
Author

FocusListener problem

Mario A. Villamizar
Ranch Hand

Joined: Mar 14, 2002
Posts: 35
Hi,
I'm developing a text editor and when it starts,it displays the main window, toolbar and menubar and this is it.
When the user create a new file, it creates dynamically a JTextPane on a JScrollPane on a JTabbedPane, it is possible to create as many file as you want and close as well one by one and all of them.
I would like when the user creates a new file, it will create a new tab with the scrollable textpane and it will get the focus on the textpane, when it creates another one; the same, the focus will be on the new textpane, when the user clicks on one of the tabs the textpane will get the focus and when the user closes one of the tabs, one of the tabs next to it will comes up and the textpane will get the focus. At the moment I've been trying to do this using a changeListener and adding it to the tabbedpane, but it doesn't work well. whe you create the first tab, the textpane get the focus but the caret doesn't blinck and whe you whan to close the right most tab, the next tab that get selected, its text pane doesn't get the focus.
it is better to do the same using a focus listener and adding it to the textpane? or creates a new focusmanager or is it better to do it with the change listener?
here is the code of the tabbedpane class, there is another class that extends a JFrame and has an instance of this class (TabbedPane)

many thanks, I hope it was clear what is the problem.


MA Villamizar
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

Here's some code that does what you want...



-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: FocusListener problem
 
Similar Threads
addMouseListener to JFrame
JTabbedPanne
Action for JMenuItem
warning mesage before leaving particular tab in swings
Swing ChangeEvent occur twice