Textfield-focus within a tabbedpane

Hi all,
I have the following focus-problem.
I have a tabbed-pane with 4-register-cards. First I'm intit the first at last the fourth.
Now I want that a text-field on the first register-card have the focus. I try it to do it this way:
public void stateChanged(ChangeEvent event) {
     if (tabbedPane.getSelectedIndex()==3) {
          if (textFieldUser!=null){
               textFieldUser.setText(" This text-output works well ! ");
               textFieldUser.requestFocus();
Now the textfield display the output-text, but the field themselves have no focus?
If I click on the tab No 2 and go back to No. 1 the field have the focus in the way that I want !?

Archana1604 wrote:
You need not use requestFocusInWindow to set the focus for a component. You can simple use requestFocus() inorder to set the focus.Please read the API and don't post bad advice.
JComponent#requestFocus
Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow(). If you would like more information on focus, see [How to Use the Focus Subsystem|http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html], a section in The Java Tutorial.
db

Similar Messages

  • How to set focus on a textfield within a tabbedpane?

    Hallo i have the following problem,
    jTextFieldMyTextField.setText("BlaBla"); -> put the string in the TextField
    jTextFieldMyTextField.requestFocusInWindow(); -> don't set the focus to the TextField
    how i must set the focus?
    Any help is appreciated

    Archana1604 wrote:
    You need not use requestFocusInWindow to set the focus for a component. You can simple use requestFocus() inorder to set the focus.Please read the API and don't post bad advice.
    JComponent#requestFocus
    Note that the use of this method is discouraged because its behavior is platform dependent. Instead we recommend the use of requestFocusInWindow(). If you would like more information on focus, see [How to Use the Focus Subsystem|http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html], a section in The Java Tutorial.
    db

  • Setting textfield focus in ActionScript 3.0

    I am using an event handler to listen for MOUSE_UP on stage_mc to let the user create text and images on the screen. I have buttons above the stage that set a variable, then the variable determines which action occurs with the mouse event.
    I would like the user to be able to enter text, and can create an input text field on the stage, but the user then has to click inside the text field to begin typing. Because of the event handler, this 2nd MOUSE_UP repositions the text field, although it IS successful in setting the focus.
    Ideally, I would like for the user to be able to create the input text field by clicking on the stage and then begin typing without having to click a 2nd time. It seems simple enough, but I still don't understand OOP enough to decipher the help pages available within the program.
    Does anyone have any suggestions? Here is my code (some of the included variable are set in previous lines):
    //Setting up the Text Field parameters
        var outputText:TextField = new TextField();
        var textFormat:TextFormat = new TextFormat();
    // Enabling the input tools
    function startDraw(event:MouseEvent):void {
        if (currentTool.name == "lineTool_mc") {
                newLine.graphics.moveTo(event.localX, event.localY);
                stage_mc.addEventListener(MouseEvent.MOUSE_MOVE, drawLine);  
        } else if (currentTool.name == "textTool_mc") {          
            textFormat.color = 0x336699;
            textFormat.size = 48;
            textFormat.font = "Times";
            outputText.defaultTextFormat = textFormat;
            outputText.selectable = true;
            outputText.x = event.localX;
            outputText.y = event.localY;
            outputText.background = false;
            outputText.border = true;
            outputText.autoSize = TextFieldAutoSize.LEFT;
            outputText.type = TextFieldType.INPUT;
            designContainer.addChild(outputText);
        } else if (currentTool.name == "brushTool_mc") { ...

    on mouseup or click, if the mouse is down, you can use:
    stage.focus=outputText;
    if the mouse isn't down, you can don't need a listener to trigger the above.

  • Input textfield focus problem

    Hello
    I'm developing a series of learning aids and the final screen requires the user to input some text.
    I have it working correctly but now need to make it a little more user friendly.
    At the moment the only way for the user to input the text is to click in each box. There are a total of 6 input text boxes.
    I would like to direct the user to a particular input text and then have them be able to use the tab key or the enter key or mouse clicks to proceed.
    As the first step I added the stage.focus = inputStarName1. See code below. As soon as I added the stage.focus = inputStarName1 line I get the dredded error 1009 when the code invokes TypeNames.
    What do I need to do to get rid of this error?
    Any help will be greatly appreciated.
    package
        import flash.display.*;
        import flash.text.*;
        import flash.events.*;
        public class TypeNames extends MovieClip
            public function TypeNames()
                addEventListener(Event.ADDED_TO_STAGE, addedHandler);
                addEventListener(Event.REMOVED_FROM_STAGE, removedHandler);
                backBtn.buttonMode = true;
                resetBtn.buttonMode = true;
                scoreBtn.buttonMode = true;
                backBtn.addEventListener(MouseEvent.CLICK, back);
                resetBtn.addEventListener(MouseEvent.CLICK, reset);
                scoreBtn.addEventListener(MouseEvent.CLICK, mark);
                scoreBtn.alpha = 1;
                feedback.alpha = 0;
                correct1.alpha = 0;
                correct2.alpha = 0;
                correct3.alpha = 0;
                correct4.alpha = 0;
                correct5.alpha = 0;
                correct6.alpha = 0;
                var score:uint = 0;// sets score variable to zero
                // Defines Input text format
                var inputFormat:TextFormat = new TextFormat();
                inputFormat.font = "Arial Bold";
                inputFormat.size = 14;
                inputFormat.align = "center";
                inputFormat.color = 0xffff00;
                //Defines and adds text input boxes for star names
                var inputStarName1:TextField = new TextField();
                inputStarName1.type = "input";
                inputStarName1.defaultTextFormat = inputFormat;
                inputStarName1.x = 12;
                inputStarName1.y = -38;
                inputStarName1.height = 18;
                inputStarName1.width = 70;
                inputStarName1.background = true;
                inputStarName1.border = true;
                inputStarName1.backgroundColor = 0x555555;
                inputStarName1.borderColor = 0xffff00;
                addChild(inputStarName1);
                stage.focus = inputStarName1;

    Hi Kglad
    Thanks for the prompt response. I tried your suggestion but got error 1120.
    The addedHandler function is presently only used to center the screens created by the class packages.
    I tried moving the addedHandler function before the constructor but it made no difference.
    Just in case there is something else in my code that's messing things up I have copied it in its entirety below.
    As you will see I still need to learn how to use arrays and for loops to shorten up my code but I needed to get this operational in a hurry hence the brute force approach.
    Thanks again for your help
    package
        import flash.display.*;
        import flash.text.*;
        import flash.events.*;
        public class TypeNames extends MovieClip
            public function TypeNames()
                addEventListener(Event.ADDED_TO_STAGE, addedHandler);
                addEventListener(Event.REMOVED_FROM_STAGE, removedHandler);
                backBtn.buttonMode = true;
                resetBtn.buttonMode = true;
                scoreBtn.buttonMode = true;
                backBtn.addEventListener(MouseEvent.CLICK, back);
                resetBtn.addEventListener(MouseEvent.CLICK, reset);
                scoreBtn.addEventListener(MouseEvent.CLICK, mark);
                scoreBtn.alpha = 1;
                feedback.alpha = 0;
                correct1.alpha = 0;
                correct2.alpha = 0;
                correct3.alpha = 0;
                correct4.alpha = 0;
                correct5.alpha = 0;
                correct6.alpha = 0;
                var score:uint = 0;// sets score variable to zero
                // Defines Input text format
                var inputFormat:TextFormat = new TextFormat();
                inputFormat.font = "Arial Bold";
                inputFormat.size = 14;
                inputFormat.align = "center";
                inputFormat.color = 0xffff00;
                //Defines and adds text input boxes for star names
                var inputStarName1:TextField = new TextField();
                inputStarName1.type = "input";
                inputStarName1.defaultTextFormat = inputFormat;
                inputStarName1.x = 12;
                inputStarName1.y = -38;
                inputStarName1.height = 18;
                inputStarName1.width = 70;
                inputStarName1.background = true;
                inputStarName1.border = true;
                inputStarName1.backgroundColor = 0x555555;
                inputStarName1.borderColor = 0xffff00;
                addChild(inputStarName1);
                var inputStarName2:TextField = new TextField();
                inputStarName2.type = "input";
                inputStarName2.defaultTextFormat = inputFormat;
                inputStarName2.x = -270;
                inputStarName2.y = -98;
                inputStarName2.height = 18;
                inputStarName2.width = 80;
                inputStarName2.background = true;
                inputStarName2.border = true;
                inputStarName2.backgroundColor = 0x555555;
                inputStarName2.borderColor = 0xffff00;
                addChild(inputStarName2);
                var inputStarName3:TextField = new TextField();
                inputStarName3.type = "input";
                inputStarName3.defaultTextFormat = inputFormat;
                inputStarName3.x = 75.3;
                inputStarName3.y = 38.3;
                inputStarName3.height = 18;
                inputStarName3.width = 70;
                inputStarName3.background = true;
                inputStarName3.border = true;
                inputStarName3.backgroundColor = 0x555555;
                inputStarName3.borderColor = 0xffff00;
                addChild(inputStarName3);
                var inputStarName4:TextField = new TextField();
                inputStarName4.type = "input";
                inputStarName4.defaultTextFormat = inputFormat;
                inputStarName4.x = 227.45;
                inputStarName4.y = 99.26;
                inputStarName4.height = 18;
                inputStarName4.width = 70;
                inputStarName4.background = true;
                inputStarName4.border = true;
                inputStarName4.backgroundColor = 0x555555;
                inputStarName4.borderColor = 0xffff00;
                addChild(inputStarName4);
                var inputStarName5:TextField = new TextField();
                inputStarName5.type = "input";
                inputStarName5.defaultTextFormat = inputFormat;
                inputStarName5.x = 94.45;
                inputStarName5.y = -72;
                inputStarName5.height = 18;
                inputStarName5.width = 70;
                inputStarName5.background = true;
                inputStarName5.border = true;
                inputStarName5.backgroundColor = 0x555555;
                inputStarName5.borderColor = 0xffff00;
                addChild(inputStarName5);
                var inputStarName6:TextField = new TextField();
                inputStarName6.type = "input";
                inputStarName6.defaultTextFormat = inputFormat;
                inputStarName6.x = 211;
                inputStarName6.y = 29.5;
                inputStarName6.height = 18;
                inputStarName6.width = 70;
                inputStarName6.background = true;
                inputStarName6.border = true;
                inputStarName6.backgroundColor = 0x555555;
                inputStarName6.borderColor = 0xffff00;
                addChild(inputStarName6);
                function mark(event:MouseEvent):void
                    if (inputStarName1.text.toUpperCase() == "POLARIS"
                        && inputStarName2.text.toUpperCase() == "SCHEDAR"
                        && inputStarName3.text.toUpperCase() == "KOCHAB"
                        && inputStarName4.text.toUpperCase() == "ALKAID"
                        && inputStarName5.text.toUpperCase() == "DUBHE"
                        && inputStarName6.text.toUpperCase() == "ALIOTH")
                        MovieClip(parent).gotoReward();
                    else
                        feedback.alpha = 1;
                    if (inputStarName1.text.toUpperCase() !== "POLARIS")
                        correct1.alpha = 1;
                        correct1.text = "Polaris";
                    if (inputStarName2.text.toUpperCase() !== "SCHEDAR")
                        correct2.alpha = 1;
                        correct2.text = "Schedar";
                    if (inputStarName3.text.toUpperCase() !== "KOCHAB")
                        correct3.alpha = 1;
                        correct3.text = "Kochab";
                    if (inputStarName4.text.toUpperCase() !== "ALKAID" )
                        correct4.alpha = 1;
                        correct4.text = "Alkaid";
                    if (inputStarName5.text.toUpperCase() !== "DUBHE" )
                        correct5.alpha = 1;
                        correct5.text = "Dubhe";
                    if (inputStarName6.text.toUpperCase() !== "ALIOTH")
                        correct6.alpha = 1;
                        correct6.text = "Alioth";
            private function reset(event:MouseEvent):void
                MovieClip(parent).gotoType();
            private function addedHandler(event:Event):void
                this.x = stage.stageWidth / 2;
                this.y = stage.stageHeight / 2;
            private function removedHandler(event:Event):void
            private function back(event:MouseEvent):void
                MovieClip(parent).gotoLearn();

  • TextField Focus

    Hello there,
    I am new to AS3 and trying to figure out how to set a focus to a textfield on the stage. I found out that if I use
    stage.focus = tf; then the tf get the focus and it does, when I type letters they go directly to this textfield.
    Problems are,
    I don't have a blinking cursor in the textfield.
    I added event listener to catch up when the user press the  ENTER  key but it catches the ENTER key ONLY after I click the textfield with the mouse and having a blinking cursor in that textfield.
    Any idea ?
    regards,

    Are you seeing this behavior in the testing environment or when you put the flash into an html page?
    In the testing environment you might want to go to the Control menu and select Disable keyboard shortcuts. That will give you a better representation of how things will actually work when they are standing on their own.
    Also there is some kind of issue around setting the focus. The swf object has to have already received a click before it can set the blinking I-beam into an input text field. It is a "security" type of thing. To prevent a malicious swf from looking like some kind of interactive password field and grabbing someone's password or the like.
    Depending upon what you are doing you can have a "Start" button or something to make sure that the user has clicked the flash before flash can be able to set the focus.

  • How to change focus within JTextPane

    Hi
    I have a JTextPane within a JScrollBar. I have a requirement to change the focus to particular line in the JTextPane on the click of a button. i.e. The JTextPane has to scroll down to that location on clicking the button. Do we have any built in APIs for this functionality ? Or how can we accomplish this ?

    play with modelToview and viewToModel methods to go where you want to go.
    Then you can set the caret position and request focus.

  • How to make scrollpane scroll with textfield focus

    I have a JScrollPane that contains a JPanel with a grid of Labels and JTextFields for data entry. When I tab through the textfields down the panel - reaching fields that are out of view, the scroll pane does scroll down fields with the cursor - keeping the cursor in view.
    Is there a way to do this? I've tried some things, but I have not been able to get this working.

    here you go..
    package com.u2d.focustest;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.FocusEvent;
    import java.awt.event.FocusAdapter;
    public class KeepCursorInView extends JFrame
       public KeepCursorInView()
          JPanel contentPane = (JPanel) getContentPane();
          JPanel fieldPanel = new JPanel(new GridLayout(12, 3));
          JScrollPane scrollPane = new JScrollPane(fieldPanel);
          contentPane.add(scrollPane, BorderLayout.CENTER);
          for (int i=0; i<36; i++)
             addField(fieldPanel);
       private void addField(final JPanel panel)
          final JTextField tf = new JTextField();
          panel.add(tf);
          tf.addFocusListener(new FocusAdapter()
             public void focusGained(FocusEvent e)
                Rectangle bounds = tf.getBounds();
                panel.scrollRectToVisible(bounds);
       public static void main(String[] args)
          JFrame f = new KeepCursorInView();
          f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          f.setBounds(100,100,400,400);
          f.setVisible(true);
    }

  • Popup status doesn't disappear when moving focus within framesets

    I developed and manage a website that makes extensive use of frames. When I click on a link in one frame that opens a page in an adjacent frame moves focus there. The problem is that the the popup status that appeared in the origin frame displaying the link to the just-opened window doesn't then disappear, but remains visible even though that frame is no longer active. This would appear to be a bug. Can it either be fixed or a work-around suggested? Please don't comment on frames being obsolete. Thanks

    Adding on to original query. In fact this behavior only occurs when transferring to a frame containing a data entry form. Then, if I move the cursor over any other hyperlink, say in the side favorites menu, the popup disappears. Quite annoying, particularly since I previously used the status bar to inform users of valid / invalid input quantities on these forms.

  • Flex application -- Focus

    I'm designing a Flex application, and for the most part, I
    want to allow users to drive the application with simple
    keystrokes.
    Obviously I need to content with a couple of UI issues:
    1) I don't want to interfere with text field input and the
    likes.
    2) After the user commits (i.e. closes or exits text fields
    or other objects that claim focus of text input) I'll need to set
    focus (responder?) to the flex application itself .
    Is this easy to accomplish?
    Thanks John

    You can set focus within the flash player to components
    within the flash player.
    You can set focus within the browser window to the Flash
    player (if you need to).
    Easy? That depends on how you want your app to behave and how
    you implement that behaviour. A "suck it and see" approach might be
    best to ascertain that one - learn by doing and similar
    clichés have merit here.
    If you have a more specific question about implementation
    detail, post back and the board should fix you up with an
    answer.

  • Create an Applescript to change focus order in browser

    Hey all,
    I'm curious if it is possible to create an Applescript to change the order focus within a browser.
    I have a bulk of data that needs to be entered into a database online.
    The focus order of the website design is not logical hence pressing tab to move from one field to the next results in confusion.
    (It includes buttons in headers, footers and empty fields making this extremely frustrating as I have to continuously use the mouse)
    Google search has not really given me any results, so I was hoping to build one.
    Thanks,
    Cheebs

    I think it is unlikely that you will get far with AppleScript as this normally involves reverse engineering the web page HTML/JavaScript and perhaps having a modified local copy of some or all of it.
    Are you able to paste the URL here without security implications?
    You could try looking at the source HTML of the web page.
    I am not sure if anybody makes a special web page viewer which has more control than a standard browser.

  • Get focused component

    Hi
    Is there a method to get the component that has focus?
    Besides using a for loop with method hasfocu()
    Thanks

    Assuming you want to find what component has focus within a specified frame:JFrame myFrame = xxx;
    Component focusComp = SwingUtilities.findFocusOwner( myFrame );

  • IOS multiline textfield - enter key

    I'm having a weird bug on iOS
    I create 2 dynamic text fields, 1 multiline, 1 singleline. I run this on my ipad, I give the textfields focus by clicking on them to pull up the softkeyboard.
    The multiline textfield will have an enter button that say "Return"
    The singleline textfield will have an enter button that says "Done"
    add a listener for keyup
    stage.addEventListener(KeyboardEvent.KEY_UP, this._onKeyUp);
    private function _onKeyUp($event:KeyboardEvent):void{
                switch($event.keyCode){
                    case Keyboard.ENTER:
                    trace("HELLO?");
              break;
    The trace will only work when you press "Done", it never fires for "Return"

    Hi,
    Yes it's always allowed, however the problem comes when you then try to output it using an outputText, it won't show the line feed as \n is ignored in HTML. You have to use Trinidad's outputDocument component for that.
    Regards,
    ~ Simon

  • How do I focus a ListCell without selecting it?

    Hi to all JavaFX 2 experts,
    I have a ListView with cells created with the factory from CheckBoxListCell.forListView(...). I'm wondering if it is somehow possible to focus a ListCell without selecting it. At least caspian.css defines this special state and i'm currently creating a custom styling and I need to test the ".list-view:focused .list-cell:focused" (and not selected!) state.
    Thank you for your support!
    WhiteAntelope

    listview.getFocusModel().focus(row) will show you the focus CSS styling for the given row. Alternatively, use ctrl+up arrow / ctrl+down arrow to move focus within the ListView after you have clicked a row inside it.
    -- Jonathan

  • How to get the current selected column and row

    Hi,
    A difficult one, how do i know which column (and row would also be nice) of a JTable is selected?
    e.g.
    I have a JButton which is called "Edit" when i select a cell in the JTable and click the button "Edit" a new window must be visible as a form where the user can edit the a part of a row.
    Then the column which was selected in the JTable must be given (so i need to know current column) and then i want the TextField (the one needed to be edited) be active with requestFocus(). So it would be
    pricetextfield.requestFocus();
    Problem now is that i have to click every time in the window the JTextField which was selected in the JTable. I have chosen for this way of editing because my application is multi-user and it would be too difficult for me when everybody did editing directly (catch signals, reload data, etc.).
    My question is how do I know the current column and the current row in a JTable?

    I'm not sure what your mean by the "current" row or column, but the following utility methods return
    which row and column have focus within the JTable.
    public static int getFocusRow(JTable table) {
        return table.getSelectionModel().getLeadSelectionIndex();
    public static int getFocusColumn(JTable table) {
        return table.getColumnModel().getSelectionModel().getLeadSelectionIndex();
    }

  • Welcome to the new Oracle User Group Community

    Welcome to the new Oracle User Group Community. Whether you landed here via the redirect from the previous community site - IOUC.org - or navigated here directly, welcome. This new platform brings new community features to enhance the way you connect with user group peers and with Oracle, as well as make it easier for you to find information through a more intuitive interface. We invite you to provide your feedback on the new site. Log in using your OTN Forum credentials and join the discussion here. If you do not yet have OTN Forum log in credentials, navigate to http://community.oracle.com/community, click on the "Register" link in the upper right corner of the page and create your account.
    We look forward to hearing from you.

    Hi Kashif,
    Glad you like the new Community. Communication among user group leaders works a little differently on this site than on the previous site. Rather than having communication focus around e-mail distribution lists, communication now is focused within the site itself. The intent is that this will provide users the one place to come for information, rather than having to sort through lots of e-mail threads. That doesn't mean that e-mail is completely out of the picture though. Users can opt-in to receive e-mail notifications when an individual piece of content is changed, or when content is posted to a space. Look for the "Receive email notifications" link under "Actions" to start receiving notices. To stop receiving notices, go back to the same content/space and click "Stop email notifications".
    Your Relationship Manager will be talking with you and the other leaders in your region over the next few days and weeks regarding how you and your group of leaders want to communicate.
    Best regards,
    Oracle User Group Team

Maybe you are looking for

  • Error while running the tcode....EASISI

    hello Experts, I am trying to execute the tcode EASISI with a varient..... All the proper values are given to....... Simulation From,Simulate To,Document Date,Posting Date,Installation,Invoicing simulation,Simulate invoic. for ind. doc., and Billing

  • Nano skips downloaded songs

    My nano skips all the songs I downloaded in the iTunes Music Store.iTunes plays the songs in my libary but my iPod Nano doesn't play them and skips to the following song! It's very weird, and I'm about to get desprate! So if someone could help me?  

  • SELECT DISTINCT in MySQL gives error...

    Anyone help with this one - I'm sure it's easy. I have a working bean for a jsp where the statement sent to the QUERY is >> private String "SELECT * FROM mytablename ORDER BY afieldname <<. It works fine and there's no overt problems. But I dont want

  • Loading Matlab variables into Java

    I have written a program in Matlab which creates a matrix. I now need to use this matrix in my Java code but i dont know how to do this. One suggestion I was given was to save the Matlab matrix as a binary file (easy) and then load the file in Java.

  • When accessing the form on the races instead of a form guide I get a java script void error. How do I fix this please ?

    When in the TAB Racing site at a particular race I click on Form to access the form guide for that race. Instead of the form guide I get an error message " Java Script Void " This has only started recently and not as a result of anything I have done