How to force a jtable to loose focus

hi all
i've got a jTextArea and a Jtable, and i want my jTable to loose focus when my JTextArea gains it
i've the metod jTextAreaFocusGained(); what shall i write inside it to make the table loose focus?
thanx
sandro

Hi,
I guess, there is a missunderstanding in that, what you want to do and that, what you say, you want.
The focus is a unique thing - only one component can have the focus at one time - so, when your textfield has gained focus, the component that formerly has had the focus, lost it already - so, there is nothing else to do.
I guess, you want another thing, perhaps to clear the selection of the JTable or something like this.
greetings Marsian

Similar Messages

  • How to force update jtable display

    I am trying to add some filtering funtionality to my swing application that uses a JTable. What I do is to filter the JTable's datamodel, and call repaint() on the jtable and JPanel, and do jframe.pack(); Sometimes it works, sometimes it doesn't. I check the jtable model, and it is being updated properly. I guess it is a GUI update problem. Is there a better way to force the whole app's GUI to be updated?
    //update tableModel
    //repaint() jtable;
    //repaint() jpanel;
    jf.pack();

    A couple questions
    1. Did you write your own table model? Not calling fireTableDataChanged() can cause problems in this case.
    2. Do you update the table from a thread? You might need to put the updates on the event thread (SwingUtilities.invokeNoow() or invokeLater()) or manually call fireTableDataChanged() (I'm not sure if this needs to happen on the event thread)

  • How a custom control is advised it gains or looses focus?

    Hey, at least I have a question to ask, instead of answering them... :-)
    Actually, I already asked it in another thread, in one of my answers: [onMouseClicked Event Is Failing To Fire|http://forums.sun.com/thread.jspa?threadID=5391008] but I fear it is lost in a rather lengthly message, so I ask it in its own thread, because I was to bring the attention of knowledgeable people (hello Sun people! :-D).
    The question is simple: In a custom control in JavaFX 1.2, with skin and behavior, how a control is advised when it gains or looses focus?
    The purpose is to let the skin to change the look of the component upon these events, like it is done for standard controls (eg. putting a border around the focused control).
    If the control is clicked, you know (unless it is disabled) that it will have the focus. But I see no way to see the lost of focus, nor when we gain (or loose) it with Tab/Shift+Tab (if it has focusTraversable to true).
    I looked for onFocus() and onBlur() events (or similar), but found nothing. No mixin, nothing related in javafx.scene.input.TextInput and friends, etc.
    I explored the Web but since 1.2 is still new, I found not much information. Only a fragment of source code in [Re: Further location optimizations|http://markmail.org/message/gsevtlkeq45rrdun] where I see scene.getFocusOwner() but this one isn't easily usable because it is package protected (and it is not an event, anyway).
    A possible solution would be to have a timer to inspect the state focused of the nodes, but it is so kludgy I didn't even tried to implement it!
    I hope I just missed the information... If there is no easy/official/working way in 1.2, I hope this will be corrected for next version!

    That's a very good remark, handling of focus highlight shouldn't be done at control (model)'s level. I hesitated to put it in behavior, but it feels more natural in the skin, so I did as you suggested.
    you'll need an interface, and JavaFX does not do thatYou have mixins. But I didn't used them here.
    focused variable never is set to trueHave you included the
    public override var focusTraversable = true;
    line?
    To support multiple skins, my control becomes:
    public class StyledControl extends Control
      // Data related to the control (the model)
      public var count: Integer;
      public override var focusTraversable = true;
      init
        if (skin == null)  // Not defined in instance
          // Define a default styler
          skin = ControlStyler {}
      package function Incr(): Void
        if (count < 9)
          count++;
    }quite bare bones (I intendedly keep the model simple).
    Note I still define a default skin in case user doesn't provide it: they shouldn't care about this detail unless they want to change it.
    I defined an abstract default skin, implementing most variables (particularly the public ones that can be styled) and the focus change:
    public abstract class DefaultControlStyler extends Skin
      //-- Skinable properties
      public var size: Number = 20;
      public var fill: Color = Color.GRAY;
      public var textFill: Color = Color.BLACK;
      public var focusFill: Color = Color.BLUE;
      package var mainPart: Node; // Decorations (id, focus) are kept out of layout
      package var focusHighlight: Node;
      package var idDisplay: Text;
      package var valueDisplay: Text;
      init
        behavior = ControlBehavior { info: bind control.id }
        node = Group
          //-- Behavior: call controller for actions
          onMouseReleased: function (evt: MouseEvent): Void
            (behavior as ControlBehavior).HandleClick(evt);
      postinit
        // Once defined by the sub-class, insert into the node
        insert [ mainPart, idDisplay, valueDisplay ] into (node as Group).content;
      public abstract function ShowIncrement(): Void;
      var hasFocus = bind control.focused on replace
        if (hasFocus)
          ShowFocus();
        else
          HideFocus();
      // Default handling of  focus display, can be overriden if needed
      public function ShowFocus(): Void
        insert focusHighlight into (node as Group).content;
      public function HideFocus(): Void
        delete focusHighlight from (node as Group).content;
      public override function contains(localX: Number, localY: Number): Boolean
        return mainPart.contains(localX, localY);
      public override function intersects(localX: Number, localY: Number,
          localWidth: Number, localHeight: Number): Boolean
        return mainPart.intersects(localX, localY, localWidth, localHeight);
    }and the concrete skins implement the mainPart, idDisplay, valueDisplay, focusHighlight nodes, override ShowIncrement with an animation, override getPrefWidth and getPrefHeight to set to mainPart size and might override ShowFocus or HideFocus (if we want it behind mainPart for example).
    The behavior is:
    public class ControlBehavior extends Behavior
      public var info: String; // Only for debug information...
      // Convenience vars, to avoid casting each time
      var control = bind skin.control as StyledControl;
      var csSkin = bind skin as DefaultControlStyler;
      public override function callActionForEvent(evt: KeyEvent)
        println("{info}{control.count}: KeyEvent: {evt}");
        if (evt.char == '+')
          Incr();
      package function HandleClick(evt: MouseEvent): Void
        control.requestFocus();
        Incr();
      function Incr(): Void
        control.Incr();
        println("{info}: Ouch! -> {control.count}");
        csSkin.ShowIncrement();
    }and knows only the abstract default skin (to apply feedback of user input to skin).
    I use it as follow:
    Stage
      title: "Test Styling Controls"
      scene: Scene
        width:  500
        height: 500
        content:
          HBox
            translateX: 50
            translateY: 100
            spacing: 50
            content:
              StyledControl { id: "Bar" },
              StyledControl { /* No id */ layoutInfo: LayoutInfo { vpos: VPos.BOTTOM } },
              StyledControl { id: "Foo" },
              StyledControl { id: "Gah" },
              StyledControl { id: "Bu", skin: AltCtrlStyler {} },
        stylesheets: "{__DIR__}../controlStyle.css"
    }BTW, I tried layoutY: 50 in place of the layoutInfo definition, but the control remained at default place. Am I reading incorrectly the ref. or is this a bug?

  • Loosing focus when quiting

    Hello,
    Can someone help me with the following problem? How can I force a JTextField to loose it's focus when I am quiting the program by clicking the x-icon?
    thanks
    Stef

    Hello.
    Add a mouse listener to your x-icon and in the mouse released method add this block
    component.requestFocus();
    which component can be any swing component like Jframe.

  • CS4 Exporting media Loosing Focus

    Hi
    When exporting media to the media encoder I am finding that I am loosing focus of the rendered file in flash.
    the original size of footage is 1920 X 1080 I have croped this to an area of the footage that I require 720 x 640 and changed the out put size to the same.
    when this is rendered out the image is blury.
    how can I change the settings to be in focus as the original footage is in focus.
    Thanks
    Rodney

    Hi Hunt
    the flash settings that I am using are
    using flash 8 and higher
    I am encoding using the alpha channel due to the footage is keyed out
    the frame rate is 1200
    I have resized to 640 x 720 from 1920 x 1080 and also croped the footage as well to the same size
    Thanks
    Rodney

  • Jscrollpane jtable custom renderer focus

    I have a jtable with a customrenderer [it extends JPanel].
    The renderer contains a JScrollPane because the contents of the cell might exceed the cell.
    The problem is that I cannot scroll.
    It seems that I don't have focus on the JscrollPane.
    I have tested with many other components, and they also don't have focus.
    ex: I have a jlabel with mouselistener.On mouseEntered I have a dialog to appear but nothing happens.
    Anyone knows how to make the cell have the focus when the mouse is over it, or any other thing that might help ?
    Thanks in advance

    You can use the both:
    JTable method:
    +Sets a default cell renderer to be used if no renderer has been set in a TableColumn.+
    public void setDefaultRenderer(Class<?> columnClass, TableCellRenderer renderer)TableColumn method:
    +Sets the TableCellRenderer used by JTable to draw individual values for this column.+
    public void setCellRenderer(TableCellRenderer cellRenderer)

  • Closing when loosing focus

    Hi, how should I do to close a JFrame when it looses focus? In my app, there are times when i have more then 2 JFrames open at the same time, and I need a way to close one of them whenever it looses focus.
    Hope you can help me.

    JFrame frame1 = new JFrame("Frame1");
    frame.addFocusListener(this);
    void focusGained(FocusEvent e)
    void focusLost(FocusEvent e)
    dispose();

  • ADF AutoSubmit True column Loosing Focus after hitting Tab

    Hi,
    I am on 11.1.2.2.0. I have implemented af:table component and inside table on few columns I have autoSubmit="true" immediate="true" . After entering values into those columns when I hit Tab (To go to next field in table) , it goes to next field and looses focus. Is there any work around or fix to overcome this issue ?
    Thanks and Regards,
    Jit

    Hi,
    Thanks for the links. My requirement is to set focus inside af:table. Inside table I have say 5 fields.
    3rd Field is LOV and 4th fields is Text. After entering LOV info in Field3 focus should go to field4(which is inputText).
    I tried
    Frank's Blog
    https://blogs.oracle.com/jdevotnharvest/entry/how_to_programmatically_set_focus
    AMIS Blog
    http://technology.amis.nl/2008/01/04/adf-11g-rich-faces-focus-on-field-after-button-press-or-ppr-including-javascript-in-ppr-response-and-clientlisteners-client-side-programming-in-adf-faces-rich-client-components-part-2/
    This works for ADF Form entry. When I tried implement this in table the field id(eg it4) is not picked.
    I found other blog for where it is mentioned field id dwill be different in case of Table.
    http://www.bartkummel.net/2009/11/oracle-adf-set-focus-to-input-field-in-data-table/#respond
    Do you have any idea how to get Table id or help in building this field id in Table ?
    Thanks and Regards,
    Jit

  • My windows keeps loosing focus when bluetooth goes active

    Hi, I have a problem with my bluetooth.
    When my bluetooth on my laptop goes active i.e. the "bluetooth B" in the bluetooth icon on the botton tray in Windows goes from white to green this problem accours. At that very moment, the current window I am working in goes inactive. If I am typing in a textbox for example and the bluetooth goes from "white to green", the textbox looses focus and I have to cklick it to resume my typing.
    How dow get rid of that problem and still have a reachable bluetooth device?
    Running on Windows XP Pro, laptop:
    Bluetooth Stack for Windows by Toshibe
    Version v4.42 (D)
    Bluetooth spec:
    Version 2.0, 1.2, 1.1
    Thanks!
    //Doman

    That could be the solution... but no luck..
    Now, I´m running with stack: v6.01.03(D)
    ...and the problem is still there.
    *More background:*
    I am using a SonyEricsson sync program, every morning I connect my mobile via this program. The program is set to autosync the first thing when it detecs the mobile via bluetooth. The laptop stays often in the it´s dock and when I leave it (with the mobile in my pocket) and come back, they find eachother again and the sync starts. This way I never need to start the sync by myself which I always forget otherwhise.
    The problem is that my computer sometimes checks if my mobile is still there (I suspect), and each time it starts to use the internal bluetooth device, the focus of current window I´m using is lost, this is of course very annoing when I´m writing something etc. This occurs regardless of the result of the search, ie regardless of it finds the phone or not.
    Is there any workaround without losing that my phone autoconnects with my computer and the sync starts?

  • How to force refresh of data through browser or PDF?

    We have the dashboard set to refresh every minute.  We are pulling the data using XML from DB.  When we are in browser and clear the browser cache and then reload the .swf... the data is updated.  We haven't been able to figure out how to force the cache-clear and data refresh with either swf or pdf.
    Your help is greatly appreciated.

    Hi Jeff,
    Is the XML coming from a web page or a web server?
    If yes then you can give this a go. To stop the caching mark your web page with extra tags to say it has expired.
    HTML page example:
    <HEAD>
        < META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE" />
        < META HTTP-EQUIV="EXPIRES" CONTENT="0" />
    </HEAD>
    JSP example:
    <%
      // Stop Internet Explorer from caching the results of this page.
      // We do this so that every time Xcelsius calls this page it see the latest results.
      response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
      response.setHeader("Pragma","no-cache"); //HTTP 1.0
      response.setDateHeader ("Expires", 0); //prevents caching at the proxy server 
    %>
    Regards,
    Matt

  • How do I stop Firefox from auto-focusing on text boxes?

    How do I stop Firefox from auto-focusing on text boxes? Sometimes as a page is loading, I scroll down the page...only to have the page jump back to where there is a text box, with a blinking cursor, after the page is finished loading. It is an annoying feature and I want to turn it off.

    Some pages use an onload event to set the focus to a text area or search field.
    You can try NoScript to see if that blocks it.
    *NoScript: https://addons.mozilla.org/firefox/addon/noscript/

  • Ive had my iphone 3 for 3 months,I have not connected my phone to upload from the computer yet,soemone told me I will loose everything in my phone.How can I do this without loosing all my stuff?

    I have had my iphone 3gs for 3 mths., I have not connected it to my computer to creat a apple id and upload, somebody told me u have to do this right when u get your phone or you will loose everything in your phone. I don't want to loose all my #'s, pictures,texts,etc.
    How can I do this without loosing everything?
    Thanks

    They told you incorrectly, although it is not a good idea to rely on the device as a single point of storage.
    You must have an Apple ID to purchase content via iTunes, simply log in with that ID in iTunes.  Then connect the device and sync it.  For detailed instructions, read the manual which is available online or on the device.

  • How to force a new password in portal with LDAP user? external users

    With an external portal (used by agents that do not work for you or reside in your office), company policy is for password to be changed every qtr.
    If the users are creating as LDAP users how to force them to change their password when required?
    Is this a custom application that needs to be written so when they log into the portal if the qtr has expired the portal ask them to enter a new password that becomes valid for the next qtr.
    Versus internally deleting and emailing all the users a new password?

    Hi Glenn,
    We are getting one problem when we are creating user in LDAP and login with that user in  Portal that time we are getting Password change screen , but when we create a user in LDAP and change the password of that user in LDAP then when the user tries to  Login to portal that time we are not able to see the password change screen.
    But again if we change the password of that user through Portal we are able to see change password screen.
    can you help on this how we can force the user to change password when we are changing password in LDAP or in SAP System.
    Regards
    Trilochan

  • How to force the "Bluetooth Communicat​ions Port" to be one of COM1 to COM8 ports?

    Dear Lenovo Community, Happy Holidays to you all and wish you a great happy new year. Recently purchased a Bluetooth OBDII device and have difficulty making it to work with its provided software on my T61 (running original XP Home). My short story and question/problem is that I can open "My Bluetooth Places" and pair with the OBDII device as an "OBDII SPP Dev", but my T61 assigns serial port COM19 to it. The OBDII software which came with the device only can let user set to one of the COM1 to COM8 ports and in the properties of Bluetooth pairing, there is no way that I can select which COM port to use. I looked at the Device Manager and I do see these COM port assignments: COM4,5,6,7: Sierra Wireless (the HSDA modem in the laptop which I have never used BTW) COM 9,10,11,12,13,14,15,16,17: Bluetooth Serial Port COM 18, 19: Bluetooth Communications Port and I don't see anything for COM1,2,3, and 8 My question is how to force the computer/OS to assign one of the COM1 to COM8 ports to my device upon pairing? Can I disable the Sierra Wireless model from the COM ports list and hope this will happen? Thanks for your help and inputs beforehand. Regards, AL

    Hi, AL_K
    Have you attempted to change the port number in device manager itself? If you navigate to Device Manager and open the list of Ports, you can right-click on the device you wish to assign a different port number. After right-clicking, click Properties. There should be a tab called Port Settings. In here, you should find a setting to manually assign a port number.
    Good luck, and let me know how it goes,
    Adam
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution!" This will help the rest of the community with similar issues identify the verified solution and benefit from it.

  • My Ipod touch is showing a connect to itunes image. How do I fix it without loosing all of my footage and photos?

    I updated my ipod but it failed....
    Now my Ipod touch is showing a connect to itunes image. When I connected it to itunes it said that I need to "Restore it". But I have video on it that I really, really need. How do I do this without loosing all of my footage and photos?
    Please help!?

    You do not. You have to restore the iPod. You can then restoe from backup and get to where you were when the the last backups was made.

