JTextField gets focus NO more

Hello,
I have a big application running on JDK 1.4.0_03 which is running on RedHat 7.3 and sometimes it produces a very strange error.
At some point in time (sometimes), the application refuses to give focus to JTextFields. I simply cannot click into the field any more. However, buttons still work, only JTextField cannot be used.
Has anybody experienced anything similar?
I am interested in any updates on this issue.
Thank you in advance,
G

Rahim_From_Puniyal wrote:
Yannix
i post this thread at java programming forum. You reply me that "should be post at swing forum" then i post it again here you again reply my question like your previous answer.I said Next time Swing related question should be posted in the Swing forum.
In short next time you have a new problem about swing post it in here. Simple English.
Please don't reply if you don't have any useful answer to the question ok.
your are not alone here at SUN developer forum. May be some give me a useful answer of my question and who is not memeber of java programming forum. that's allI think your are just one of those guys who doesn't read a post carefully.
If you take a look at your other post I did give you an answer in reply # 1. Read Carefully.
So before you tell me what's my problem you should read the thread carefully.
and If you carefully read reply#1 I did state read your other thread for solution.

Similar Messages

  • JTextField and JTextArea don't get focus occuasionally

    I am developing a Java Swing Applet. At edit mode, JComboBox, JCheckBox, JRadioBox, and JButton work fine, but JTextField and JTextArea can't get focus occuasionally while I click them.
    Anyone has idea?
    Thanks

    Thank you Himanshu,
    but that's not exactly what my issue is. This link describes the undesired effect of ending up outisde of the player window and in the browser.
    My problem is kind of the opposite. When I launch the page in the html file I cannot use the tab key to get to any of the controls in the captivate window. I'm stuck in the browser unless I click on the captivate window. That is not acceptable if we want it accessible without using a mouse. I found a way to make it work for chrome like I stated above, but not in FF. Do you have any ideas for this?
    Thanks!
    Monique

  • Can't get focused a JTextField within a JTable cell

    I have a table and I placed a cell editor with a JText field on it for all cell editing,
    I want to do things when the focus is lost or gained and my app works fine when a cell is double clicked or f2 is pressed, but when a cell is selected (without double clicking) and just begin typing it produces no focus gained event.
    I tried by calling grabFocus method of that jTextField within the overriden prepareEditor method of the JTable but it doesn't get focus (doesn't even gains and loses it :s )
    Does anyone have an idea of how to force this component to grab focus?
    Thanks

    Hai,
    dont add the FocusListener to the EditorComponent.
    Try to use the JTable Functions - like this:
    import javax.swing.event.ChangeEvent;
    import javax.swing.table.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.EventObject;
    import javax.swing.*;
    public class Test extends JFrame
         JTable table;
         JTextArea text;
         JScrollPane scroll;
         JTextField cellTextField;
         Test()
              DefaultTableModel model = new DefaultTableModel();
              cellTextField = new JTextField();
              text = new JTextArea();
              text.setEditable(false);
              scroll = new JScrollPane();
              scroll.setViewportView(text);
              table = new JTable(model){
                   @Override
                   public Component prepareEditor(TableCellEditor editor, int row, int column) {
                        text.append("Better use this to Start Edit!\n");
                        return super.prepareEditor(editor, row, column);
                   @Override
                   public void editingStopped(ChangeEvent e) {
                        text.append("Better use this to Stop Edit!\n");
                        super.editingStopped(e);
              model.addColumn("Column 1");
              model.addColumn("Column 2");          
              model.addRow(new String [] {"Cell 1", "Cell 2"});
              table.setCellSelectionEnabled( true );
              table.getColumnModel().getColumn(0).setCellEditor( new DefaultCellEditor(cellTextField));
              table.getColumnModel().getColumn(1).setCellEditor( new DefaultCellEditor(cellTextField));
              getContentPane().setLayout(new BorderLayout());
              getContentPane().add(table, BorderLayout.NORTH);
              getContentPane().add(scroll, BorderLayout.CENTER);
              setSize(300, 300);
              setVisible(true);
              setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
         public static void main(String[] args)
              new Test();
    }

  • Getting focus on JTextField?

    I made a chat with a JApplet. In my chat i have a JTextField where users can write messages. I want to have focus on this JTextfield all the time, the user should not be allowed to get focus somewhere else. How can I do that? I tried requestFocus(); but its not making any differants. I use gridbaglayout and this is how I create my JTextfield:
    beskedFelt = new JTextField(10);
    c.insets = new Insets(10,0,0,0);
    c.gridx = 1;
    c.gridy = 2;
    gridbag.setConstraints(beskedFelt, c);
    contentPane.add(beskedFelt);
    beskedFelt.setEditable(true);
    beskedFelt.addActionListener(this);
    beskedFelt.requestFocus();
    thx for your time....

    yesss it worked:
    beskedFelt = new JTextField(10);
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    beskedFelt.requestFocus();
    c.insets = new Insets(10,0,0,0);
    c.gridx = 1;
    c.gridy = 2;
    gridbag.setConstraints(beskedFelt, c);
    contentPane.add(beskedFelt);
    beskedFelt.setEditable(true);
    beskedFelt.addFocusListener(this);
    beskedFelt.addActionListener(this);
    public void focusGained(java.awt.event.FocusEvent fe)
    public void focusLost(java.awt.event.FocusEvent fe)
              Object source = fe.getSource();
              if ( source == beskedFelt)
    beskedFelt.requestFocus();
    thx a lot ppl....

  • Accelerators, JTextField, and focus

    I created a JMenuItem for Save. I also created an accelerator for the Save menu item.
    JMenuItem saveItem;
    JMenu fileMenu = new JMenu ("File");
    fileMenu.add (saveItem = new JMenuItem ("Save"));
    saveItem.setMnemonic ('S');
    KeyStroke cntrlS = KeyStroke.getKeyStroke(KeyEvent.VK_S,
    Event.CTRL_MASK);
    saveItem.setAccelerator (cntrlS);
    saveItem.addActionListener (new ActionListener() {
    public void actionPerformed (ActionEvent e) {
    doSaveNote();
    When the user is finished entering data into the JTextField(s), the user then either presses ctrl-S or clicks on the Save button on the menu. My code (not shown) validates data in JTextFields when the Save accelerator or button is pressed (blank field is considered invalid as well as wrong flight number). If data is invalid, then the first field with invalid data gets focus.
    If the JTextField has focus and invalid data is there, then when the user clicks the Save button the JTextField still has focus with a message letting the user know the data is invalid. However, if the user puts invalid data in the JTextField and uses the accelerator ctrl-S without tabbing out of the field first, the invalid JTextField does not get focus and no error message is presented. When using the accelerator the invalid JTextField only gets focus and prints an error message if the user tabs out of the JTextField befor pressing ctrl-S.
    I don't want to tab out of the field. Why is the behavior different between the accelerator and clicking the Save button? Any help is appreciated.

    You can request focus for another component.
    Or you could do: myTextField.setFocusable(false). But in this case you would have to make it fosucable later on if you want to use it.

  • Vocals getting recorded at more rate so out of rythm

    Hi I need help my vocals get recorded at more speed than I actually sing at so getting out of rythm.
    Please help
    Its not a latency issue it is the other way round .

    You seam to be focusing your anger at Verizon and not your sister. Verizon followed the rules and required IDs and passwords to access the wireless account. You and/or your mother are supposed to safeguard that information.  Your sister has committed the felony by stealing your mothers identity for personal gain.
    You say "I am very dissatisfied with how VZW is handling an illegal and fraudulent change on my account that has shafted me out of 500 dollars.'  My question to you is who made the illegal and fraudulent change to your account?  Verizon or your sister? Keeping in mind your sister had all the correct IDs and passwords,
    I'm sure if you went to Verizon and wanted to make some changes to your account, and you had the correct IDs and passwords, you would be upset and angry if they put you through the 3rd degree because they thought you were committing fraud.
    Good luck to you, (seriously) whatever happens,

  • How to make a JScrollPane not getting Focus?

    How to make a JScrollPane not getting Focus?
    When i tab out from a textfield inside a scroll pane focus is going to ScrollPane .And if i press tab once more then only focus is going to other textField which is outside the scrollpane.
    For me when i press tab from a text field inside a scrollPane ,i should go to textfield out side the scroll pane.
    satish

    Hi,
    I've the same problem, that I have to double click on tab
    to step from a textfield with a scrollpane to the next textfield in my panel.
    I tried to implement a FocusListener on my JScrollPane, but without success.
    Can you tell me in detail how to implement this listener ?
    Kind regards
    Andy Kanzlers

  • Why my textfield can not get focus?

    I put a textfield on the first tab of a tabbed panel. I need this textfield to get the focus when I open the first tab. I tried to use grabfocus() method in the constructor of class, but it does not work. Does anybody know why? and how can I solve it?
    Thanks!

    No, I didn't call grab/requestFocus on the event thread.
    My code is like this:
    public class GeneralPane extends JPanel {
    JPanel ltPane;
    private JTextField txtCountry;
    public GeneralPane() {
    initComponents();
    private void initComponents(){
    setLayout(new BorderLayout());
    //Add another Panel to contain Labels and Text fileds
    ltPane = new JPanel();
    FocusListener mFL = new FL();
    txtCountry = new JTextField("US", 20);
    //this listener is used to store the data in the textfield into a variable
    txtCountry.addFocusListener(mFL);
    // add the textfield into ltPane
    mUtil.insertTextPane(txtCountry,ltPane);
    //txtCountry got focus
    //txtCountry.setFocusable(true);
    ltPane.requestFocus();
    //txtCountry.requestFocusInWindow();
    Then in the main program, I create an instance of this class and then use addTab(...) function into the my tabbedPanel.
    The logic is simple, but the textfield still couldn't get focus when I open the tabbedPanel.

  • Child JWindow containing JTextField takes focus from JFrame

    I have a bit of a unique problem.
    I have a JFrame as the main application window. I then create a JWindow with a JTextField that I would like to use as a Popup Palette. The problem is that when I click in the text box, the title bar of the JFrame changes it's appearance because the focus is now on the text box in the JWindow.
    If I use setFocusableWindowState(false) on the JWindow then the title bar of the JFrame does not change(which is the behaviour I want), but I cannot type in the JTextField.
    I understand why this is happening. The JTextField needs to have focus in order to recieve input and because it is in the JWindow, the JWindow takes the focus away from the JFrame.
    Does anyone know how I can make it so the JFrame Title Bar does not change appearance when the JTextField in the JWindow gets focus?
    The only thing that I can think of, is to somehow change the JFrame Look & Feel so that the title does not change appearance when the JFrame looses focus. I have no idea how to do that though.
    If you are wondering why I need this, it is because I need a JTextField to display on top of a Heavyweight component. I want it to appear as if it is part of the same window. Having the title bar of the JFrame change when you click in the textbox kind of destroys the illusion that it is part of the heavyweight component.
    Also, if you know of any other ways to get the JTextField to display and work on top of a Heavyweight component then I would appreciate that as well.
    Here is an example that you can run to see the behaviour. You can try it with the setFocusableWindowState line both uncommented and commented out.
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JWindow;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    public class TestFocus implements Runnable {
        private JFrame frame;
        private JWindow popup;
        public void run() {
            //Create a new Frame
             frame = new JFrame("Frame Test");
             JButton but = new JButton("Does Nothing");
            frame.getContentPane().add(but);
            frame.setPreferredSize(new Dimension( 500, 500 ));
            frame.pack();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
            //Create a JWindow with a JTextField
            popup = new JWindow( frame );
            JPanel p = new JPanel(new BorderLayout());
            JTextField txt = new JTextField();
            p.add( txt, BorderLayout.NORTH );
            JButton but2 = new JButton("Also does nothing");
            p.add(but2, BorderLayout.SOUTH);
            popup.getContentPane().add(p);
            popup.setLocation( frame.getLocation().x + 50, frame.getLocation().y + 50 );
            popup.pack();
            //Proper title behaviour if I have this statement
            //but then I can't type in the text box.
            //popup.setFocusableWindowState(false);
            popup.setVisible(true);
        public static void main(String[] args) {
            try {
                System.setProperty("sun.java2d.noddraw", "true");
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            catch (Exception e) {
            SwingUtilities.invokeLater(new TestFocus());
    }Thanks,
    Jeff

    The code works fine on XP using JDK1.4.2, maybe its a version/platform issue check the bug database.
    -> if you know of any other ways to get the JTextField to display and work on top of a Heavyweight component
    You could try using
    JPopupMenu.setDefaultLightWeightPopupEnabled(false)and then add the JTextField to a jPopupMenu instead of a JWindow (although behind the scenes I think it will use a JWindow as the popup, so it may not solve the problem either if it is a version/platform issue).

  • Applying the Shortcut key Tab to JTextField to focuse one by one

    how are we Focusing the JTextField one by one by using the Shortcut Key Tab,as per our specified ordering of JTextFields.
    In my application,i used the Shortcut key Tab for JTextField by focusing the JTextFields for each JTextField key event...but i could not get the result successfully.Do u have solution means u reply me plz.......

    as per our specified ordering of JTextFields.set your own FocusTraversalPolicy()
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#customFocusTraversal

  • Cant get Focus on textfield

    Hi
    I have a class extending JFrame say "MainFrame" which consist of JSplitPane say "splitPaneA"
    splitPaneA has top and bottom component.
    TopComponent is another JsplitPane say "splitPaneA-B"
    splitPaneA-B consist of a Jpanel say "B-rightPanel "as RightComponent and another JPanel as left.
    splitPaneA has bottomcoponent which is Jpanel class say "BottomPanel " extendingJPanel
    splitPaneA .setABottomComponent(new BottomPAnel());
    BottomPanel has JtoolBar say toolBar
    ToolBar has a JtextFiled say textField1 which needs to be focused as soon as bottomPanel loads.
    I tried using following in BottomPanel class
    this.setEnabled(true);
    this.setFocusable(true);
    this.setVisible(true);
    this.requestFocusInWindow();
    textField1.requestFocusInWindow()
    But textFiled never gets focused.I also tried requestFocus method.
    In class MainFrame
    FocusManager.getCurrentManager().getFocusOwner()); always returns null
    (FocusManager.getCurrentManager().getFocusedWindow()); returns null
    this.hasFocus()); returns false
    Any help is greatly appreciated.

    Thanks for your responses.
    This is my compilable,executable dummy code.I have taken out lines which are not relevant to focus issue as well as the import.Please llet me know what can be done to get the focus in textfield as soon as window loads.
    public class DummyObjectSearchPanel extends JPanel implements ActionListener
    JTextField textField1;
    JButton searchButton;
    ImageIcon searchIconIcon;
    JToolBar jToolBar1;
    private static Icon closeIcon = new ImageIcon(ObjectSearchMainPanel.class.getResource("/resources/images/close_small.gif"));
    private JButton closeButton;
    JFrame frame;
    private String newline = "\n";
    public DummyObjectSearchPanel()
    this.setLayout(new BorderLayout());
    this.setBorder(new ShadowBorder());
    textField1 = new JTextField();
    this.setEnabled(true);
    this.setFocusable(true);
    this.requestFocusInWindow();
    this.setVisible(true);
    textField1.requestFocus();
    System.out.println("has focus " + textField1.hasFocus());
    jToolBar1 = new JToolBar();
    frame = new JFrame();
    frame.setUndecorated(true);
    jbInit();
    void jbInit()
    searchButton = new JButton();
    searchButton.setText("SearchButton");
    closeButton = new JButton(closeIcon);
    ActionListener al = new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textField1.requestFocusInWindow();
    textField1.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    searchButton_actionPerformed(e);
    jToolBar1.setBorder(null);
    jToolBar1.addSeparator();
    jToolBar1.add(closeButton);
    closeButton.setOpaque(false);
    closeButton.setMargin(new Insets(4, 4, 4, 4));
    Dimension closeBtnDimension = new Dimension(20, 20);
    closeButton.setPreferredSize(closeBtnDimension);
    closeButton.setMinimumSize(closeBtnDimension);
    closeButton.setSize(closeBtnDimension);
    closeButton.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(java.awt.event.ActionEvent evt)
    //closeButton action taken out to make code short
    jToolBar1.addSeparator();
    jToolBar1.addSeparator();
    jToolBar1.add(textField1);
    jToolBar1.addSeparator();
    jToolBar1.add(searchButton);
    jToolBar1.addSeparator();
    jToolBar1.addSeparator();
    this.add(jToolBar1);
    searchButton.addActionListener(new java.awt.event.ActionListener()
    public void actionPerformed(ActionEvent e)
    searchButton_actionPerformed(e);
    textField1.requestFocusInWindow();
    void searchButton_actionPerformed(ActionEvent e)
    //searchbutton logic removed to simplify the code
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("New Search");
    Dimension d=new Dimension(600,100);
    frame.setSize(d);
    frame.setMinimumSize(d);
    frame.setPreferredSize(d);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    //Create and set up the content pane.
    JComponent newContentPane = new DummyObjectSearchPanel();
    newContentPane.setOpaque(true); //content panes must be opaque
    frame.getContentPane().add(new DummyObjectSearchPanel(),
    BorderLayout.CENTER);
    //Display the window.
    //frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    UIManager.put("swing.boldMetal", Boolean.FALSE);
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();
    public void actionPerformed(ActionEvent e)
    // TODO Auto-generated method stub
    Thanks you so much

  • JTextArea should get focus...

    Hi everybody,
    I want to accomplish a relatively easy task: when I click on a JButton the text area in my frame should get focus, i.e.: there should be a blinking cursor in the text area and the user should be able to start typing in it right away. However, the text area refuses to get the focus. This is my code:
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    public class TextAreaFocus implements ActionListener
       private static JTextArea text = new JTextArea();
       private static JButton btn = new JButton("Click me");
       public static void main(String[] args)
          // Init the JTextArea.
          text.setText("testje");
          text.setRows(10);
          text.setColumns(50);
          text.setFocusable(true);
          // Create the JPanel for the components.
          JPanel panel = new JPanel(new GridLayout(2, 1));
          panel.add(btn);
          panel.add(text);
          // Create a JFrame to show it all.
          JFrame frame = new JFrame("Testing JTextArea focus");
          frame.add(panel);
          frame.pack();
          frame.setVisible(true);
       public void actionPerformed(ActionEvent e)
          // When the button is clicked the cursor should be placed in the text area.
          // text.requestFocus();
          text.requestFocusInWindow();
    }I guess I am doing / forgetting something really trivial, however I just don't see it.
    Best regards,
    Jethro

    You are right, what i huge mistake! I made this program however, to demonstrate the problem. In my original program (much more complicated that the example off course) requestFocus() does not do the trick. Tomorrow I will try and see if I can give a more complete example which comes closer to the original program.

  • How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album :)?

    How can i Delete all foto from my iphone and after some time get them one more time on it but not as a new album, i want them in the camera roll ?

    How can I delete EVERY THING off my Mac and have it like new?
    Boot from the software install DVD and do an "erase and install" when prompted.

  • How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    How can I see if my program is for more than one user? We think we have bought in design for more users, but can not find out how to get in for more than one?

    If you bought a CC for team, you can log in at http://adobe.com and insert the e-mail that you gave at the moment at the purchase and than you can manage and see you product/plan/team.
    If I was not clear you can use the following link to help you solving your issue:
    Creative Cloud Help | Manage your Creative Cloud for teams membership
    If your not clear about this situation, contact with an agent of Adobe, by chat or phone. Use the following link to see the type of support you have on this matter:
    http://adobe.com/getsupport
    I think this will help you.
    Regards

  • Avoid window getting focus after pressing a mouse button on it

    I want that a window does not get focus although I press a mouse button on it, in Windows XP.
    I have search in Microsoft help and this fact is controlled by the Operating System itself. The notification that is sent after the user presses a mouse button is WM_MOUSEACTIVATE notification. The return value of this notification indicates the behaviour of the window after the mouse down, existing 4 options: MA_ACTIVATE, MA_ACTIVATEANDEAT; MA_NOACTIVATE & MA_NOACTIVATEANDEAT. The default is the first one, but I want to change the behaviour of the window to be the the third one: MA_NOACTIVATE, that does not activate the window, and does not discard the mouse message. The function that performs this is DefWindowProc according to the MSDN Help content.
    Any help about doing this in Labview? Is there any special function in Labview that allows setting this behaviour to a window or should I use a Windows dll? In that case how can be programmed? Has anyone done it before? I'm working with Labview 8.6.1, and I haven't found anything about this. Any help will be very useful.
    Thank you very much in advance.
    David Fernández

    It is the front panel window of a VI which I don't want to get focus. I have tried to achive this with property nodes, but the problem I think that cannot be solved in this way, because is the Operative System that gives the focus to the window when pressing a mouse button before Labview does anything. You can release the focus once the window have taken it with the Front Panel window focus property node, but what I really want is to keep the focus on the old window.
    My idea is that the VI act as a background of my application, so never can be over the rest of the windows. Some of them are floating but others are standard and I don't want to use modal windows, so I cannot solve this with the Window Appearance options.
    I have also tried to discard the mouse down in the Mouse Down? event, but I doesn't work, the window continues getting the focus although does not carry on any action.
    Any suggestion?
    Thank you for your interest
    David F

Maybe you are looking for