Focus with JComboBox? HELP!!!

How do you set the focus for a JComboBox? When I use the addFocusListener on a JComboBox it does NOT gain or lose any focus. But when applied to a JButton you'll see it gain and lose focus. Is this a bug in java for the JComboBox?
Here's an example of the usage
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JApplet {
MyFocusListener focuslistener = new MyFocusListener();
JButton button_1 = new JButton("regular button 1");     
JComboBox combo_2 = new JComboBox(new Object[] { "item1", "item2" } );
     public void init() {
          Container contentPane = getContentPane();
          combo_2.setNextFocusableComponent(button_1);
          button_1.addFocusListener(focuslistener);
combo_2.addFocusListener(focuslistener); //<--------- Add listener here
          contentPane.setLayout(new FlowLayout());
          contentPane.add(button_1);
          contentPane.add(combo_2);
class MyFocusListener implements FocusListener
          public void focusGained(FocusEvent e)
               Object object = e.getSource();
               System.out.println("OBJECT: " + object);          
          public void focusLost(FocusEvent e)
          System.out.println("Focus lost" + e);

This is a quick hack to the focuslistener added to a JComboBox. I noticed that inorder to obtain some focus on a JComboBox you must requestFocus on it. Therefore what I do is I requestFocus right after the button has lost focus. Might not be the best thing to do but it's a quick hack.
Code listed below.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Test extends JApplet {
JButton button_1 = new JButton("regular button 1");     
JComboBox combo_2 = new JComboBox(new Object[] { "item1", "item2" } );
MyFocusListener focuslistener = new MyFocusListener();
MyComboListener combolistener = new MyComboListener();
     public void init() {
          Container contentPane = getContentPane();
          combo_2.setNextFocusableComponent(button_1);
button_1.addFocusListener(focuslistener);
combo_2.addFocusListener(combolistener);
          contentPane.setLayout(new FlowLayout());
          contentPane.add(button_1);
          contentPane.add(combo_2);
button_1.requestFocus();
class MyFocusListener implements FocusListener
          public void focusGained(FocusEvent e)
               Object object = e.getSource();
               System.out.println("Button gained Focus");          
          public void focusLost(FocusEvent e)
          System.out.println("Button lost Focus");
combo_2.requestFocus(); //<------------ This is the trick
class MyComboListener implements FocusListener
public void focusGained(FocusEvent e)
               Object object = e.getSource();
               System.out.println("COMBO gained Focus");          
          public void focusLost(FocusEvent e)
          System.out.println("COMBO lost Focus");
}

Similar Messages

  • Back button focusing with the 6D

    I cannot get my 6D's back button focus (AF-ON) to work.  After following directions on Canon's website on how to set it up, the button just does not do anything.  Auto focus only works  with the shutter button.  I have the function set to "P" which I understood to be o.k.  Would resetting the camera to factory default help?  I would prefer not to have to send the camera to Canon for a one button repair.  The camera body was purchased new and is still under warranty.
    Thanks
    Solved!
    Go to Solution.

    It's super easy to set up BBF on a 6D....
    If you have already been changing some things and are unsure which ones, you might want to reset all the Custom Functions to factory default, before starting. (Note: There is a way to view which C.Fns are set and to what each is assigned... As you enter each of the four C.Fn groups, note the list in the lower LH corner of the LCD screen, that shows all the C.Fns in that group at a glance. The top line is the C.Fn number, the bottom line is the setting for each C.Fn.)
    To set up BBF....
    All you have to do is go into the menu, Custom Functions, C.Fn III-5, operations/others, button assignments. Select and enter that and then press "set" and this should take you right to the top of the LH column, which is a graphic illustration of the shutter release button. Press set again to enter this, then scroll to select the center option "start metering" and press "set" once more to select this choice, then press "menu" button several times to back out of the menus. Done!
    What this does is remove AF start from the shutter release button.  By default it's already assigned to the AF-On button on the back of the camera too, so BBF is set up and ready to use as soon as you remove it from the shutter release button.
    Metering and Image Stabilization will continue to start with a half press of the shutter release button or whenever you press the AF-On button. But AF will  only start with your thumb on the AF-On button. Using BBF, you now can use AI Servo most of the time, for stationary or moving subjects. If you want to "focus and recompose", simply focus and then lift your thumb off the AF-On button to leave focus where it is and recompose as you see fit. (Without BBF, you cannot do focus and recompose.... it will cause mis-focused shots.) You still might want to switch back to One Shot when you want high precision focus with stationary subjects.
    There is another option you may want to consider...
    Using the same Custom Function III-5, if you prefer you can swap the functions of the AF-On and * (AE Lock) buttons. I do this on my cameras for a couple reasons: One is that the * button is larger, more prominent, and closer to my thumb... so I prefer to use it for focusing. The other reason is that older Canon models that didn't have the AF-On button, you had to use the * button and that's the way I learned to use BBF (Note: In some cases there was an AF-On button on the body but not on the vertical grip, while older cameras simply didn't have an AF-On button at all, on the body or the grip).
    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 

  • Error while adding a custom field with Input help via AET

    Hi All,
    I need to add two custom field under Service orders at Item level in component BT140I_SRVP.
    One field is required to have the input search help f4 and autopopulates the second field
    I am able to add one field(not requiring help) successfully through AET .
    I have created one Zsearch_help in se11 and its successfully running  and Autopopulating seocnd field while I am testing it
    While adding second field through AET,I need to enter following details as -
    field label,search relevant ,serach help etc.
    When I type the name of my 'Zsearch_help' against field search help it gives me following error
    'Search help is not compatible'.
    Secondly,not getting getter and setter methods for the attrributes in BTAdminI.
    Last,please tell me if i create zhelp and activate it,would it automatically appear in the list on AETwhile assiging it to input field?
    Please help me out.Kindly be detailed as I am new to SAP CRM.
    Thanks,
    Shivani

    The question is answered in CRM 7.0 forum:
    Getting error while adding a custom field (with input help) through AET

  • Creation of report with the help of report painter

    Dear Experts,
                         I need report painter material, if any body have  pls  farward to me.
    my intension to create controlling report with the help of report painter.
    I am ready to award full points.
    Thanks in advance
    Regards
    avudaiappan
    Moderator - Please read this:
    /thread/931177 [original link is broken]
    Thread locked

    Hello Chinasammy,
    Report Painter allows you to create reports using data from SAP application components, which you can adapt to meet your individual requirements.
    Many of your reporting requirements can already be met by using the standard reports provided by various SAP application components. If these SAP standard reports do not meet your reporting needs, Report Painter enables you to define your specific reports quickly and easily.
    When executing a Report Painter report, it is displayed by the system in Report Writer format. You thus have access to the same functions as for Report Writer reports defined in the same way, and can combine Report Painter and Report Writer reports together in a report group.
    Report Painter uses a graphical report structure, which forms the basis for your report definition and displays the rows and columns as they appear in the final report output.
    To facilitate report definition, you can use many of the standard reporting objects provided by SAP (such as libraries, row/column models, and standard layouts) in your own specific reports. When you define a Report Painter report you can use groups (sets). You can also enter characteristic values directly.
    Advantages of Report Painter include:
    Flexible and simple report definition
    Report definition without using sets
    Direct layout control: The rows and columns are displayed in the report definition as they appear in the final report output, making test runs unnecessary.
    =============================================
    Below mentioned is the process for creating reports using Report Painter as a tool.
    Selecting and maintaining a library for your report: As the transfer structure to Report Painter you use a report table, which is defaulted by SAP and can not be maintained. This table contains characteristics, key figures and predefined columns. In a library, you collect the characteristics, key figures, and predefined columns from the report table, which you need for your Report Painter reports.
    When you define a Report Painter report, you assign it to a library. Reports assigned to one library can only use the characteristics, key figures, and predefined columns selected for that library.
    When you create or maintain a library, the Position field determines the sequence in which the characteristics, key figures or (predefined) key figures appear in the Report Painter selection lists when you define a report. This allows you to position the objects that you use regularly in your reports at the beginning of the selection lists. If you do not make an entry in the Position field, you will not be able to use this object in Report Painter reports.
    You can use either the standard SAP libraries for your reports or define your own.
    (ii) Selecting or maintaining a standard layout for your report: Standard layouts determine report layout features and the format of your report data.If the SAP standard layouts do not meet your reporting requirements, you can create a new  standard layout or change an existing one.
    (iii) Defining row and column models: A model is a one-dimensional, predefined reporting structure that you can insert in either the rows or columns of your report.If you often use the same or similar row or column definitions in your reports, it is recommended that you create row or column models.
    You must define the row and/or column models that you want to include in your report definition before you define the report.
    You can also use the standard column models supplied by SAP.
    (iv) Defining the report: Defining a Report Painter report involves the following steps.
    (a) Define the report columns: You define the report columns using the characteristics, key figures, and predefined columns selected for the library that the report uses. Alternatively, you can use a column model for column definition. Column models are predefined column structures which you insert into your entire column definition, instead of defining each individual column.
    (b) Define the report rows: You define the report rows using the characteristics selected for the library selected for the report.
    Alternatively, you can use a row model for your row definition. Row models serve the same purpose as column models, but are used to define a report row.
    Edit and format the report rows and columns in line with your requirements. (For example, you can hide rows or columns, define the column width or define colors for your report rows).
    (iii)Define general data selection criteria for the selection of your report data: Selection criteria are the characteristics used to select data for the entire report. You cannot enter characteristics as data selection criteria if they are already being used in the report rows or columns.
    (iv) Assigning the report to a report group: Once you have defined a report, you must assign it to a report group. A report group can contain one or more reports from the same library. However, reports that share the same data will select data more quickly and improve processing time.
    Hopw this helps you. Please let me know if you need anything more and assign points.
    Rgds
    Manish

  • Custom report templates with the help of BI Publisher.

    Hi All,
    I have created custom report templates with the help of BI Publisher it is working as we excepted.
    refered : https://blogs.oracle.com/kyle/tags/reports
    But our requirement want to change the color of heading and include filters in output report, It is possible, if yes pls share you comments?
    Best Regards
    Pradeep

    how silly of me!
    just restarting the tomcat sorted the problem!!!

  • IPad 1 Safari crashes frequently. I went to many Apple stores in different countries and each Apple staff member had their own different opinions with no help. I had upgraded my iOS to 5.1.1 and the Safari crashing started about one year

    IPad 1 Safari crashes frequently. I went to many Apple stores in different countries and each Apple staff member had their own different opinions with no help. I had upgraded my iOS to 5.1.1 and the Safari crashing started about one year after the upgrade and some Apple staff blame this- but this started one year later after the iOS upgrade. Recently at the Apple Store in Vancouver an Apple staff reset my computer (erased everything and sent to iCloud to reset the iPad) and I hoped this would fix the problem. IPad Safari still crashes. Short of booking an appointment for taking it for repair to Apple technicians which will cost me money can anyone help me to fix this Safari crashing.

    Hi,
    You might have a 3rd party plugin that isn't compatible with Safari 4.0.4. Go here for help...
    Safari add-ons can cause performance issues or other situations
    If you are using a USB hub, try disconnecting and restarting with just your keyboard and mouse connected.
    From the Safari Menu Bar, click Safari / Empty Cache. When you are done with that...
    from the Safari Menu Bar, click Safari / Reset Safari. Select the top 5 buttons and click Reset.
    Mac OS: Web Browser Quits Unexpectedly or Stops Responding
    Also, you could download and install the 10.5.8 combo update (PowerPC) available here.
    http://support.apple.com/downloads/MacOS_X_10_5_8_ComboUpdate
    It contains fixes that might help. Then repair disk permissions.
    Quit any open applications/programs. Launch Disk Utility. (Applications/Utilities) Select MacintoshHD in the panel on the left, select the FirstAid tab. Click: Repair Disk Permissions. When it's finished from the Menu Bar, Quit Disk Utility and restart your Mac. If you see a long list of "messages" in the permissions window, it's ok. That can be ignored. As long as you see, "Permissions Repair Complete" when it's finished... you're done. Quit Disk Utility and restart your Mac.
    Carolyn

  • How do I reset the password that allows me to download reader - I worked with chat help - we rest my password and I can get into my adobe account but when I try to download reader and work my way through the process when I get to the password it will not

    How do I reset the password that allows me to download reader.. I worked with chat help two hours last night - we have reset a password that lets me into my adobe account but in the download reader process that password will not work - where it says Adobe reader wants to change something and please type in password, just vibrates with the dots glowing purple but will not open…. what do I do to reset that password or get it to function. they would not assist me further they said its a free download and I would need to seek help from forums ( all this is new to me )
    so "forums" help…what do I do ?
    thank you
    PL

    patricia here again:
    I am the system administrator - personal computer
    I have been able with your lead to find the password I need , and to have install happen
    however - when I then go to the website to download the Pdf document I need I get a screen with the big red adobe icon that says to complete and down load this document I must launch adobe reader a dn sign the terms of agreement , close browser and reopen.
    but thatscren has no choice buttons whatsoever, I cannot find anywhere a adobe reader image to launch - been into launch pad , preferences etc.
    so now the loop is the pdf document and the adobe screen saying I must do terms of agreement
    like is this Kafka like or what ...
    suggestions?
    thanks
    P.

  • Replication of Berkeley DB Xml Edition with the help of JAVA API

    hi,
    i am trying to replicate berkeley DB to 2 other replicas.with the help of small program which along with its documentation(of chapter 3). And i'm using java API for the same(specifically replication framework program.)
    All necessary files are get created at host side like log files, dll files, db files. But at replica(client) side nothing get created. Host and clients are placed in the same network.
    But unfortunately its not working. don't know the reason. And its not giving any sort of error. And i dont know how to go ahead. Or is there any other way should i proceed with.
    So could you help me out to get rid of this problem.
    Thanks

    What compiler are you running?
    See this message and thread:
    Re: Problem after update to 2.3.8
    It may be necessary to apply the -fno-strict-aliasing flag to the Berkeley DB Java library as well.
    Regards,
    George

  • I had to restore all the files on my pc using carbonite.  I reinstalled iTunes and was able to find my music with the help of Apple support.  How do I find my podcasts?

    I had to restore all the files on my pc using carbonite.  I reinstalled iTunes and was able to find my music with the help of Apple support.  How do I find my podcasts?

    This helped, I restored them, but when I go to iTunes they are not there.    Is there another step?

  • My 3 year-old macbook pro is very slow. I have run disk utility and virus scan with no improvement. The "beach ball" will spin for minutes at a time when opening, closing or changing windows. Apple Store looked at it a few months ago with no help.

    my 3 year-old macbook pro is very slow. I have run disk utility and virus scan with no improvement. The "beach ball" will spin for minutes at a time when opening, closing or changing windows. Apple Store looked at it a few months ago with no help. What can I do?

    Under CPU: 3.5% user; 5% system; 91% idle; 441 threads; 90 processes.
    Under System: out of 2GB - 54.7MB free; 530MB wired; 603MB active; 862MB inactive; 1.95GB used.
    Is too much of the system memory tied up? If so, what can I do to free some up?

  • Java Script Error while deploying a Model with Value Help

    Hi,
    I am using EP 7.0 SP 10.
    I am trying to deploy a model which includes the Value Help for an Input field, and i am trying to deploy this model.
    The model compiles successfully, but gives a Java Script Error while deploying the model,
    ! Error on Page
    When Click on this java script error, it shows that ,
    Line:14985
    Char 1: Error
    object does n't support this property or method.
    code
    URL: <serverhost>/VCRes/WebContent/VisualComposer6.0/bin/223334.htm?24102006.1712.
    The Same model works in dev server, and it fails in the production server.
    Thanks and Regards,
    Sekar

    Hi jakob,
    Thankyou for your quick response.
    I did a basic model with the help of a documentation which i got from this forums.I created a iView and from there i used Bapi "BAPI_SALESORDER ".
    I created a Input Form and a outpot form (table view).I tested model and am able to get the output.but when i try to deploy it is giving me the error.
    And i think am not paring any formulas here.
    Please guide me.
    thanks and regrads
    Pradeep.B

  • My iPhone 5 is not being recognized by my iMac.  All my other devices, including iPod and iPad are recognized with no sync problems.  I've tried every approach with online help as well as an Apple advisor by phone.  Help?

    My iPhone 5 is not being recognized by my iMac.  All my other devices, including iPod and iPad are recognized with no sync problems.  I've tried every approach with online help as well as an Apple advisor by phone.  Help?  Any other suggestions other than going to an Apple Store?

    Back to life**
    Oh I know there are many other vocabulary mistakes but never mind them I was just too excited when I wrote all of that while typing very quickly
    P.S: if you have any question then ask and please do tell me if it works or not with u but I'm definitely sure it'll work so tell me this and we'll get excited together
    Also if you have an experience to share then do share it as well please.
    Peace

  • When I enter my password to start my atv it tells me, that "there was a problem connecting to the network."  My Ipad works fine but not my new atv.  I have reset my password multiple times with no help.  I have also rebooted my wireless server.take it bac

    When I enter my password to start my atv it tells me, that "there was a problem connecting to the network."  My Ipad works fine in my house, but not my new atv.  I have reset my password multiple times with no help.  I have also rebooted my wireless server.  Do I take it back?

    Where is everyone????  Does anyone have an answer???
    Allik1

  • Transfer Of Data from Sap to Oracle with the help of Enterprise Services.

    Hello,
    We want to transfer data from Sap to Oracle using standard Enterprise Services.Some fields were not available in the existing standard Enterprise Services,so we have enhanced the existing Services by writing code inside BADI available with Enterprise Services.Rest of the fields we have mapped with the existing fields available in standard Enterprise Services.But,the Oracle people want to fetch all data from Sap without entering any input as a mandatory field in the Enterprise Services.The existing standard Enterprise Services require to enter any field as mandatory and are not accepting the range in input for multiple records.e.g.All enterprise Services related to Sales Orders are displaying only one sales Order.We have searched all Enterprise Services for Sales Order(related to reading of data),but not able to find service which would display mutiple records without entering any input.ECC_SALESORDER009QR is the only service which is displaying multiple records without entering any input,but the required fields are not available in this service.So,kindly suggest what we need to do further.
    1.Should we go for customization of services completely,so that it would fulfil our requirement.
    2.Are there  standard Enterprise Services exists which would we give us data in range(all records).
    If they exists,please specify the names of Services for reading Purchase Order,Production Order,BOM etc.
    Thanks & Regards,
    Divya.

    Hi Vaibhav,
    Let me tell you the objective in detail.
    Objective.
    To develop a package solution which will work as a bridge between Oracle APS and SAP system so that customers using SAP will be able to use advantages of Oracle APS for their planning needs.
    This will consist of following major components:
    OA Templates is an Oracle utility to load data from any legacy system to Oracle APS using standard flat files.
    Oracle has developed an Application Integration Architecture which is a standard architecture used for integration of Oracle products with other systems.
    Enterprise services is an SAP utility to communicate with SAP.
    AIA canonicals are standard canonicals developed by Oracle where we have to map data fields from destination system (Oracle APS) and source system (SAP)
    Fusion middleware is being used to develop application interfaces following AIA standards.
    Tasks at stake:
    Mapping of Oracle APS fields and SAP Enterprise Service fields to AIA canonicals
    Technical work of developing middleware using Oracle Fusion
    From Sap side,we have to map fields which we have received from Oracle with the help of Enterprise Services,rest  consumption of these services is done by Oracle guys.So,suggest is there enterprise services available which would give us multiple records .
    Thanks & Regards,
    Divya.

  • With the help of script i want to identify each and every thing in a indesign file

          i want to identify the each and every thing in a .indd file with help of script.and also i have to find totally how many farmes or things present in that file
    kindly guys help me out.
    and also suggest me some ideas.
    thanks in advance
    regards,
    siv 

    thanks ya...
    Actually my recuirment is there will be so many number of frame or text frame will present there in a indd file
    >with the help script im giving number to the script label . it follows the order of Stack
    (the frame designed latest will get the latest script label)
    >in a particular order the frame has to get numbered in script label
    i.e
    either from right to left or left to right.
    hope u got my point
    kindly help me out
    regards siv

Maybe you are looking for

  • In R12.1.3, MO:Security Profile Vs HR:Cross Business Group precedence

    Hi All, In R12.1.3, Which profile option has higher precedence in MOAC structure. If i set the HR:Cross Business Group to NO at resp level and MO: Security Profile, which is associated to Global Security Profile which has two OUs of two different BGs

  • IPhone 5 backup & iTunes

    Just noticed today that I cannnot backup my iPhone 5 to iCloud. The last backup was Dec. 12. Also, I cannot access iTunes from my phone to do app updates. This just started today. I did check the iCloud status page and all is green. Any one else noti

  • BuddyAPI functions

    Greetings, i'm using buddyApi function "baGetFiles" in order to load .swf files. By default, the "baGetFiles" function is"files = baGetFiles( the moviePath & "images", "*.jpg", "", "My program", "Select pictures to import", 3, 100, 100 )" example giv

  • Installation of Logitech QuickCam Pro 9000 on iBook G4 (MAC OS X 10.3.9)

    Hi iBook friends, I am writing from Munich, Germany. I just got my first webcam and I am a bit lost... I got the Logitech QuickCam Pro 9000 and I have no idea how to install it... Can somebody give me a hand? Thank you very much!

  • Having problems removing tags from script.

    I'm not using the browser to run Adobe Story, but the Desktop version from my iMac.  Cmd + Double Click works, but once every 30 times.  Is anyone else having this problem removing tags from a script?