Maybe you are looking for

  • Error while executing infopackage of 2lis_03_bx

    Hi, I am using a multiprovider which gets data from 3 cubes OIC_C03 ,ORT_C37 and my customized ZRT_C37. When i am executing infopackage  2LIS_03_BX(Stock Initialization)  which updates data into three specified cubes , its giving me below specified e

  • Help restoring hard drive storage!!!

    Is there ne way i can clear up my hard drive because i only have like 7 Ggs left. I want to delete all my pictures in IPHOTO (they're already backed up) but when i did that it didnt restore any storage back? please help!!

  • ITunes Match never works!

    I purchase iTunes Match four days ago.  I only have 12k songs in my library.  Match never completes step one.  Errors 4002 and 4010 continuously appear.  None of the solutions posted online have worked.  What is the solution?

  • Using bind variable in existsnode?

    Is there a way to use bind variables in an XPath query? SELECT sys_xmlagg(sys_xmlgen(xmlconcat(extract(value(x),'//title'),extract(value(x),'//description')))).transform(pkg_xslt_dao.getIndexContentXSLT).getClobVal() into v_html from iwgeneric x wher

  • Remove attachments from sent mail - how to?!

    Hi all. Sometimes I'd like to keep sent mails but remove the attachment(s) embedded in there. How can I do this? Thanks in advance.