How to generate action through Keyboard

Hi,
I have a JFormattedTextField. When it gets the focus all the data in it to be selected.
I have used selectAll () and select (), but no use.
As we know if use keyboard SHIFT+END will select all the data in text field.
How to do the same when text field gets the focus
please help me.
My code is below
textField.addFocusListener(new FocusAdapter (){
     public void focusGained (FocusEvent fe){
          textField.selectAll () ;
}) ;

Your code does work as expected.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class TfFocus{
  public static void main(String[] args){
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final JTextField tf = new JTextField("Get Focus Get Selected");
    frame.getContentPane().add(tf, BorderLayout.SOUTH);
    JTextArea ta = new JTextArea();
    frame.getContentPane().add(ta, BorderLayout.CENTER);
    tf.addFocusListener(new FocusAdapter(){
      public void focusGained (FocusEvent fe){
        tf.selectAll () ;
    frame.setBounds(0, 0, 400, 400);
    frame.setVisible(true);
    ta.requestFocus();

Similar Messages

  • How to generate cXML through  XI

    Can  you  please help me how to  generate  cXML and what configuration I need to  do it .  Thanks

    Ram,
    If you want you can download it and directly use it in XI by importing them as shabarish told. Check this threads for some information:
    Dynamically Download cXML.DTD in XI
    cXML Integration
    standard cXML package
    Does SAP EBP supports cXML?.
    ---Satish

  • How to add actions to keyboard?

    Hello I´ve been looking around the net, and found a lot
    of confusing information.
    I would like to know how to add simple actions like
    gotoAndPlay("next"); to a key.
    e.g. the right arrow.
    How could I do this? any simple way?
    thanks in advance, marcelo.

    In AS3 you can just use:
    if(event.keyCode == Keyboard.A)
    help doc:
    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/ui/Keyboard.html
    In AS2 you can use:
    if(String.fromCharCode(Key.getCode()) == "a")
    help doc:
    http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00001143.html#300959
    That way you don't have to look up the key codes.

  • How to set Actions to keyboard keys?

    hi,
    I need to provide action for the Function Key with Modifier Keys
    for eg : SHIFT+F3..
    Plz help me out..
    Thanks in advance..

    You might want to read up on [Creating a GUI with JFC/Swing|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html] and more specifically [How to use menus|http://java.sun.com/docs/books/tutorial/uiswing/components/menu.html].

  • How to preven JButton of generated actions when the user keep pressing down

    How to preven JButton of generated actions when the user keep pressing down the key or the short cut
    The code below to show the issue when the user keep pressing Alt+ O
    We want to prevent the JButton from generating multi actions just one action only
    A sample of code shows the behaviour which has to be prevented. Continue pressing "Alt +O" and you will see the standard ouptput will print time stamps
    Please notice, I am NOT interested in Mouse press which has a solution by adding a threshold ( setMultiClickThreshhold(long threshhold) on the JButton  as an attribute.
    public class TestPanel extends JPanel
       private JButton btn;
       public TestPanel()
          btn = new JButton("Open");
          this.add(btn);
          registerCommand(new MyAction(), InputEvent.ALT_MASK,
                KeyEvent.VK_O, btn, btn.getText(), 0);
       public static void registerCommand(AbstractAction action,
             int mask,
             int shortCommand,
             JComponent component,
             String actionName,
             int mnemonicIndex)
          InputMap inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
          KeyStroke knappKombination = KeyStroke.getKeyStroke(shortCommand, mask);
          if ((component instanceof AbstractButton)
                && mnemonicIndex >= 0
                && mnemonicIndex < actionName.length()
                && (shortCommand >= KeyEvent.VK_A && shortCommand <= KeyEvent.VK_Z))
             ((AbstractButton) component).setDisplayedMnemonicIndex(mnemonicIndex);
          if (inputMap != null)
             ActionMap actionMap = component.getActionMap();
             inputMap.put(knappKombination, actionName);
             if (actionMap != null)
                actionMap.put(actionName, action);
       public static class MyAction extends AbstractAction
          private static final long serialVersionUID = 1L;
          @Override
          public void actionPerformed(ActionEvent e)
             System.out.println(System.currentTimeMillis());
       public static void main(String... args)
          SwingUtilities.invokeLater(new Runnable()
             public void run()
                JFrame frame = new JFrame("Testing");
                JPanel panel = new TestPanel();
                frame.getContentPane().add(panel);
                frame.setPreferredSize(new Dimension(500, 500));
                frame.setMinimumSize(new Dimension(500, 500));
                frame.pack();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setVisible(true);
    }Edited by: user12130673 on 2013-feb-13 03:01

    Use KeyStroke getKeyStroke(int keyCode, int modifiers, boolean onKeyRelease) with onKeyRelease=true instead?

  • How's Light Going Through The Wireless Keyboard Aluminum Body?

    Hi. It's nice how they designed the wireless keyboard. If you switch on the power button, you'll see the light coming through the alluminum body but there are no holes in there. How'd they do that?:) It's nice to see things like this from Apple's designers. I wished it was flatter though and the battery case would just be on top or middle. Gbu.

    If you take a very close look at the keyboard you'll see that there micro holes in the casing.
    afaik a laser is used to punch that holes.

  • How to generate selection change event through code in JTree?

    I am developing an application which downloads the file from other system and adds it into the tree. On selecting any file in the tree I m displaying it's contents. But now i am trying to display the contents of downloaded file as soon as it's download completes. Here i am not getting the way to how to generate the event as the download completes, because i tried that setSelectionPath(TreePath path), but it also don't generates the selection change event. Is there any other way to do so?

    Put null in place of oldLeadSelectionPath. From the API for TreeSelectionEvent:
    protected TreePath     oldLeadSelectionPath:
    leadSelectionPath before the paths changed, may be null.
    I'm at the office and can't try out anything, so please let me know whether that works for you.
    db
    edit Or it may be easier to put all code from your valueChanged (...) override in a new method and invoke that method both from valueChanged (...) and wherever else you need.
    Edited by: Darryl.Burke

  • How to generate org model through report

    How to generate org model using report .
    please share your information .
    thanks in advance ,
    sapcrm

    Hi,
    It's look like you are assuming that an organizational model can be created from external data input via a report. If so, then your assumption is wrong. There is no standard way to create a org. model from external input.
    As a standard practice SAP provided a report as mentioned in the previous reply. Using this report you can download ECC/R3 org. model into SAP CRM. This is the easy and best proven way of generating org. model in SAP CRM.
    Please let me know, if you need any further clarification
    Do not forget to reward if it helps
    Regards,
    Paul Kondaveeti

  • How to generate download links of packages through Pacman

    Hello World
    I have installed Arch base in virtual box before physical install. I have synchronized pacman database with pacman -Syy command. Now I want to install other stuff like x ,gnome, sound etc. Please tell me how to generate download link for any any package and all its dependencies to a text file with Pacman so that i can download it with wget on some other computer and then transfer it back to my system.
    Thanks
    Last edited by cadcrazy (2008-09-23 03:33:08)

    man pacman wrote:-p, --print-uris
               Print out URIs for each package that will be installed, including
               any dependencies yet to be installed. These can be piped to a file
               and downloaded at a later time, using a program like wget.

  • How to add drill-through action programmingly

    I am using a third-party tool to create the SSAS cube. That tool does not have the function to create a drill-through action so I have to manually add the drill-through each time after I overwrite the SSAS database.  
    Is there a way to add the drill-through action through code, like XMLA? I googled this topics for a while but could not find the answer. 
    Thanks.

    HI,
    U can use AMO(Analysis Management Objects) to create a whole SSAS Database.
    For example
    http://avinashkt.blogspot.co.at/2008/04/olap-cube-generation-programmatically.html
    This example shows the cube generation programmatically by C#. But there are alos classes and methods in AMO for Actions.
    KR Jürgen

  • How to generate key events to a componet without keyboard

    I want to generate a key event, a Keylistener is already there, (in fact, java3D's KeyNavigatorBehavior). I want to use other input methods instead of key pressings, so how I generate the key event manually
    thx,

    Look at java.awt.Robot. It has a keyPress() method to simulate key presses.

  • Best Practices:: How to generate XML file from a ResultSet

    Hi all,
    Could someone please suggest the best practices of how to generate an XML file from a resultset? I am developing a web application in Java with Oracle database and one of my tasks is to generate an XML file when the user, for example, click a "download as XML" button on the JSP. The application is basically like an Order with line items. I am using Struts and my first thought has been to have an action class which will extend struts's DownloadAction and through StAX's Iterator API to create an XML file. I intend to have a POJO which will have properties of all columns of my order and line items tables so that for each order I get all line items and:
    1. Write order details then
    2. Through an iterator write line items of that order to an XML file.
    I will greatly appreciate for comments or suggestions on the best way to do this through any pointers on the Web.
    alex

    Use a OracleWebRowSet in which an XML representation of the result set may be obtained.
    http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/webrowset/Readme.html
    http://download.oracle.com/docs/cd/B28359_01/java.111/b31224/jcrowset.htm

  • How to Generate commercial Invoice and Shippers letter of instructions?

    Hi,
    Could you please tell me how to generate the Commercial Invoice and Shippers Letter of instructions in GTS? What should be done after generating a proforma invoice (F8)??
    Please walk me through with the settings that are required for generating and printing a commercial invoice.
    Thanks,
    Shruthi

    Hi Shruthi,
    One you have created F8 it has to be pushed to GTS this F8 doc create custom Shipment document in GTS on this document you have to configure a mesage type determiantion which will print Commercial Invoice.
    Thorugh Communication Process setting ( PPF) ( SPRO Customs Mgmt --->Comm Process )
    Detail step :
    Define Tech Med for Msgs ( PPF) for Custom Shipment and Decalration ( If any messages required)
    2.Define Condition and Output Parameters for Comm Of Cust ship & Decl.
    3.Define Messages For Comm Process.
    4. Define Control Settings of Communication Process
    Process Templates, Process, Activities,Messages,Activity Seq,Subsequent Activity ,
    5.Determination Of Activity Sequence.
    6.Classify Foreign Trade Document.( For messages)
    7.Define Standard Text and Logo For Printing Document ( If reqd for mesages)
    8.Print Control For Foreign Document .
    Set the parameter defined under in GTS Main Menu *"(Customs Processing Import Export/Message Parameters) Message Determination *"
    Action profile you have choosen to define your action def has to be assigend to
    custom doc type CULOEX or which ever you are using
    SAP native /SAPSLL/PF_US_COM_IN  Pdf form is available for CI you can create custom if you need more fileds on it.
    Kind Regards,
    Sameer

  • How to Generate a ReportError Event

    I'm sure I'm just missing something here.  Our LabVIEW GUI has a registered event Callback for ReportError.  In TestStand I handle errors with SequenceFilePostStepRuntimeError and ProcessModelPostStepRuntimeError callbacks.  I used the error handling example and modified to basically just show a popup with the error message.  My problem is how to generate the ReportError event so our GUI can take the appropriate action.
    I don't see it listed under the given UIMessage event codes.  I can't find it anywhere.  So the questions is where do I generate the ReportError event within TestStand?
    Thanks.

    Hi Sir Mutt,
    If my understanding is correct, you are using LabVIEW as your operator interface to start the Teststand Application and you want to do Teststand Error Handling in LabVIEW. The most common way that this is achieved is through ActiveX Invoke and Property nodes as well as ReportError events. I have attached two screenshot examples of this. Does this sufficiently address your question or did I misinterpret your question?
    Regards,
    Jackie
    DAQ Product Marketing Engineer
    National Instruments
    Attachments:
    ReportError Callback.png ‏8 KB
    Teststand Error Handling.png ‏20 KB

  • How to generate an excel spreadsheet from an Oracle Application forms runni

    I need URGENT generate an Excel spreadsheet with rows and columns populated from a forms that is running on Oracle Application R11.5 and open this worksheet for the User save.
    I want to include a PL*SQL code on a button and this button to run the spreadsheet open save for the User.
    Sorry my poor English, thanks for the comprehension

    909356 wrote:
    I need URGENT generate an Excel spreadsheet with rows and columns populated from a forms that is running on Oracle Application R11.5 and open this worksheet for the User save.
    I want to include a PL*SQL code on a button and this button to run the spreadsheet open save for the User. This functionality is already available in the application (File > Export) and you do not need to write a code to do that.
    How To Export Form Data To a CSV Format File [ID 779079.1]
    How To Setup Action Export Functionality in Release 11i [ID 136074.1]
    Thanks,
    Hussein

Maybe you are looking for

  • Printing subtotal in XML report

    Hi, how can I display subtotals for each customer if we have 3 customers. Here each customer has more than one row. How can I set this in RTF for XML report. jyothi

  • Skype Messages won't send

    A couple of days ago when I reinstalled Skype for my Mac, I was talking to a friend when suddenly my messages were pending. I did everything, checked my connection, it was fine, closed and reopened Skype, it was the same, uninstalled and reinstalled,

  • Char to Num or Num To Char

    Hi Gurus, Can any one tell the conversion from char to num or num to char in ABAP. we are using abap extractor .where we are  joining num --> char Field. select c1 c2 c3 from table x,y where xcolumn(num) = ycolumn(char). I got a CHAR_NUMC_CONVERSION

  • Virus email opened on phone is it safe to use Mac?

    Hi everyone, Whilst away on my honeymoon I was using my husband's HTC phone. I recieved an email from a family member and being half asleep I stupidly opened the suspicious email and the attchment and even logged into my email account again on a bogu

  • N97 mini USB cable connectivity issue

    Hello all, I've tried to connect my N97 mini with the micro USB cable, and it seems not to work.  When I connect the device, It asks me to pick PC Suite, I choose it, but then, when it tries to install the phone on my laptop, it just doesn't work, an