• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FocusListener problem

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some code that does what you want...

reply
    Bookmark Topic Watch Topic
  • New Topic