JSplitPane, focus and keybindings

Just noticed that the JSplitPane is a bit crazy regarding its keybindings (example below)
- bindings are defined in When_Ancestor, that's the good part
- they only work if the splitpane itself is focused
This requires additional activity for the user: needs to press f8 (and know about that particular binding, me didn't until browsing the bug parade) to first focus, than move the divider
The culprit is BasicSplitPaneUI.Actions in collaboration with Handler:
// actionPerformed
  if (ui.dividerKeyboardResize) {
        // move the divider
// handler focusLost
  ui.dividerKeyboardResize = false;Any ideas how to make them work as expected (that is move the divider if focus somewhere in the child hierarchy, provided no child consumes it) - short of c&p the actions without that check?
Thanks
Jeanette
public class SplitPaneKeyBindings {
    private JComponent createContent(boolean focusable) {
        JButton button = new JButton("left");
        button.setFocusable(focusable);
        JButton other = new JButton("right");
        other.setFocusable(focusable);
        JSplitPane pane = new JSplitPane();
        pane.setLeftComponent(button);
        pane.setRightComponent(other);
        return pane;
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JFrame frame = new JFrame("");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.add(new SplitPaneKeyBindings().createContent(true));
                frame.setLocationRelativeTo(null);
                frame.setSize(400, 200);
                frame.setVisible(true);
}

You can (and should, I guess) use the component's input and action maps.
Kind regards,
  Levi

Similar Messages

  • Camera Raw loses system focus and becomes inactive

    While working in ACR if I hover over any of the command buttons, Save Image,  Open Image, Cancel, or Done for a few seconds the "tool tip" for the button displays and as soon as I move the mouse again the whole Camera Raw windows loses system focus and becomes inactive (every tab, control, menu, etc., becomes greyed out).  To regain the system focus I must move the mouse to the windows 7 taskbar and then back into Camera Raw.  If the fullscreen checkbox in Camera Raw is active the only way to regain system focus is to press the Windows Key twice on the keyboard and move the mouse out of the taskbar tray.  This gets pretty frustrating.  Any clues?

    It doesn't normally do this, I can assure you.  Normally the tooltips just pop up and Camera Raw stays active.
    Do you have any desktop management software installed, besides what Windows provides?
    Are your video drivers up to date?
    -Noel

  • How to focus and select to the next cell with a ListView when scrolling?

    I have a ListView filled with cells and I'd like to scroll to the next cell to have it focused and selected.
    My code works to scroll down but the scroll bar is going to far!
    How can I reduce the scroll size to each cell, so I can see the focused cell? Is there a better way to implements this?
    Here is my code:
    documentListView.scrollTo(0);
    documentListView.getSelectionModel().select(0);
    int indexSize = documentListView.getItems().size();
    for (Node node : documentListView.lookupAll(".scroll-bar")) {
      if (node instanceof ScrollBar) {
      final ScrollBar bar = (ScrollBar) node;
      bar.valueProperty().addListener(new ChangeListener<Number>() {
      @Override
      public void changed(ObservableValue<? extends Number> value, Number oldValue, Number newValue) {
      int selectedIndex = documentListView.getSelectionModel().getSelectedIndex();
      if(selectedIndex <= indexSize && listScrollDown(oldValue.floatValue(), newValue.floatValue())) {
         selectedIndex++;
         documentListView.scrollTo(selectedIndex);
         documentListView.getFocusModel().focus(selectedIndex);
         documentListView.getSelectionModel().select(selectedIndex);
    Thanks for your help,
    Regards

    You could set the IsHitTestVisible property of the WebControl to false but then you won be able to interact with the web page:
    <awe:WebControl ... IsHitTestVisible="False"/>
    Another better option would be to handle the PreviewMouseLeftButtonDown of the WebControl, find the ListBoxItem in the visual tree and then set its IsSelected property like this:
    <ListView x:Name="BrowserListview" ItemsSource="{Binding browserCollection}">
    <ListView.ItemTemplate>
    <DataTemplate>
    <VirtualizingStackPanel Orientation="Horizontal">
    <awe:WebControl Source="{Binding mySource}" PreviewMouseLeftButtonDown="wc_MouseLeftButtonDown"/>
    <Rectangle/>
    </VirtualizingStackPanel>
    </DataTemplate>
    </ListView.ItemTemplate>
    </ListView>
    private void wc_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
    ListViewItem lbi = FindParent<ListViewItem>(sender as DependencyObject);
    BrowserListview.UnselectAll();
    lbi.IsSelected = true;
    private static T FindParent<T>(DependencyObject dependencyObject) where T : DependencyObject {
    var parent = VisualTreeHelper.GetParent(dependencyObject);
    if (parent == null) return null;
    var parentT = parent as T;
    return parentT ?? FindParent<T>(parent);
    Hope that helps.
    Please remember to close your threads by marking helpful posts as answer.

  • Difference between fixed focus and auto focus?

    what is difference between fixed focus and auto focus and which is better?

    Thanks for the advice Phonehacker, this Forum is so helpful on a variety of subjects, and the users are so patient, that's why I enjoy it so much   My diet is now perfectly organised and my larder is full of Brown Bread and Red Wine 
    If I have helped at all, a click on the White Star is always appreciated :
    you can also help others by marking 'accept as solution' 

  • Gainer Focus and Lost Focus

    How implements the methods to gainer focus and lost focus?
    Thanks

    Use a node.focusedProperty() change listener to know when a field gains or loses focus.
    Call node.requestFocus() to ask for focus (for some reason I have to wrap this in Platform.runLater to get it to actually do anything).
    Call node.setFocusTraversable(false) if you don't want the user to be able to tab to the node, but still be able to click on the node to give it focus.
    Call node.setDisable(true) if you don't want the node to be focusable at all.
    I'm not sure how the focus traversable order is calculated, perhaps the order that items are added to the scene?
    Not sure how you would create a custom focus traverse if you needed one.
      @Override public void start(Stage primaryStage) {
        final TextField tf1 = new TextField("First but not initially focused");
        final TextField tf2 = new TextField("Second initially focused");
        Platform.runLater(new Runnable() { public void run() { tf2.requestFocus(); } });
        final TextField tf3 = new TextField("Can focus by clicking on, but not by tabbing to.");
        tf3.setFocusTraversable(false);
        final TextField tf4 = new TextField("Cannot focus at all.");
        tf4.setDisable(true);
        tf1.focusedProperty().addListener(new ChangeListener<Boolean>() {
            public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
              if (newValue) {
                System.out.println("First text field gained focus");
              } else {
                System.out.println("First text field lost focus");
        VBox root = new VBox(); root.setSpacing(5);
        root.getChildren().addAll(tf1, tf2, tf3, tf4);
        primaryStage.setScene(new Scene(root, 300, 100));
        primaryStage.show();
      }

  • The jpegs in my movie start in focus then quickly go out of focus, and then come back to focus just as the clip ends

    The jpegs in my movie start in focus then quickly go out of focus, and then come back to focus just as the clip ends

    Viewed in FCP or after export?
    Russ

  • Camera focusing and resolution.

    Camera doesn't seem to focus and takes poor pictures.  what is wrong?

    iPad has a very low resolution camera for still pictures. It is not really meant to be used as a camera, more for video confrencing. For focusing you need to tap on the area you want clear and be careful not to move.

  • IPhone 4 keeps focusing and refocusing in video

    When shooting video with my iPhone 4, the image keeps focusing and refocusing as I move the camera causing the picture to pop in and out of focus. It's happening in all video apps so I'm suspecting the phone.
    Ideas?

    Basic troubleshooting steps clearly outlined in the User Guide are restart, resest, restore from backup, restore as new.
    If you still have problems after going through ALL the recommended troubleshooting steps, then you likely have a hardware issue.  You'll need to bring your phone into Apple for evaluation.

  • JS: Get Control that has the Focus and paste something into it

    Hi,
    I want to implement some clientside code that gets the control that has the focus and copy some text into it.
    Can this be easily accomplished?
    Thanks
    Sven

    Hi,
    According to your post, my understanding is that you want to get the focus element via JavaScript.
    We can use the document.activeElement to get the current active element.
    http://stackoverflow.com/questions/497094/how-do-i-find-out-which-dom-element-has-the-focus
    http://stackoverflow.com/questions/11277989/how-to-get-the-focused-element-with-jquery
    Then you can use the obtained focus element to paste text into it.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected]
    Jason Guo
    TechNet Community Support

  • How to set focus and mark red on certain select option field

    hi experts
    I embedded a select_option view in my application and  tried to use IF_WD_SELECT_OPTIONS->request_focus to set focus on a certain select option field if the logical check failed, and also hope the low field of the select option can be marked red....but things does not happen that way....
    could anyone kindly tell me how to implement that requirement?
    tkx and regards
    sun

    What is the problem you are facing in this ?
    Requesting focus is easy.
    just call the method request focus and pass the id of the parameter whose lower value field you want to focus.
    as shown below.
    code you might have written in wddoinit
    DATA: LT_RANGE_TABLE TYPE REF TO DATA,
            RT_RANGE_TABLE TYPE REF TO DATA,
            READ_ONLY TYPE ABAP_BOOL,
            TYPENAME TYPE STRING.
        DATA: LR_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER,
            L_REF_CMP_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE.
    *   * create the used component
      L_REF_CMP_USAGE = WD_THIS->WD_CPUSE_SELECT_OPTIONS( ).
      IF L_REF_CMP_USAGE->HAS_ACTIVE_COMPONENT( ) IS INITIAL.
        L_REF_CMP_USAGE->CREATE_COMPONENT( ).
      ENDIF.
        WD_THIS->M_WD_SELECT_OPTIONS = WD_THIS->WD_CPIFC_SELECT_OPTIONS( ).
        WD_THIS->M_HANDLER = WD_THIS->M_WD_SELECT_OPTIONS->INIT_SELECTION_SCREEN( ).
    LT_RANGE_TABLE = WD_THIS->M_HANDLER->CREATE_RANGE_TABLE( I_TYPENAME = 'ZDEALERID' ).
    * * add a new field to the selection
      WD_THIS->M_HANDLER->ADD_SELECTION_FIELD( I_ID = 'ID'
      IT_RESULT = LT_RANGE_TABLE I_READ_ONLY = READ_ONLY ).
    code for focusing a field.
    wd_this->m_handler->request_focus( i_id = 'ID' ).
    you must have declared attributes m_handler and m_wd_select_options type reffering to IF_WD_SELECT_OPTIONS and
    IWCI_WDR_SELECT_OPTIONS respectively.
    and regarding that red color i am not sure it is possible without using message manager.
    thanks
    sarbjeet

  • The code to set focus and cursor position fails in a mobile browser

    In two previous discussions (http://scn.sap.com/message/15176399 and http://scn.sap.com/message/15205348) I received help on how to set the focus on an OpenUI5 mobile input field and then how to position the cursor at the end of any text that might be in that field.
    That all works well in desktop browsers (Chrome, Firefox and IE10).
    However that same code seems to fail when I test it on browsers on mobile devices. At first I thought this was working in Chrome on an iPad but now it does not (could our taking new OpenUI5 code recently affected that?). I do not think I have ever see this work in Chrome on a, Android tablet.
    Has anyone had success setting the focus and cursor position on a mobile input field running in a mobile environment?

    Wasn't sure where to turn with this problem. There is talk on the web that there is a problem in Chrome on Android and that this will be fixed in version 37. We I get that version I will try and update this post.

  • Click button/link in out of focus window to bring focus AND select button

    example: firefox and mail are both open; mail is in front and ff is in back, out of focus but visible. there's a website open in ff, and I'm reading a mail message. I want to click on a link in the open ff page, but mail has focus. I must click the ff link TWICE (once to bring ff to focus, and once to then click the link). on a windows machine, all the buttons and links in all visible apps are always "live", so this annoyance doesn't happen. can it be fixed in tiger?

    I believe this is considered correct behavior for Mac apps, despite the few that don't behave this way. It would all too easy to try to click on a mostly-hidden window to bring it to the top and accidentally click on something important - like an "Okay" or "Cancel" button. Things like buttons and links are only SUPPOSED to be "clickable" in the frontmost window, for user safety reasons.
    For consistency, the rule applies whether or not the second window is mostly hidden, mostly visible, or whatever. Think of the confusion that "sometimes it takes one click, sometimes it takes two clicks" would engender!
    By contrast, more than once I've done something unwanted (but so far not terribly destructive) in Windows when I was trying to change window focus but instead did something in that mostly hidden window.
    Doug

  • One day it just stopped focusing and the pictures are blurry.  If I switch it to the front camera it works well and looks like it should but when I turn it back it goes back to being out of focus and I can't figure out how to fix it?

    i installed ios 7.after  that my primary cam, one day it just stopped focusing and the pictures are blurry.  If I switch it to the front camera it works well and looks like it should but when I turn it back it goes back to being out of focus and I can't figure out how to fix it?

    This advice will sound like a joke or prank, but believe me it worked on my iPhone 5 and my daughter's.  The lens mechanism got stock on each of our iPhones.  We found a post on these message boards that said to hold the iPhone about 6 inches above a table or counter top and drop it so that it lands flat on it's back.  Now try the camera ...Fixed!  It has been more than six months now and neither of our iPhones have ever experienced the problem again. 

  • My I5s camera hardware have problem. Can't focus, and the pictureis very fuzzy. I brought this 5s in Canada, but I use it in China. I can't get support in China to fix  my phone.

    I brought my 5s last year in Canada. And take back to China to use.
    few days ago, I found my camera can't focus and the picture is fuzzy .
    I had call to Apple's Chinese service for check and help. After they check, they said this is the hardware 's problem.
    Because  my 5s is come from Canad, so they can't help me to fix my phone.
    I am in China now, what can I do about my phone?
    Camera is very important to me.
    Please give me the solutio.
    thank you very much.

    If a phone is sold from one friend to another and wants to use it on a different carrier the friend can contact the carrier it was sold by to request it unlocked.  I know AT&T, Verizon, and Sprint will give you the steps to unlock it as long as the original contract it was bought under has been completed.  eBay/Craigslist is really not the best place to try to get "unlocked phones" from, if it turns out the phone isn't unlocked then I'm really sorry you got stuck with that one and as stevejobsfan said above I would report them immediately and see if you can recover your money.  I sell phones for a living and this happens a lot

  • Keep focus and actionlistener

    I open as a popup a custom JPanel but
    I want to keep focus and actionlistener on it
    while it is opened.
    is there a way?
    thanks for any clue

    I tried removing all the pattern validations on the field and added this below code in the validate event of the text field and it works..
    var strCode;
    var f = /^([A-Z]{2}[1-9]{5}[A-Z])$/;
    if(this.rawValue != null && String(this.rawValue) != "") {
                        strCode = String(this.rawValue);
                        if (f.test(strCode) == false) {
                                            xfa.host.messageBox("Invalid pattern!");
                                            xfa.host.resetData();
                                            xfa.host.setFocus(this);
    xfa.host.setFocus(this);

Maybe you are looking for