Button focus for mnemonic control

Does anybody know how to set the focus on a JButton, in order for the mnemonic key to work? I have a Frame with textarea and a button, and the button ("Close") is set with a mnemonic key (`C`). I just don't know how to set the focus on the button so that when I hit Alt + C, the window will be close. Here is my code sample:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BorderExample {
     private Frame f;
private JButton close;
private Panel p;
private TextArea ta;
public BorderExample() {
f = new Frame("Border Layout");
close = new JButton("Close");
close.setMnemonic('C');
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
     System.exit(0);
ta = new TextArea();
ta.append("Hello World");
ta.setEditable(false);
public void launchFrame() {
f.add(ta, BorderLayout.CENTER);
p = new Panel();
p.add(close);
f.add(p, BorderLayout.SOUTH);
f.pack();
f.setSize(200, 200);
f.setVisible(true);
public static void main(String[] args) {
BorderExample ex = new BorderExample();
ex.launchFrame();
Any suggestion is greatly appreciated.

hi,
this time i got ur exact problem. actually mnemonic control workes fine if all the components are in the same container. in ur example, they r in different panels. so, we need to make following changes :
1) create a reusable action listener object, not the anonymous.
2) call one method on the button panel : (methos in JComponent class, bur depricated since JDK1.3.)
p.registerKeyboardAction(<action listener object>, <String action command>, KeyStroke.getKeyStroke(<key char value for mnemonic control>),JPanel.WHEN_IN_FOCUSED_WINDOW);
this will fire the desirable event, even if u press alt-c while typing in text area.
and regarding the grey color of text area, i am sorry about my previous reply. in disabled mode, background color doesn't change. just the text color changes and u can set that text color by calling this method of JTextComponent
jtextcomp.setDisabledTextColor(Color c) ;
hope this helps!!
anshu

Similar Messages

  • Back button focusing for 5d Mark III. How do I set it up?

    How do I set up Back Button focusing on my new 5D Mark III.  Can't find instructions in Canon supplied manual or third-party book.
    Solved!
    Go to Solution.

    It's really easy because it's mostly already set up... The AF-On button on the back of the camera already starts and stops AF.
    To set up true BBF technique, you turn off the AF function at the shutter button. I believe it's Custom Function IV, 1:  Opertaion/Others.... where you make button assignments.  Navigate to the shutter button icon and press "set" to enter the options for that... change to the center one "metering start" and press "set" again. Done.
    Optionally you can swap the function of the AF-On and "*" (AE Lock) buttons, using the same button assignment tool.
    Alan Myers
    San Jose, Calif., USA
    "Walk softly and carry a big lens."
    GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
    FLICKR & PRINTROOM 

  • What settings do I use to back button focus set up for the d5 mark 3? TIA

    5D Mark 3
    Solved!
    Go to Solution.

    When you activate the menu, scroll over (using the dial on the front of the camera) to the orange "C.Fn2: Disp./Operation" menu. (that's the icon of a camera that has a index marks for a light meter below it -- right of the wrench icon, left of the star icon.)
    Each of those menu's on the 5D III have multiple pages.  It's the 2nd page (the 2nd dot from the left) that has the category for "Custom Controls".  Highlight that (using the dial on the back this time) and click the 'set' button.
    That brings up a menu showing each of the major controls on the back of the camera and what they do.  Highlight the icon for the shutter button (this only changes the behavior of a half-press) and change it from "Metering and AF start" to just "Metering start".
    The "AF-ON" button (on the back of your camera) is likely already set to "Metering and AF start" (I believe that's the factory default.)  
    So you're not so much enable back-button focus (which is already probably active)... you're more "disabling" the focus when  the shutter button is pressed half-way.
    Good luck
    Tim Campbell
    5D II, 5D III, 60Da

  • Not user friendly behaviour for CNiNumEdit control when it has got a focus

    The CNiNumEdit hasn't user friendly behaviour when it has got a focus on TAB event for example.
    If you set a value in your prgram like this code:
    m_ninumedit.SetValue ( 1234 );
    and the focus is on other control and then you press TAB for changing the focus and the control m_ninumedit got it but it put the edit cursor in front of the first character '1'.
    The correct behaviour would be that the control selects all characters to be ready to edit a new value.
    The later versions that 7.1.0.313 have a bad behaviour (cwui.ocx)

    Hello Benjamin,
    You will find  the sources code to test the behavior of CNiNumEdit by using the TAB key between two controls CNiNumEdit.
    Best regards
    Armageddon
    Attachments:
    TestCNiNumEdit.zip ‏510 KB

  • Keep focus in a control until certain conditions are met?

    Hello,
    Is there a way to keep focus at a control until certain conditions are met?
    For example, if I might want to keep the focus set to a text field inside a tab unless the text field contains something valid.
    If user tries to switch to different tab without having valid text inside the text field, I would like to pop up a stage/dialog and abort the tab switching.
    Please help!
    Thanks.

    Hi. Here is an example:
    import javafx.application.Application;
    import javafx.beans.value.ChangeListener;
    import javafx.beans.value.ObservableValue;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.*;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.stage.Modality;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.WindowEvent;
    public class SSNValidation extends Application {
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(final Stage primaryStage) {
            primaryStage.setTitle("SSN Validation");
            Button btn = new Button();
            final TextField tfSSN = new TextField();
            StackPane layout = new StackPane();
            Scene scenePopup = new Scene(layout, 424, 154, Color.TRANSPARENT);
            final Stage stage = new Stage();
            stage.initModality(Modality.APPLICATION_MODAL);
            stage.setScene(scenePopup);
            stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
                @Override
                public void handle(WindowEvent event) {
                    tfSSN.requestFocus();
            tfSSN.focusedProperty().addListener(new ChangeListener<Boolean>() {
                public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, final Boolean newValue) {
                    if (!newValue) {
                        if (tfSSN.getText().length() < 9) {
                            stage.show();
            final TextField tf2 = new TextField();
            btn.setText("Submit");
            VBox root = new VBox();
            root.getChildren().addAll(tfSSN, tf2, btn);
            primaryStage.setScene(new Scene(root, 300, 250));
            primaryStage.show();
    }

  • Add support for colorist control surfaces

    A Lightroom feature I would like to see is support for colorist control surfaces such as those made by Tangent Devices, JL Cooper, Euphonix, etc. Working with still images in Lightroom is rather like color grading motion scenes (daVinci, Apple Color, etc.). A colorist interface with simultaneous image adjustments would really bring a whole new level of interactivity and efficiency to a photographer's photos.

    Hi all,
    I've been around midi music and controlers for a while, and I believe I posted a question for LR+midi a (possibly VERY) long time ago to one of the forums (I can't even remeber the answer).
    IMHO, if adobe were ever to do something like that, THE reference is http://www.novationmusic.com/products/midi_controller/nocturn
    This is a contoller+software, where the contolers "sees" in what window (read LR module) you are working, "talks" to LR to get information on which sliders are available and then auto-maps the available hardware sliders and buttons to the onscreen ones.
    The advantage, you don't develop a hardware product which is dedicated to one software (even version) and it is very customisable.
    But maybe let's first focus on getting LR3 our in good shape and get this on Adobe's list for 3.X somewhere.
    Kindest regards,
    Bart

  • How to prevent the backspace conditionally. if no focus in any control in the document ?

    I prevent a backspace button conditionally using confirm box. i used event.preventdefault() method to stop the event of i press ok in the conform box.
    But it works when the focus is on either input or text area elements.
    if there is no focus in these controls the browser redirects to previous page.
    i need your help..
    thanks in advance !

    Hi dineshkumar,
    Thank you for your question. I understand that there are some default hot keys that are not being prevented in a web page unless they are focused in an input html tag. I do not know if this is for a website you developed or if this is for all websites, but:
    If it is for all websites: you can use a key configuration to change it only in Firefox [http://kb.mozillazine.org/Keyconfig_extension]
    If it is in a website:
    *Please see the MDN article for more information on the Javascript call you are using: [https://developer.mozilla.org/en-US/docs/Web/API/event.preventDefault]
    *Here is a relevant stack overflow question: [http://stackoverflow.com/questions/1357118/event-preventdefault-vs-return-false]
    Thank you and we hope this helps.

  • 70D and Back Button focus

    I have set up the camera for back button focus.   HOWEVER ... when I review shots taken using BBF, in Aperture, the "Focus Point" display indicates I focused always in  the center of the screen, not off to the right or left, as I might have recomposed.  Yes, I keep the AF On button pressed.

    I don't have 70D, but have been using BBF most of the time for the past 15 years with various Canon film and digital cameras. I'm one of those folks who swear by it! And I would guesstimate that most people I've taught to use it over the years love it and swear by it, too. BBF allows you to use AI Servo as your default AF mode, so is particularly popular with sports photographers or anyone else shooting action and moving subjects. I'd rather have my camera in AI Servo, since it can be used with both moving and stationary subjects. One Shot can mostly only be used with stationary subjects. So, using AI Servo as my default mode, I'm better prepared for whatever happens. If you don't use BBF there are times that AI Servo can cause problems, such as when you use single point and a focus and recompose technique. So, that's basically why I use and swear by BBF. It puts me in more full control and allows me to have my cameras in AI Servo ready and ready to quickly get a shot of almost anything, using most any technique I wish. But, based on your description, you might be using BBF wrong.  You wrote, "I have set up the camera for back button focus... as I might have recomposed...  I keep the AF On button pressed." In fact, this is exactly the opposite of what you need to do. What you should do when focusing and recomposing with BBF is NOT maintain pressure on the back button.  To focus and recompose while using BBF and AI Servo: first put the AF point on the subject and achieve focus... Then release the button so the AF stays focused on the subject, while recomposing as you see fit. The subject stays in focus. (You cannot do sngle point/focus and recompose in AI Servo mode with shutter-release based AF control enabled. You have to use One Shot.) One caveat, if using a zoom and part of your recomposing involves changing its focal length, be aware that many modern zoom lenses are "varifocal" designs that do not maintain focus when zoomed. With those, you'll be fine so long as you are using AI Servo, BBF and not recomposing (i.e, not moving the AF point off the subject)... the camera automatically corrects focus as you zoom. But if you zoom a varifocal lens at the same time or as a part of the recomposition, you need to remember to update focus on the subject after changing the focal length... else you'll miss focus. Look for info about any zooms you use, to see if they are varifocal and need refocusing after zooming... Or if they're "parfocal" type that will maintain focus during zooming. I only very rarely take my cameras out of BBF now... Mostly just if I'm lending one to someone who doesn't know how to use it and I don't have time to give them a lesson. BBF puts me more in control of the AF system... of exactly when and where it focuses. It gives me the best of both worlds: the speed and accuracy of AF, plus user control more like we had when we manually focused our lenses. Like others, most of the time I tend to use center AF point only. I just don't have time to set up planned shots when shooting sports/action. Plus with some cameras and lenses the center point is higher performance. But, I see AF point selection as a somewhat separate consideration from BBF... and single point/center only works quite well in conjunction with BBF... or not. More info about BBF here: http://www.learn.usa.canon.com/resources/articles/2011/backbutton_af_article.shtml ***********
    Alan Myers
    San Jose, Calif., USA
    "Walk softly and carry a big lens."
    GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
    FLICKR & EXPOSUREMANAGER 

  • Team Foundation Server 2013 Refresh button not refreshing Custom Control values in TFS Templates

    Hi all,
    We have recently migrated from Team Foundation Server 2010 to Team Foundation Server 2013 Update 2. In TFS 2013 template design we found the refresh form control (inbuilt control of TFS) which is unable to refresh the custom control values that is built
    by us. Is there any way that we can programatically modify to enable the refresh button work with custom control.
    Please find below screenshot link for reference.
    http://postimg.org/image/z4mo3t8r9/
    SaranRam

    Hi SaranRam,
    The refresh button is there to allow the data that populated the work item to be refreshed. The data that you want refreshed is part of the rendering of the form and would only be refreshed when the browser refreshes. Refer to MrHinsh's reply in this
    page.
    Best regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How can I set up a custom keyboard shortcut for volume control?

    Hi all,
    I use my black MacBook at work, connected to an external monitor and external keyboard. I'm looking for a way to set up the F buttons on my external keyboard as volume control, just as they do on my laptop keyboard. Looking for F3 to F5 to be volume mute, down, and up, respectively.
    I tried going into Keyboard Shortcuts in System Preferences but since there is no menu item for volume control I can't seem to add it. Anyone know how I can go about doing this or what I'm missing?
    Thanks
    Mike

    paste the following into Applescrpt Editor (it's in /Applications/Utilities)
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    set curVolume to output volume of (get volume settings)
    -- work out the new setting
    if curVolume < 96 then
    set newVolume to curVolume + 5
    else
    -- can't go over 100
    set newVolume to 100
    end if
    -- and apply it
    set volume output volume newVolume</pre>
    this script will increase volume by 5 (out of 100) any time you run it. you can adjust this of course. save the script somewhere.
    You can use a 3rd part app launcher to bind a keyboard shortcut to it. I use Butler. there are many others: Quicksilver, ikeys, quickeys, Spark, Launchbar.
    this will work the fastest.
    If you don't want to use 3rd party tools for this you can make a service using automator but that might be a bit slower than the first option. open automator. it will give you a pulldown screen wiuth the choice of what you want to make. choose "service". set it to receive no input and be available in all applications. add the following "run apple script" action to the service
    <pre style="
    font-family: Monaco, 'Courier New', Courier, monospace;
    font-size: 10px;
    margin: 0px;
    padding: 5px;
    border: 1px solid #000000;
    width: 720px;
    color: #000000;
    background-color: #ADD8E6;
    overflow: auto;"
    title="this text can be pasted into the Script Editor">
    on run {input, parameters}
    set curVolume to output volume of (get volume settings)
    -- work out the new setting
    if curVolume < 96 then
    set newVolume to curVolume + 5
    else
    -- can't go over 100
    set newVolume to 100
    end if
    -- and apply it
    set volume output volume newVolume
    end run</pre>
    save the service, go to keyboard system preferences->keyboard shortcuts->services and make a shortcut for the service you just created.

  • Does Av digital adapter works with the universal dock for remote control?

    if I only connect the Lightning to 30 pin adapter to the universal dock for remote control it works so good with music, spotify, Netflix, YouTube etc.
    but if I add the av digital lightning adapter to watch on Tv, the dock and remote control don't work anymore    what can I do? I want to watch stuff on tv and use the IR dock for remote control please help me what's going wrong?

    Thanks for your advice.
    I recently purchased a universal dock for my iphone 3g. It works great. I just had one question. When my iphone is sitting on it for lets say 20 - 30 minutes. Then if i press the buttons on the remote. nothing happens! If I then press the home button while it is on the cradle then, the remote, it plays music. There after lets say if I stop stop the music through the remote and again press the remote button after a few minutes it starts playing. So what happens after a long time. Why do i have to press the home button on the iphone for the remote to work. Is that how it is supposed to work???
    Thanks

  • With Traditional NI-DAQ Compatibility VI's the acquisition locks when I press the increment or decrement button of a numeric control.

    Hello all.
    I´m using a PCI-6220 and the Traditional NI-DAQ Compatibility VI's to make the acquisition that is in the attached VI. But when I click the increment/decrement button on the numeric controls my acquisition stops. In the same PC I made the same experience with a 6040 and I could not see this problem. I tried with the PCI-6220 with the DaqMX VI's and I could not see this problem too, for these reasons I believe that the problem has something to do with the Traditional NI-DAQ Compatibility VI's.
    I built machines that can have one or the other board (depending if it is low-end or normal). Does somebody knows the solution for this problem?
    Thanks in advance.
    Paulo Carmo
    Attachments:
    experiencia.vi ‏49 KB

    Hello
    For what I’ve seen on National web site, using the “Traditional compatibility VI’s”, it sould be possible to control a NI-DAQmx using code written in NI-DAQ Traditional. This information was obtained from the following NI link:
    http://digital.ni.com/softlib.nsf/954feaeea92d90918625674b00658b83/9d67f671bcc6850586256e630059308b?...
    Please read this information and then tell me something please.
    Best regards!

  • The acquisition locks when I press the increment or decrement button of a numeric control

    Hello all.
    I´m using a PCI-6220 and the Traditional NI-DAQ Compatibility VI's to make the acquisition that is in the attached VI. But when I click the increment/decrement button on the numeric controls my acquisition stops. In the same PC I made the same experience with a 6040 and I could not see this problem. I tried with the PCI-6220 with the DaqMX VI's and I could not see this problem too, for these reasons I believe that the problem has something to do with the Traditional NI-DAQ Compatibility VI's.
    I built machines that can have one or the other board (depending if it is low-end or normal). Does somebody knows the solution for this problem?
    Thanks in advance.
    Paulo Carmo
    Attachments:
    experiencia.vi ‏49 KB

    Hello
    For what I’ve seen on National web site, using the “Traditional compatibility VI’s”, it sould be possible to control a NI-DAQmx using code written in NI-DAQ Traditional. This information was obtained from the following NI link:
    http://digital.ni.com/softlib.nsf/954feaeea92d90918625674b00658b83/9d67f671bcc6850586256e630059308b?...
    Please read this information and then tell me something please.
    Best regards!

  • JavaScript Error : Can't move focus to the control because it is invisible,

    I have one JSP page in my project where i am putting all input to save personal details of a person.
    This personal details header contains button(to collapse or expand).
    I input all details and save. It works fine but when i collapse the header and name, age etc are not visible.
    Only Save and cancel button is visible. so i click on save and following javascript error show up :
    Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
    In case of expand mode,If there is any error while providing input in text boxes , i have given pop up to display that like " Name field is mandatory " and control focus to that field again. it works fine.
    In case of collapse, as fields are not visible and if i directly click on save button. Pop up is displayed as usual "Name field is mandatory" but it pop up again javascript error
    "Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus."
    Please let me know how to reolve this?

    1) there is a JSP forum
    2) that still doesn't make it a forum to ask javascript questions
    Please let me know how to reolve this?Who says that you can resolve it? If it isn't allowed, don't try it. Likely you'll have to rethink the design of your page.

  • Active Focal Point Not Shown in Software Using Back Button Focus

    I use Back Button Focus (BBF) and set the focus point (using center spot).
    In the software (DPP, ZoomBrowser or EOS Utility) the point I selected is not highlighted in the view window.
    All points are shown, but none highlighted.
    If I take the same shot using default focus method (shutter button AF), the point is highlighted .
    Why is this?
    Not too technical, please
    Canon 3Ti, EF 50mm f/1.4 USM, EF-S 18-55mm f/3.5-5.6 IS II, EF-S 55-250mm f/4-5.6 IS II, 320EX Speedlite

    Thanks.
    I did just download and install the updates (DPP, EOS, Picture Style Editor and Zoom Browser).
    Still no red focus point(s) shown with Back-button Focusing.
    I searched on the web for this "symptom" and found, that I'm not alone.
    It seems in Back-Button Focusing, the focus point won't be displayed unless you hold the back button down (* button  in my case) while pressing the shutter button.
    I tried holding the * button while taking a shot and yes the red box shows up.
    This seems like defeating the usefulness of back button focusing. (???).
    What do I know? I'm just a newbie.
    Canon 3Ti, EF 50mm f/1.4 USM, EF-S 18-55mm f/3.5-5.6 IS II, EF-S 55-250mm f/4-5.6 IS II, 320EX Speedlite

Maybe you are looking for

  • Issues with UpdateAction and later using jbo:RowsetIterate

    Hello - I am putting together a BC4J/Struts web app and am having some issues with using the oracle.jbo.html.struts11.actions.UpdateAction class. I am trying to figure out the correct way to reset a row after validation exceptions so that <jbo:Rowset

  • CS3 crashes when Opening and saving files - also runs slow

    Today, while using photoshop, it locked up on me & I had to force quit. It then wouldn't open a file either via Bridge or the open menu. I could create a new file, but it would hang while attempting to save. I downloaded and ran the FixVCUIFramework,

  • Abiword 3.0 - crash when save as pdf

    Recently I have upgraded Abiword to 3.0. When save a document in pdf format Abiword crashes and leaves 2 files in the directory: .gsf-save-XXXXXX documentname.abw.saved Is it an issue with the new 3.0 version or something is wrong with my system? In

  • "Invalid Password" Message from Network

    My 1 year old Time Capsule has been working perfectly since I bought it. Now all of a sudden I don't get logged in automatically to my network. In addition, I can't connect to my network manually; when I try it asks for my password (that Airport Util

  • Difference between LDAP andOID

    Hi all Can anyone please explain me the Difference between LDAP and OID?..... Is there any difference or they completely different Thanks