Regarding Focus on Uielement

Hi experts
   I create 2 input fileds  and i set focus on Ist inputfield when browser open.When i click the tab the focus goes to addressbar.I want the focus to be on 2nd input field.
Plz give me the solution

Hi,
Check the <b>label for</b> properties of the second input box.
Is the second text box enabled?
Regards
Ayyapparaj

Similar Messages

  • Problem regarding focusing elements after submit

    Hi all
    I have a bunch of radio groups with submit on my page . The requirement is to set focus on the next radiogroup with submit after any radiogroup with submit is clicked.
    But the problem is When user changes the value the focus is moving to the top of the page. Is there any way that we can keep the focus on the same item or other item at the same level ?
    I have written the following statement in HTML Form Element Attributes and Form Element Option Attributes of the first radiogroup with submit (called P4_X) : onClick = "document.getElementById('P4_E').focus();" (The last radiogroup with submit on the page is called P4_E).
    But alas it just doesnt work :-(
    If this is any help, I am pasting a sniplet of the 'view source' of my page
    <td colspan="2" valign="top" class="t3Body"><table class="formlayout" summary="" ><tr><td nowrap="nowrap" align="right"><a class="t3optionalwithhelp" href="javascript:popupFieldHelp('3886301842732082','12829541423701975766')" tabindex="999"></a></td>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="3886301842732082" /><fieldset id="P4_X"><input type="radio" name="p_v01" value="%null%" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" /><span onClick = "document.getElementById('P4_E').focus();">%</span>
    <input type="radio" name="p_v01" value="choice1" checked="checked" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_1" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_1">choice1</label></span>
    <input type="radio" name="p_v01" value="choice2" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_2" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_2">choice2</label></span>
    <input type="radio" name="p_v01" value="choice3" onclick="doSubmit('P4_X')" onClick = "document.getElementById('P4_E').focus();" id="P4_X_3" />
    <span onClick = "document.getElementById('P4_E').focus();"><label for="P4_X_3">choice3</label></span></fieldset>
    <td colspan="1" rowspan="1" align="left"><input type="hidden" name="p_arg_names" value="3891304050742114" /><fieldset id="P4_E"><input type="radio" name="p_v08" value="choice1" onclick="doSubmit('P4_E')" id="P4_E_0" />
    <label for="P4_E_0">choice1</label>
    <input type="radio" name="p_v08" value="choice2" onclick="doSubmit('P4_E')" id="P4_E_1" />
    <label for="P4_E_1">choice2</label>
    <input type="radio" name="p_v08" value="choice3" onclick="doSubmit('P4_E')" id="P4_E_2" />
    <label for="P4_E_2">choice3</label></fieldset>
    <a class="eLink" title="Edit" href="javascript:popupURL('f?p=4000:371:14317056829894007819::::P371_ID,FB_FLOW_ID,FB_FLOW_PAGE_ID:3891304050742114,101,4');" tabindex="999"><img src="/i/e.gif" alt="Edit" class="eLink" /></a></td></tr>
    Please help me out !!
    Regards
    -Shantanu Dhanuka

    Hi,
    1 - Create a new HTML region on your page called "Scripts" and in the "Display Point" select "Before Footer" - this places the region at the bottom of the page.
    2 - Create a new Item and put in the new region. Call the item P1_FOCUS_FIELD. Set its Default Value to the name of the field that will receive the focus when the page is FIRST loaded (P_E_1?).
    3 - In the new region's Region Footer, add in the following:
    &lt;script type="text/javascript"&gt;
    var f = document.getElementById("P1_FOCUS_FIELD").value;
    document.getElementById(f).focus();
    &lt;/script&gt;
    4 - Update your submit process to set the value of P1_FOCUS_FIELD to the ID of the field that you want to receive the focus when the page is reloaded.
    Regards
    Andy

  • Regarding Focus and Validation message on the JDialog

    Hi All,
    Can any body provide the Solution for the below scenario.
    I have a dialog ,on this i have some components like combobx , TextField and check box etc..... and also one OKButton and Cancel button.
    The problem is when i enter some invalid data or with out entering the values in any fields , if i click on ok button a validation message will be displayed stating that perticuler field is mandatory and if i click on that validation message the focus should go to the corresponding field.
    it is not happening some times(i.e the focus is not going to the corresponding field)
    but some times it is happening.
    can u provide a solution or suggest me on this regard.
    Thanks in Advance.
    Regards,
    jeevan.

    Put the request focus code inside this:
    SwingUtilities.invokeLater(new Runnable()
         public void run()
                 //Put the code here to set the focus
    });

  • Regarding Focus on InputField

    Hi Experts,
       I have created 3 input fields in a view.
       I set focus on First Inputfield
       When i click Tab in keyboard the focus went to address bar.
      I want to set the focus on next inputfield when i click tab .
      Plz give me suggestion

    Hazrath,
    Keep all the input fields in a transparent container. Make sure the 'labelFor' property of the Labels for the input fields, point to one of the inputfields. (otherwise, tab focusses on label instead of inputfield.
    Try and let me know.
    Regards,
    Rajit

  • Focus box anomoly (continued from prior IE alpha issue)

    The "standard" PNG fix for IE doesn't work when there are
    JavaScript image
    swaps on the page.
    The "Fix" for it causes the transparent background to 'flash
    white' for a
    second as the image loads.
    Anyone know of any other fixes?
    Here's an example.
    http://www.buddhapada.com/tests/png_mouseover.htm
    Works fine in FF, but you'll see the image background of a
    second in IE.

    Wow...not REALLY not paying attention today.
    Meant to post this here:
    Let's start off with my confession that I haven't a genuine
    clue about how
    this focus stuff works.
    Focus box/lines stuff seems inconsistent all over the place.
    Some sites show
    them, some don't (even without "scrubbing" code) in both IE
    and FF. Safari
    doesn't seem to ever display them, but I have that by
    hearsay, only.
    http://www.buddhapada.com/tests/feral.htm
    The four graphic links across the top of this page will
    display focus boxes
    when clicked in FF or if you tab through them, but the "moth"
    link at the
    right doesn't show the focus box on click or during a tabbing
    cycle and
    during the tabbing cycle there is a point where the focus box
    highlights the
    entire page.
    In IE6 clicking on any of the links will NOT produce a focus
    box, but the
    focus boxes DO appear during tabbing INCLUDING the 'moth'
    link at the right.
    What are the words of wisdom regarding focus box display
    cross browser?

  • Facing troubles with "requestFocus()"

    Hi
    Can anyone help me telling what is wrong with my code?. I hv 2 JTextFields and both will hv their values checked when losing focus. My problem is that a MessageDialog is showed telling what's wrong for the user, but then when ok button is clicked, the same messagedialog appears but with no button or message and everything freezes.
    Here's my code
    public void focusGained(FocusEvent e)
    public void focusLost(FocusEvent e)
    if (e.getSource().equals(edtCityCode))
    //check if CityCode is valid or not               
    if (!valid)
    JOptionPane.showMessageDialog(null, "This code is not valid. Type another");
    edtCityCode.requestFocus();
    else if (e.getSource().equals(edtCityName))
    if (edtCityName.getText().equalsIgnoreCase(""))
    JOptionPane.showMessageDialog(null, "You must type field = cityname");
    edtCityName.requestFocus();
    Thanks in advance.

    After reading all over Sun/Google/Yahoo about this bug and the workarounds posted for this problem I finally got to get it to work as per my requirements.
    Following were some of the constraints that I had:-
    1) All screens are already developed and buttons are already coded so I cannot go back and
    substitute extended JButton instance with has altered behaviour regarding focus events.
    So the one possible workaround that for this problem which involved extending JButton was ruled out.
    2) I want to make the IV generic so that it can read from some property file the rules to validate this.
    (I did not include this stuff in the implementation below but if you need that you can ask via email.
    3) I did not liked the idea of altering the basic plaf which was another way how people have worked out their ways from this problem.
    So here is my solution.
    1: Assign an extended verifier SCAInputVerifier to the JTextField/JTextArea. Pass the Container that contains the text field to the constructor of SCAInputVerifier.
    2: First time when the verify() method is called it creates a SCAJFocusListner as listed below. It validates and keeps the result in SCAInputVerifier but always returns true.
    3: As soon as the focus is about to loose to the next component the SCAJFocusListner comes into picture
    and displays the message via JOptionPane.showMessageDialog().
    (Before clicking the Ok button on this error message dialog if the user clicks on any AbstractButton it showed random behaviour.
    This is addressed in point 5)
    (Optional)
    4: As a general rule I we have all Cancel button or Close button closing the JDialog and their name starts with Cancel.
    If the user clicks cancel or close button on the screen user is allowed to go exit.
    5: Now the main problem:If the focus was going to a AbstractButton it was showing weired behaviour.
    It was getting pressed as soon as mouse was over that button.
    This problem is fixed in focusLost() method of SCAFocusListener.
    6: The focus is requested back into the text field.
    * SCAFocusListener.java
    * Created on August 14, 2003, 7:01 PM
    package walgreens.sca.system;
    import java.awt.event.*;
    import javax.swing.*;
    * @author Yogesh Gadge
    public class SCAFocusListener extends FocusAdapter{
    private SCAInputVerifier iv = null;
    public SCAFocusListener(SCAInputVerifier iv) {
    super();
    this.iv=iv;
    public void focusLost(FocusEvent fe) {
    if ( (! iv.isGood()) && iv.getParentPane()!= null && iv.getParentPane().isVisible()) {
    java.awt.Component opp = fe.getOppositeComponent();
    //if cancel or close button
    if (opp instanceof AbstractButton) {
    AbstractButton aBut = (AbstractButton)opp;
    String name = aBut.getText();
    if(name != null && (name.trim().toLowerCase().startsWith("cancel") || name.trim().toLowerCase().startsWith("close"))) {
    return;
    //workaround for bug in JDK 1.4.1 bugID 4342333
    ButtonModel mod = aBut.getModel();
    aBut.revalidate();
    if (mod.isArmed())
    mod.setArmed(false);
    if (mod.isPressed())
    mod.setPressed(false);
    JOptionPane.showMessageDialog(iv.getParentPane(),"Input is invalid.");
    java.awt.Component c = fe.getComponent();
    //fe.consume();
    c.requestFocusInWindow();//InWindow();
    } else
    super.focusLost(fe);
    import javax.swing.*;
    import java.awt.event.*;
    * @author Yogesh Gadge
    public class SCAInputVerifier extends javax.swing.InputVerifier {
    private java.awt.Container parentPane=null;
    private boolean good = false;
    private FocusListener focusListener = null;
    /** Creates a new instance of SCAInputVerifier */
    public SCAInputVerifier(java.awt.Container parentPane) {
    this.parentPane=parentPane;
    public boolean verify(javax.swing.JComponent comp) {
    if (focusListener == null)
    comp.addFocusListener(createFocusListener());
    this.good=true;
    if (comp instanceof javax.swing.text.JTextComponent) {
    javax.swing.text.JTextComponent field = (javax.swing.text.JTextComponent) comp;
    String input = field.getText();
    System.out.println(input);
    try {
    //lets say it is convergence factor
    double d = Double.parseDouble(input);
    if (d < 0.0 || d >=1.0 )
    good=false;
    } catch(Exception e) {
    good=false;
    return true;
    public boolean isGood() {
    return this.good;
    protected FocusListener createFocusListener() {
    FocusListener f = new SCAFocusListener(this);
    System.out.println(f);
    this.focusListener=f;
    return f ;
    /** Setter for property good.
    * @param good New value of property good.
    public void setGood(boolean good) {
    this.good = good;
    /** Getter for property focusListener.
    * @return Value of property focusListener.
    public java.awt.event.FocusListener getFocusListener() {
    return focusListener;
    /** Setter for property focusListener.
    * @param focusListener New value of property focusListener.
    public void setFocusListener(java.awt.event.FocusListener focusListener) {
    this.focusListener = focusListener;
    /** Getter for property parentPane.
    * @return Value of property parentPane.
    public java.awt.Container getParentPane() {
    return parentPane;
    /** Setter for property parentPane.
    * @param parentPane New value of property parentPane.
    public void setParentPane(java.awt.Container parentPane) {
    this.parentPane = parentPane;

  • My shooting setup

    Hi all
    Well after reading through this forum it seems there is a lot of information about how many images should be shot etc. so I thought I would share my setup as I seem to be embarking on a bit of a mission. I need to be really accurate, as the images will be used in photogrammetry, so I am being as scientific as I can be. The camera is a Canon 1ds Mark II, and I have these lenses:
    28mm
    50mm
    85mm
    24-105mm
    24-85mm
    70-200mm
    8mm fisheye
    I have a small studio of approx 16ft in length.
    Primes:
    close-up focus distance: 9 x chart positions, 1 stop aperture increments
    mid focus distance: 9 x chart positions, 1 stop aperture increments
    far focus distance:  9 x chart positions, 1 stop aperture increments
    Zooms:
    close-up focus distance, widest zoom: 9 x chart positions, 1 stop aperture increments
    close-up focus distance, mid zoom: 9 x chart positions, 1 stop aperture increments
    close-up focus distance, tele zoom: 9 x chart positions, 1 stop aperture increments
    mid focus distance, widest zoom: 9 x chart positions, 1 stop aperture increments
    mid focus distance, mid zoom: 9 x chart positions, 1 stop aperture increments
    mid focus distance, tele zoom: 9 x chart positions, 1 stop aperture increments
    far focus distance, widest zoom: 9 x chart positions, 1 stop aperture increments
    far focus distance, mid zoom: 9 x chart positions, 1 stop aperture increments
    far focus distance, tele zoom: 9 x chart positions, 1 stop aperture increments
    Now, not only do I have my work cut out for me, but I doubt I have the space needed. What I would like to know is are all the focus distances really needed? I guess giving how exact we need our profiles to be it is in fact a requirement? Also I thing getting smaller grids will be needed for some of the telephoto and close-up shots seeing as I dont have a huge amount of room?
    Any thoughts will be appreciated.
    Elliot

    Hi Elliot, the first potential big timesaver is to check if the Adobe-supplied profiles work well on your system. For example, with the public Camera Raw 6.2 Release Candidate and Lightroom 3.2 Release Candidate (posted last night), Adobe has Canon lens profiles for all 50 mm lenses except the f/2.5 compact macro, both 85 mm lenses, the 24-105 zoom, and all 70-200 lenses. If these do work well for you, then that takes care of 4 of your 7 listed lenses, including two zooms (which are more time consuming to profile).
    Regarding focus distance: yes, it does matter, but only if you shoot in those conditions. For example, if you never use your 28 mm at minimum focus distance, then it's not worth profiling it at that distance. Consider doing just 2, or maybe even just 1 focus distance.
    When we build profiles internally at Adobe for broad distribution, we really can't assume how a lens will be used (i.e., we can't go around saying, "don't use this lens at minimum focus distance ... !"), so we need to cover the bases and build thorough profiles that will work well under a broad range of field & studio conditions. But for profiles that you're building for your own use, this is not necessarily the case.

  • Installation stops without error

    After a reinstallation of Office 365 on a Win 7 ultimate 64 bit system I am not able to reinstall my Visio 2013 Pro. After inserting the installation disk the setup.exe starts but nothing happens. I tried to start the setup.exe from the DVD by double click
    as administrator but still the same behaviour.
    I also tried to copy the DVD to a local directory and to start the setup but always the same - nothing happens and no error message appears.So what to do now?
    best regards,
    focus 043

    Hi,
    It’s most like that the installation DVD is corrupted. Is the DVD damaged?
    If so, you can download a copy of Visio 2013 from this site.
    http://office.microsoft.com/en-us/products/download-back-up-restore-microsoft-office-products-FX103427465.aspx
    You may need to run “Fix it” to uninstall Visio 2013 before reinstalling it.
    http://support.microsoft.com/kb/2739501
    Regards,
    Greta Ge CHN
    TechNet Community Support

  • Regarding Cursor focus by default

    Hi Experts,
    Please help I need something like this.
    For Example
    Start- All Programs-Accessories---Calculator.
    As we all are aware of the start menu when we click start, it opens but when we keep the cursor over any of the options like All Programs it opens and shows other options related to that.
    Please help me whether it is possible in web dynpro or not.
    Its urgent..
    Regards
    Nutan

    Hi Armin,
    Like in Start--->Programs. In the same way I need to display my records.I am having Two buttons A and B. And if I will keep my mouse over  A somw documents will display in a tree structure with the save button. Similarly with Button B.So ,Please help how to achieve this.
    Regards.
    Nutan

  • 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

  • JInternalDialog stealing the focus in Linux environment.

    I have the code which opens new JInternalFrame (showPopup() method). When this code is called from EDT directly, for instance from actionPerformed() then newly opened JInternalFrame does not steal focus from other applications ... but If this code called from EDT, but for instance in SwingWorker done() method ... then it does, newly opened JInternalFrame steals focus from other appliaction. Some from GUI programmer point of view the same thread call the same piece of code but get the different behavior ... This is reproducable only under Linux OS (I have tried under Fedora and Scientific Linux) .... Any ideas ?
    Below code which you can try, just compile and run ...
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.Rectangle;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.JDesktopPane;
    import javax.swing.SwingWorker;
    import javax.swing.WindowConstants;
    import javax.swing.JInternalFrame;
    public class FocusTest implements ActionListener {
         private JDesktopPane desktop;
         private JInternalFrame frame;
         private JInternalFrame iframe;
         private JButton button1;
         private JButton button2;
         public FocusTest(){
              JFrame.setDefaultLookAndFeelDecorated(true);
              JFrame externalFrame = new JFrame();
              desktop = new JDesktopPane();
              desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
              frame = createMainFrame();
              desktop.add(frame);
              externalFrame.add(desktop);
              externalFrame.setSize(new Dimension(700, 300));
              externalFrame.setVisible(true);
         private JInternalFrame createMainFrame() {
              button1 = new JButton("EDT Dialog");
              button1.addActionListener(this);
              button1.setToolTipText("Wait 2 seconds then show popup, openInternalFrame(), directly in EDT (without any switching between threads).");
              button2 = new JButton("Worker Dialog");
              button2.addActionListener(this);
              button2.setToolTipText("Wait 2 seconds then execute SwingWorker and in done method show popup, openInternalFrame()");
              JPanel panel = new JPanel();
              panel.add(button1);
              panel.add(button2);
             JInternalFrame internalFrame = new JInternalFrame();
             internalFrame.add(panel);
             internalFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
             internalFrame.setBounds(new Rectangle(300, 150));
              internalFrame.setVisible(true);
                try {
                     internalFrame.setSelected(true);
                } catch (Exception e) {
                     e.printStackTrace();
            return internalFrame;
         private void showPopup(){
             JPanel panel = new JPanel();
              panel.setLayout(new BorderLayout());
              JPanel msgspanel = new JPanel();
              msgspanel.add(new JLabel("INTERNAL FRAME"));
              panel.add(msgspanel, BorderLayout.PAGE_START);
              JPanel buttonpanel = new JPanel();
              final JButton ok = new JButton("Ok");
              final JButton cancel = new JButton("Cancel");
              buttonpanel.add(ok);
              buttonpanel.add(cancel);
              panel.add(buttonpanel, BorderLayout.PAGE_END);
              iframe = new JInternalFrame();
              iframe.setTitle("Internal Frame");
              iframe.add(panel);
              ok.addActionListener(new ActionListener() {
                   @SuppressWarnings("synthetic-access")
                   public void actionPerformed(ActionEvent evt) {
                        iframe.dispose();
              cancel.addActionListener(new ActionListener() {
                   @SuppressWarnings("synthetic-access")
                   public void actionPerformed(ActionEvent evt) {
                        iframe.dispose();
              iframe.pack();
              iframe.setLocation(frame.getLocation().x+10, frame.getLocation().y+10);
              iframe.setVisible(true);
              desktop.add(iframe);
              try {
                   iframe.setSelected(true);
                } catch (Exception e) {
                     e.printStackTrace();
              iframe.toFront();
         @Override
         public void actionPerformed(ActionEvent e) {
              if (e.getSource().equals(button1)) {
                   try {
                       Thread.sleep(2000);
                       showPopup();
                  } catch (InterruptedException ex){
                       ex.printStackTrace();
              } else if (e.getSource().equals(button2)) {
                   try {
                       Thread.sleep(2000);
                  } catch (InterruptedException ex){
                       ex.printStackTrace();
                   OpenerWorker worker = new OpenerWorker();
                   worker.execute();
         private class OpenerWorker extends SwingWorker<Object, Object> {
              @Override
              protected Object doInBackground() throws Exception {
                   return null;
              @Override
              protected void done() {
                   showPopup();
          * @param args
         public static void main(String[] args){
              SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                       try {
                            new FocusTest();
                       } catch (Exception e){
                             e.printStackTrace();
    }

    Set ur path env variable in your .bash_profile or .bashrc file
    export PATH=$ORACLE_HOME/bin:$PATH
    Then just issue the command in your prompt
    linux]dbca
    linux]netmgr
    NB: if your are in a remote machine you need to set DISPLAY variable too
    or you can directly to ur bin folder where you can see all the utilities.. you can run it like
    linux ]./dbca
    Regards
    Nishant

  • Yoga Tablet 2 Pro 1380F - Projector Focus Problem

    Hi, I have a problem with the focus in my 1380F. When I try to focus the projector image it only focus part of the screen. For example, when I'm watching a movie and I get the best focus on the centre of the screen the subtitles get blur, and vice-versa. Does anyone have this problem or another like this related to focus?I would appreciate some feedback because I want to know if this is a defect with my device only or if it's just the quality of the focus mechanism that is not so good. Best regards Rui Alves 

    I don't own the device so can't test, but this is what i find on the net about the projector: The tablet manages to keep images in focus from about eight feet, measuring in roughly a 70-inch screen. Lenovo recommends a maximum of 50-inches. 

  • Me51n - set focus

    hi everyone...
    i set an user exit in order to validate some fields, not in the header of the lines but in the imputation screen.
    the thing is that when one of the fields doesn t pass the validation i send a message but the problem is that it doesnt goes to the corresponding screen (Eyelash) where de field is wrong. I found how to do this. but i coulnd t do to set the focus on the corresponding field.
    ths for the help.

    Hi Jen,
    Check If that provision is there like to adjust the position of tab like badi. I think there is no provision for this exit.
    Regards,
    Madhu.
    Edited by: madhurao123 on Jul 11, 2011 8:58 AM

  • How to capture the event on changing focus from a JTextField?

    Hi All,
    I have got a problem...
    I want to do something (say some sort of validations/calculations) when I change the focus by pressing tab from a JTextField. But I am not able to do that.
    I tried with DocumentListener (jtf01.getDocument().addDocumentListener(this);). But in that case, it's calling the event everytime I ke-in something in the text field. But that's not what I want. I want to call that event only once, after the value is changed (user can paste a value, or even can key-in).
    Is there any way for this? Is there any method (like onChange() in javascript) that can do this.
    Please Help me...
    Regards,
    Ujjal

    Hi Michael,
    I am attaching my code. Actual code is very large containing 'n' number of components and ActionListeners. I am attaching only the relevant part.
    //more codes
    public class PaintSplitDisplay extends JApplet implements ActionListener
         JFrame jf01;
         JPanel jp01;
         JTextField jtf01, jtf02;
         //more codes
         public void start()
              //more codes
             jtf01 = new JTextField();
              jtf01.setPreferredSize(longField);
              jtf01.setFont(new Font("Courier new",0,12));
              jtf01.setInputVerifier(new InputVerifier(){public boolean verify(JComponent input)
                   //more codes
                   System.out.print("updating");
                   jtf02.setText("updated value");
                   System.out.print("updated");
                   return true;
              //more codes
              jtf02 = new JTextField();
              jtf02.setPreferredSize(mediumField);
              jtf02.setEditable(false);
              jp01.add(jtf02, gbc);
              //more codes
              jf01.add(jp01);
              jf01.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              jf01.setVisible(true);
              //more codes
         public static void main(String args[])
              PaintSplitDisplay psp = new PaintSplitDisplay();
              psp.start();
         public void actionPerformed(ActionEvent ae)
              //more codes
    }As you can see I want to update the second JTextField based on some calculations. That should happen when I change the focus from my frist JTextField. I have called jtf02.setText() method inside InputVerifier. But it's giving error...
    Please suggest...
    Ujjal

  • JComboBox.setPopupVisible() and focus

    Hello,
    the following code demonstrates that always when the combobox is editable and the standard focus sequence is modified, a setPopupVisible(true) indeed opens the popup, but it is immediately closed again. Is anything wrong with the code?
    Although there are quite a number of JComboBox bugs in the database, I did not find this one. If it is a bug, of course I would be interested in a workaround.
    Regards
    J�rg
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Y extends JFrame
      private JComboBox cmb;
      public Y()
      { setSize(300,300);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        Container cp= getContentPane();
        cp.setLayout(null);
        final JCheckBox cb= new JCheckBox("Combo editable");
        cb.setBounds(80,30,130,20);
        cb.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
         cmb.setEditable(cb.isSelected());
        final JTextField tf1= new JTextField();
        tf1.setBounds(50,60,60,20);
        tf1.addFocusListener(new FocusAdapter() {
          public void focusLost(FocusEvent evt) {
         if (!tf1.getText().equals("ee")) {
           cmb.requestFocusInWindow(); // Prevents popup to stay open.
           cmb.setPopupVisible(true);
           System.out.println(cmb.isVisible());
        JTextField tf2= new JTextField();
        tf2.setBounds(150,60,60,20);
        tf2.addFocusListener(new FocusAdapter() {
          public void focusLost(FocusEvent evt) {
         cmb.setPopupVisible(true);
        cmb = new JComboBox(new String[]{"Item 1", "Item 2", "Item 3", "Item 4"});
        cmb.setBounds(100,90,50,20);
        cmb.setSelectedIndex(-1);
        System.out.println("LightWeight: "+cmb.isLightWeightPopupEnabled());
        cp.add(cb);
        cp.add(tf1);
        cp.add(tf2);
        cp.add(cmb);
        setVisible(true);
        tf1.requestFocusInWindow();
      public static void main(String args[])
      { java.awt.EventQueue.invokeLater(new Runnable()
        { public void run()
          { new Y();
    }

    Well, there's two things I note. The first is you're printing out the comboBox's visible status, which is always true, when you're probably trying to get the comboBox's popup's visible status.
    The second thing is the cause of your problem. You request focus on the combo box. When it is editable, however, it is the editor component that gets the focus, not the combo box. So, the popup is made visible and then the editor component loses focus because the combo box gets focus, and so the popup is hidden.
    This change does what you want, I think:
        tf1.addFocusListener(new FocusAdapter() {
          public void focusLost(FocusEvent evt) {
        if (!tf1.getText().equals("ee")) {
            if ( cmb.isEditable() )
                cmb.getEditor().getEditorComponent().requestFocusInWindow();
            else
                cmb.requestFocusInWindow(); // Prevents popup to stay open.
          cmb.setPopupVisible(true);
          System.out.println(cmb.isVisible());
        });

Maybe you are looking for