Make a JComponent focusable

Hi, I have created a control myself, which extends JComponent. But I found it is not focusable.
Actually the problem is I want to make this control listening to some keyevent but I found adding a keylistener does nothing. I read something in the api document and I think it is because my control won't be able to get focus. I tested it by adding a focuslistener and no focusevent is detected.
Please correct me if I am wrong here. If I am right, does anybody konw a solution? Thanks.

Try overriding isFocusTraversable(). By default it appears to return false;

Similar Messages

  • How to make Finder to focus on the last used foto in the iPhoto folder?

    Hello! I have a 1200-fotos iPhoto folder containing fotos of my last voyage. Im trying to upload some of them them to the account of one of the social networks.
    I scroll through them in iPhoto to chose the best then in Safari press "Upload from file" button on the website.
    But every time I press "Upload from file" button and finder window openeswith the focus on the very first foto in folder! And every time I have to scrooll through all the fotos searhing for the needed foto or have to press Command+f and search by name.
    In windows by default  I have a focus on the file being used the last.
    Any ideas how to manage files in this case not having to scroll all the previous files from hte very start?

    Alejandro,
    I have a 1200-fotos iPhoto folder containing fotos of my last voyage. Im trying to upload some of them them to the account of one of the social networks.
    What kind of folder? A folder with albums in iPhoto, or a folder in the Finder? If the Finder, how are you scrolling in iPhoto to browse a folder in the Finder?  Are you using iPhoto in a referenced mode and accessing the originals using the Finder?
    If yes, there is no connection between your browsing position in iPhoto and the browsing of original files in the Finder.
    If you want to upload a photo you have just seen in iPhoto, the simplest way would be to drag it from the iPhoto window to a folder on your desktop (that will export a jpeg version of the photo) and then to upload it from there. That would save you a lot of scrolling.

  • How to make App Icons focus Moving applied?

    Hi, friends help me to find how to created animated applications icons from builder 6.0,

    Read the following article
    http://fadlijabir.blogspot.com/2012/12/solusi-blackberry-app-world-icon-yang.html
    Or Downgrade your Blackberry app worlds klik this
    http://mobileapps.blackberry.com/devicesoftware/entry.do?code=appworld3
    Choose Replace old apps
    But the best way is upgrading your OS up

  • How can I make a custom component focusable?

    Hi all,
    I'm using a custom made component that consists of a JLabel
    and a JTextField. I want to make this component focusable,
    and when it's in focus I want the JTextField to have the
    focus so that the user can start typing immediately.
    I've looked at the java tutorial
    (http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#focusable).
    When my component gets the focus I request the focus to the
    JTextField. The problem is: whenever i check if my custom
    component has the focus, it hasn't because JTextField has it
    (the focus, i mean :-) ) Which isn't strange i think, but
    how can i solve this problem?

    I want to make this component focusable, and when it's in focus I want the JTextField to have the focus
    The problem is: whenever i check if my custom component has the focus, it hasn't because JTextField has it (the focus, i mean :-) So whats the problem the textField has focus as desired.
    You don't need to make the containing panel focusable in order for the text field to receive focus. The FocusManager is smart enough to place focus on the first focusable component contained in the panel. If you make the panel focusable then you will need to use the tab key twice, once to move focus to the panel and a second time to move focus to the text field.

  • Input Text in a row of a table is not getting focused after PPR

    Hi All,
    I have a use case where the form will have a table and one of the columns will have inputtext and the other column will have outputtext. Once the user enters some data in inputtext and presses the down arrow, i am using autosubmit and valuechangelistener to call some method in bb which will show popup in the page. And after selecting some value from popup, i close the popup by setting the first row's outputtext with some data and wants to make the cursor focus to the next row's inputtext.
    Its working without PPR, but when we use PPR to set the outputtext component, its failing the focus is getting lost. Any ideas would be helpful.
    Regards,
    N

    Hi,
    Check following will helpul
    http://blogs.oracle.com/jdevotnharvest/entry/how_to_programmatically_set_focus

  • When opening new tab, how to make me able to type in the adress bar directly without clicking on it? -- (about:config reset and add-on doesn't work)

    Hi all,
    Need a help relating New Tab on Mozilla.
    I want to be able to directly type in the address bar everytime I open a new tab in Mozilla, without clicking anything. To be clearer, it means that everytime I open the new tab, the blinking cursor is already on the address bar.
    What's happening right now is everytime I open new tab, the cursor is not placed anywhere--not on the search bar on the page, not on the address bar. I should put the cursor somewhere to do something.
    I tried using the about:config reset (1) and installing custom new tab (2), but both do not work.
    When I tried the about:config reset the Reset button is not highlighted (I assume it means it's default already), and the Custom New Tab doesn't yield in different result.
    What confuse me is 2 days ago my Mozilla works just fine. Everytime I opened a new tab, the blinking cursor was on the address bar and I was able to type directly.
    Thank you and appreciate the help!!
    Note:
    (1) about:config reset:
    - Type about:config into the address bar and press Enter.
    - To bypass the warning, press the big button labeled "I'll be careful, I promise!".
    - In the search box, paste browser.newtab.url
    - In the search results, right-click browser.newtab.url and choose Reset.
    (2) Custom Add On reset:
    - Install Custom New Tab. = https://addons.mozilla.org/firefox/addon/custom-new-tab/
    - Open the Add-ons Manager (Ctrl+Shift+A; Mac: Command+Shift+A), then the Extensions category.
    - Next to Custom New Tab, click the Options button.
    - Set whatever page you want to open in each new tab (about:newtab is the default; about:home is the default home page), and make sure "Place focus in URL bar" is not checked.

    ''philipp [[#answer-669209|said]]''
    <blockquote>
    ok, as a follow up i'd recommend disabling half of the addons & restarting the browser - if the problem continues disable the other half & continue until you've narrowed it down to the culprit...
    </blockquote>
    Hi Philipp,
    I read the link you copied on the first post and also tried your recommendation above. None seem to work. Even if I disable all add-ons, the problem still persists.
    One other info, this problem seem to appear after I installed several program yesterday. These programs apparently installed other programs that set my homepage and main search engine to a particular website. But I installed all of these programs already. Would that be a cause of the problem?
    Thanks.

  • Move Tab in focus to start and end doesn't work

    I can't use the shortkey to move the tab to start or end, it only moves the scrollbar in that particular tab to bottom and top of the page.
    https://support.mozilla.org/en-US/kb/keyboard-shortcuts-perform-firefox-tasks-quickly?redirectlocale=en-US&redirectslug=Keyboard+shortcuts#w_editing

    You can use code in the userChrome.css file to make the tab focusable.
    Add code to the <b>userChrome.css</b> file below the default @namespace line.
    *http://kb.mozillazine.org/userChrome.css
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    .tabbrowser-tab[selected="true"] {-moz-user-focus: normal !important;}
    </nowiki></pre>
    The customization files userChrome.css (user interface) and userContent.css (websites) are located in the <b>chrome</b> folder in the Firefox profile folder.
    *http://kb.mozillazine.org/Editing_configuration
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    * Create the chrome folder (lowercase) in the <xxxxxxxx>.default profile folder if this folder doesn't exist
    * Use a plain text editor like Notepad to create a (new) userChrome.css file in this folder (the names are case sensitive)
    * Paste the code in the userChrome.css file in the editor window and make sure that the userChrome.css file starts with the default @namespace line
    * Make sure that you select "All files" and not "Text files" when you save the file via "Save file as" in the text editor as userChrome.css. Otherwise Windows may add a hidden .txt file extension and you end up with a not working userChrome.css.txt file

  • Making JFrame Window Lose Focus to a Native Window

    How can i from within the same JFrame code or another class with the JFrame reference make JFrame lose focus to another native window on the desktop.
    Any tips

    In the core java API you can not make a native window take focus, you would have to use native code (JNI).
    The best you could do would be minimize the JFrame.

  • Focus search field when open Presets and Effects panel

    Hi Adobe-Forum.
    I like to get the cursor automatically placed into the search-field of the preset and effects panel.
    Exists a shortcut or an option for that?
    It’s annoying to use the mouse to get into this field by hand.
    Thank you for your help!
    Cheers
    Brian

    I was mistaken. Every time I go to that panel I click in the search field. I don't recall ever clicking in the panel first then the search field. It was not until I tried it buy clicking outside the search field that I discovered the problem.
    It looks like there is no way to make it automatically focus when selecting the panel with a keyboard shortcut. Might be time for a feature request.
    For most of my effects I add them in the ECP (Effects control Panel and then type the first letter of the category, right arrow, then the first letter of the effect. This works for me because I know where just about all of them are from experience. If I do have to search I simply click directly in the search field.

  • Firefox focus issues

    Hi!
    I have a sometimes very irritating problem with Firefox. I have a Logitech G7 mouse with a tiltable wheel that I've set up to change tabs in forefox, and a sidebutton that I use to close tabs with. I'm just using xbindkeys to bind the mouse buttons to ctrl+page up, ctrl+page down and ctrl+w. The thing is that firefox sometimes seems to loose focus, and ignores keyboard commands. For example when I close my current tab with my mouse or by pressing ctrl+w, and then try to close the next tab too, it doesn't work. I have to click on another window or on the desktop to make firefox loose focus, and then click on firefox again. Then it starts working temporarily again.
    I'm using Firefox 3.0b2 from AUR right now, but I had the same problem with Firefox 2 from extra too. I use gnome with metacity. I also have a couple of plugins installed, but I have tried without any plugins too. I also have the same problem on my laptop, and both my computers use Arch64.
    So, does anyone know a solution to this? It's not such a big deal really, but I gets really annoying sometimes.

    arnuld wrote:
    Aha... and I thought I am the only with Firefox issue
    I use "wmii" and my Firefox always looses focus. In wmii, you can change to different TAGS (like Desktops in GNOME) using "ALT-#" If i have 3 tags opened and Firefox is running on tag-2 and I go to tag-3 to check my messages in pidgin and come back with "ALT-2" I do not see Firefox. I see only border of Firefox and between the border i see my background wallpaper . Clickign with mouse does not bring the focus in anyway..... Quite funny though.. It is happening very frequently , nearly all the time, even if I kill Firefox using <killall firefox-bin> or <kill -9 PID> , the problem remains as it is when I start Firefox again :\
    This also seems to be a different problem from what I'm experiencing, but it seems like there are lots of different firefox focus issues. From your description it almost seems like firefox has crashed for you, since it is no longer drawing itself. Have you tried running firefox from a terminal, to see if you get any error messages?

  • How to drag and drop a swing component that can make it behave like Visio.

    1) How to make a JComponent drag and drop that behave like visio? I understand it's possible to drag and drop a text or image, but no idea on how to do that on JComponent. 2) After the JComponent is dragged and dropped, how to make the JComponent to be able to resize by the user using mouse 3) The area that the JComponent dropped should it be GrassPane, LayerPane, or ContentPane?

    I see where you're going. I'm drawn to Thunderbird because it puts open emails in separate tabs, which makes finding a particular open message easier than searching the task bar for an open outlook message. I do see your point that tab happy programmers, probably too young to remember how cool we thought drag and drop was when it first came out, don't think much of it. As with a lot of software, each programmer has a very limited view of how it their program should be used vs how it is actually used in the wild.
    People work in different ways. When I schedule an appointment with a client, this is often preceded by a series of emails related to whatever the client wants to discuss. I drag and drop those messages into the appointment window so that on the date of the appointment, I have a nice neat summary of the issues right there in the appointment window. I could use workarounds (save email and then attach to the appointment), but that's like a trip back to Windows 3.0 and it's, if I'm not mistaken, 30+ years later. I guess I'll continue to use Tbird for email and outlook for calendar, not my preferred solution, I'd like to flip MS the bird and cut all ties to outlook, and was hoping Tbird was the solution. Not yet, and perhaps not ever, based on your thoughts.

  • IPhone 4S camera will not focus

    My iPhone 4S camera is not focusing, it is the camera on the back. One time I tried to take a photo of a document on paper and it just wouldn't focus on the writing, I turned my phone off and on and then it seemed to be working and focusing again. Recently today I tried doing the same thing but it wouldn't work. I tried turning it off and on but still no luck, a friend told me it was because of the 6.0.1 update that it wasn't focusing but I'm not sure. If someone can help me out that would be really appreciated, thanks

    when you are viewing the object with the camera tap on the object you see on your screen to make the camera focus on it

  • Initial Focus

    I have six text boxes in a panel. How do I make the initial focus to be in the first enabled text box. And how do I make the focus to traverse in a serial order..like how it used to work with setNextFocusableComponent() in jdk1.3.
    Please help.

    Here you are (It's Christmas time ;-) )
    The following programme demonstrates a simple way of controlling the focus
    sequence when navigating with the TAB and shift-TAB keys through the components
    of a panel.
    Here we have only four textfields (tf1-tf4) in one column and two buttons (b1,
    b2) in a second column. When running the programme, the focus sequence is: tf1,
    b1, tf2, tf3, b2, tf4.
    But this is not really what we would like. We'd rather prefer to first fill the
    textfields and then choose between two different actions. So remove the comment
    slashes in
    //    panel.setFocusCycleRoot(true);
    //    panel.setFocusTraversalPolicy(new MyFocusTraversalPolicy());
    Recompile and run, and see that the sequence is now: tf1, tf2, tf3, tf4, b1, b2
    as desired.
    What has happened?
    With "panel.setFocusCycleRoot(true);" we declared our panel as the FocusCycleRoot
    which is an obligatory step. The actual FocusTraversalPolicy is defined in our
    own class MyFocusTraversalPolicy. What happens there? Not very much. The
    important thing is that it extends ContainerOrderFocusTraversalPolicy; read well
    the word "ContainerOrder..." that means the order is taken from our panel IN THE
    SEQUENCE WE ADDED OUR COMPONENTS THERE. Make a brief test in changing the order
    in the panel: Cut the line
        panel.add(tf4);
    and paste it after
        panel.add(b2);
    Compile and run. Yes, our sequence has changed to: tf1, tf2, tf3, b1, b2, tf4.
    Remains to explain the effect of the method "protected boolean accept(Component
    aComp)" in class MyFocusTraversalPolicy. Well, without the accept-method the
    focus would move in our example also to the JLabels and the JPanel itself. So the
    method makes sure that the focus rests only on components which can accept input
    or fire an action.
    import java.awt.*;
    import javax.swing.*;
    public class FocusSeqDemo
      public static void main(String args[])
      { new FocusSeqDemo();
      public FocusSeqDemo()
      { JFrame frame = new JFrame();
        frame.setSize (210,220);
        frame.setTitle ("FocusSeqDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container cp = frame.getContentPane();     
        JPanel panel = new JPanel();
        panel.setLayout(null);
    //    panel.setFocusCycleRoot(true);
    //    panel.setFocusTraversalPolicy(new MyFocusTraversalPolicy());
        JLabel l1= new JLabel("A:");
        JLabel l2= new JLabel("B:");
        JTextField tf1= new JTextField();
        JTextField tf2= new JTextField();
        JTextField tf3= new JTextField();
        JTextField tf4= new JTextField();
        JButton b1 = new JButton("action 1");
        JButton b2 = new JButton("action 2");
        Insets insets= new Insets(0,0,0,0);
        b1.setMargin(insets);
        b2.setMargin(insets);
        l1.setBounds(10,40,20,21);
        l2.setBounds(10,100,20,21);
        tf1.setBounds(30,40,50,21);
        tf2.setBounds(30,70,50,21);
        tf3.setBounds(30,100,50,21);
        tf4.setBounds(30,130,50,21);
        b1.setBounds(110,60,60,30);
        b2.setBounds(110,100,60,30);
        panel.add(l1);
        panel.add(l2);
        panel.add(tf1);
        panel.add(tf2);
        panel.add(tf3);
        panel.add(tf4);
        panel.add(b1);
        panel.add(b2);
        cp.add(panel, BorderLayout.CENTER);
        frame.setVisible(true);
        panel.getComponent(2).requestFocusInWindow(); // component 0 and 1 are the
    //                                             labels.
      class MyFocusTraversalPolicy extends ContainerOrderFocusTraversalPolicy
      { protected boolean accept(Component aComp)
        { if (aComp instanceof JTextField || aComp instanceof JButton)
                                  return super.accept(aComp);
          return false; // JLabel and JPanel.
    }

  • Focusing a JTextField

    I made a guessing game and id like to know how to make the program focus itself on my text field after each press of the guess button, instead of alwayz having to click in the field to get a cursor to enter your next guess.

    use the requestFocus method

  • Automatically focus JInternalFrame when starting the application...

    Hi,
    I wonder why my JInternalFrame is not selected (focused) when I start the application - in NetBeans GUI editor I have set the following properties to make my JInternalFrame automatically selected when the app starts:
    o enabled
    o selected
    o visible
    Can anyone tell me how to make my JInternalFrame focused?
    Thanks
    - Stephan

    Thanks but unfortunately that didn't solve my problem...
    I even tried the following code excerpt...
    try {
        jInternalFrame1.setSelected(true);
    } catch (java.beans.PropertyVetoException e1) {
        e1.printStackTrace();
    }... but it didn't work - my jInternalFrame1 is not focused on startup. Is this a bug in Java 1.4?
    On the other hand I noticed that the example application (InternalFrameDemo) doesn't focus the first internal frame on startup, too - when creating another internal frame from within the application that frame gets focused...
    http://java.sun.com/docs/books/tutorialJWS/uiswing/components/ex6/InternalFrameDemo.jnlp
    Thanks in advance
    - Stephan

Maybe you are looking for

  • White screen appeared twice now when Curve 8520 battery is low? (Please Help)

    I'm really worried that my Blackberry is going to die ... I've only had it just over a year & I'm still paying for it, so for it to die on me would be truly upsetting!! I've had the white screen twice now while my battery is low, I've seen a fix onli

  • Which table we can see unused Asset Code

    Hi All Please tell me that which table for we can unused Asset Code. Ritu Edited by: Ritu V on Jul 13, 2010 8:56 AM

  • Custom Infotype not displaying locked records in the list screen (3000)

    I have a custom infotype (9xxx) that will not display the locked records (locked indicator (sprps) is set to X) in the list screen (3000) in PA20 and PA30. Any ideas on what may be causing the records to not display in the list screen? Thanks, Ted

  • CRM SP5 and BW SP7

    We are on CRM7 and BW SAP EHP 1 for SAP NetWeaver 7.0.The SAP_BW component on BW is at SP level 7 and on CRM side its at SP5.I am having some issues in datasource replications in BW.Should both SP levels be same in order to get business content work

  • Outbound IDOCs in MM

    Hi, I would like to know the outbound idocs that are possible for 1. Purchase Requisition Change 2. Creation of Goods Receipt 3. Cancellation of Goods Receipt. I found some inbound idocs for the above. Thanks in advance. Regards, Venkatesh