A focus question: button activated by mouse or by ENTE

In the following program:
If the program is run as is ? The button can be activated only by the mouse.
If the part:
// try {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// catch(Exception e) {
// e.printStackTrace();
is used, the button can be activated also by ENTER and the focus is the default.
How to get the second option not using SystemLookAndFeel ?
Which option is better for an application or an applet ?
Help would be appreciated.
import javax.swing.*;
import java.awt.event.*;
public class Focus extends JPanel {
JButton b2;
public Focus() {
// try {
// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
// catch(Exception e) {
// e.printStackTrace();
b2 = new JButton(("Is it ok?"));
add(b2);
b2.addActionListener(buttonListener);
ActionListener buttonListener = new ActionListener() {
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Is it ok?")) {
System.out.println("It's ok !!!");
public static void main(String[] args) {
JFrame fr = new JFrame();
     Focus fc = new Focus();
fr.getContentPane().add(fc);
     fr.setVisible(true);
fr.pack();

dialog.setModal(true);beat you!
You did provide code though :)

Similar Messages

  • How to keep the save-button active all the time?

    Hi!
    I'm using mobile sales 4.0.
    On a tile i've only fixed questions and combo boxes with yes and no ...
    When i write manually a "yes" in the combo box field the save button is active - When i use the combo box with a mouse click the save-button isn't active.
    What are the settings i've to do to keep the save-button active all the time?
    Thanks a lot in advance.
    Best regards,
    Ingo

    Hi Ingo,
    If your combobox is a bound control, then when you change a value in it, the save button should be enabled. Strange. But anyway, you can do this.
    In the <b>combobox_OnValueChanged2</b> event, make a call to makeDirty method in the tile:
    If boundAttributeChanged Then
         <b>anchorthatyourcombotiedto</b>.bo.MakeDirty True
    End If
    This will make the Save button enabled.
    Regards, Vadim.

  • Attaching several buttons to one mouse listener

    Attaching several buttons to one mouse listener
    I have an application which consists of a GUI form, "EntryForm," and "DataForm," a collection of variables.
    Clicking EntryForm's submit button sends the entries to DataForm.
    The submit button is attached to a mouse listener "SubmitButtonHandler"
    My Question: How can I attach an arbitrary number, up to five instances of EntryForm to ONE mouse listener?
    I have tried this:
         final SubmitButtonHandler sbh = new SubmitButtonHandler( ...
         entryForm1 = new EntryForm();
         dataForm1 = new DataForm();
              entryForm1.submitButton.addMouseListener( sbh );
         entryForm2 = new EntryForm();
         dataForm2 = new DataForm();
              entryForm2.submitButton.addMouseListener( sbh );
         entryForm3 = new EntryForm();
         dataForm3 = new DataForm();
              entryForm3.submitButton.addMouseListener( sbh );
         entryForm4 = new EntryForm();
         dataForm4 = new DataForm();
              entryForm4.submitButton.addMouseListener( sbh );
         entryForm5 = new EntryForm();
         dataForm5 = new DataForm();
              entryForm5.submitButton.addMouseListener( sbh );
         ...In the mouse listener I have tried these approaches:
         public void mouseClicked( MouseEvent e ) {
              if ( e.getSource() == entryForm1.submitButton ) {
                   System.out.println( "Clicked: entryForm1.submitButton" );
                   // send the data to dataform1
              } else if( e.getSource() == entryForm2.submitButton ) {
                   System.out.println( "Clicked: entryForm2.submitButton" );
                   // send the data to dataform2
         public void mouseClicked( MouseEvent e ) {
              if ( e.getSource() == submitButton ) {
                   if( e.getSource() == entryForm1.submitButton ) {
                   // send the data to dataform1
                   } else if( e.getSource() == entryForm2.submitButton ) {
                   // send the data to dataform2
              } else if ( e.getSource() == anotherButton ) {
                   ...In both cases, only ONE form's button registers and even that is screwy.
    Can this approach be fixed so that the mous listener can discern between the various forms, or do I have to use five sets of forms and mouse listeners?
    Many thanks in advance.

    Hi,
    Button1.addMouseListener(ourMouseListener);
    Button1.setActionCommande("This is button 1");
    Button2.addMouseListener(ourMouseListener);
    Button2.setActionCommande("This is button 2");
    In the "ourMouseListener" event method, you use this...
    if((((JButton)event.getSource()).getActionCommand()).equals("This is button 1"))
    Source code for Button1
    if((((JButton)event.getSource()).getActionCommand()).equals("This is button 2"))
    Source code for Button2
    JRG

  • How to focus a button

    Hi all,
    Sorry about this stupid question, but really get confused now.
    I?ve got an Applet and i want to focus a button when it starts! How can i do this?
    thx

    Don't know if anyone is looking at this, but I went through a coupla days work, so I thot I would post. I was only able to get it working in IE. This solves the problem of initially not having focus on the applet, setting initial focus to a component and resetting the focus when switching back & forth betweens apps. First the HTML<SCRIPT LANGUAGE="JavaScript">
    <!--
    function setFocus() {
      hide.hideField.focus();
      document.TestApplet.setFocus();
    // -->
    </SCRIPT>
    <form id=hide>
    <INPUT style="border: 0px;" ReadOnly id=hideField maxLength=0 name="hideField" type=text notab>
    </form>
    </HEAD>
    <BODY onFocus="setFocus()" onLoad="setFocus()">
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    //removed some
    <PARAM NAME="scriptable" VALUE="true">I have no idea how this is going to post. This calls the JApplets setFocus method on loading and on focus. Make sure scriptable="true". Now the JApplet.public class Applet1 extends JApplet {
      public void start() { Focus.setFocus(jButton2); }
      public void init() {
        getContentPane().addContainerListener(Focus.cl);
      public void setFocus() { Focus.setFocus(); }
      static class Focus {
        private static Component lastFocus;
        public static ContainerListener cl = new ContainerAdapter() {
          public void componentAdded(ContainerEvent ce) {
         Component child = ce.getChild();
         addlisteners(child);
        private static void addlisteners(Component c) {
          c.addFocusListener(fl);
          if(c instanceof Container) {
         Container ct = (Container)c;
         ct.addContainerListener(cl);
         for(int i=0; i<ct.getComponentCount(); i++) {
           addlisteners((Component)ct.getComponent(i));
        public static FocusListener fl = new FocusAdapter() {
          public void focusGained(FocusEvent fe) {
         lastFocus = (Component)fe.getSource();
        public static void setFocus() { setFocus(lastFocus); }
        public static void setFocus(final Component comp) {
          if (comp != null) {
         SwingUtilities.invokeLater(new Runnable() {
           public void run() { comp.requestFocus(); }
    }I tried to make it compatible with AWT, but haven't tested it too much. Focus might also be made into it's own class, instead of an inner class so that it can be called from anywhere (after dialogs???).

  • The scroll button on my mouse suddenly stoped working after the recent upgrade in firefox

    about 6 weeks ago, the scroll button on my mouse quit working when using firefox. It works fine with explorer

    about 6 weeks ago, the scroll button on my mouse quit working when using firefox. It works fine with explorer

  • How can we make the save button active in standard toolbar in outout of alv

    Hi experts ,
    I am using factory method to print alv with oops .
    Cancel , Exit and Back button are active by default in Standard tool bar  in output of Report , But Save button is not active , How can i make that save button active .
    Also Pls tell me how i can make editable to the cell in output , 
    My Code is like this :
    cl_salv_table=>factory( IMPORTING r_salv_table = gr_table CHANGING t_table = ispfli ).
      gr_functions = gr_table->get_functions( ).
      gr_functions->set_all( abap_true ).
      gr_display = gr_table->get_display_settings( ).
      gr_display->set_striped_pattern( cl_salv_display_settings=>true ).
      gr_display->set_list_header( 'This is the heading' ).
      gr_columns = gr_table->get_columns( ).
      gr_column ?= gr_columns->get_column( 'CITYTO' ).
      gr_column->set_long_text( 'This is long text' ).
      gr_column->set_medium_text( 'This is med text' ).
      gr_column->set_short_text( 'This is sh' ).
      gr_column ?= gr_columns->get_column( 'CITYFROM' ).
      color-col = '6'.
      color-int = '1'.
      color-inv = '0'.
      gr_column->set_color( color ).
      gr_sorts = gr_table->get_sorts( ).
    *gr_sorts->add_sort( 'CITYTO' ).
      gr_sorts->add_sort( columnname = 'CITYTO' subtotal = abap_true ).
      gr_agg = gr_table->get_aggregations( ).
      gr_agg->add_aggregation( 'DISTANCE' ).
      gr_filter = gr_table->get_filters( ).
      gr_filter->add_filter( columnname = 'CARRID' low = 'DL' ).
      gr_layout = gr_table->get_layout( ).
      gr_layout->set_key( key ).
      key-report = sy-repid.
      gr_layout->set_save_restriction( cl_salv_layout=>restrict_none ).
      gr_table->display( ).
    Rgds,
    Premraj

    Hi,
    1)you need to give the function code to that save in the Function Keys of that screen from the GUI Status.
    2) while filling the field catalog of that field you need to put the        
    wa_fieldcat_edit-edit = c_x.
    i.e use the edit and append to that field catalog internal table.
    for more infomation you can refer to below links:
    problem with alv edit and save
    *Edit* and *Save*  for the selected records in ALV
    solves your problem
    Thanks!!

  • I want to know how to clear the text area by the push off my next question button and ask a new ques

    I want to know how to clear the text area by the push off my next question button and ask a new question - also I want to know how to code in my project to where a user can enter a math question in one border container and the answer enters into the next container
    heres my code so far
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" backgroundColor="#1E5C75">
        <fx:Script>
            <![CDATA[
                protected function button1_clickHandler(event:MouseEvent):void
                    //convert text area into labelid to be identified by actionscript
                    richTextLabel.text = myArea.text;
            ]]>
        </fx:Script>
        <fx:Declarations>
            <!-- Place non-visual elements (e.g., services, value objects) here -->
        </fx:Declarations>
        <!--container 1-->
        <s:BorderContainer borderWeight="7" x="28" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
            <!--data Entry control-->
            <s:TextArea id="myArea" width="153" height="68"/>
            <!--end of data entry control-->
            <s:Button width="151" label="ask a question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        <!--container2-->
        <s:BorderContainer borderWeight="7" x="509" y="10" width="200" height="138">
            <s:layout>
                <s:VerticalLayout paddingTop="10" paddingBottom="10"
                                  paddingLeft="10" paddingRight="10"/>
            </s:layout>
    <!--data entry control-->
            <!--convert tne data entry control into a label id in actionscript-->
            <s:Label id="richTextLabel" width="153" height="68"/>
            <s:Button width="151" label="next question" click="button1_clickHandler(event)"/>
        </s:BorderContainer>
        </s:Application>

    This is a user to user support forum.  We are all iphone users just like you.
    You are not addressing Apple here at all.
    This is an odd way to ask your fellow iphone users for help. Berating oterh users will not help you.
    "it's too fragile"
    No it is not.  i have never damaged one, nor has anyone I know.
    " U loose data when Ur phone is locked"
    No you don't.  Why do you think this?
    "and there is no customer support!!!  "
    Wrong yet again.  Apple has an 800 number and they have many retail stores and they have support articles that you can access using the search bar. Or you can contact them throgh express lane online
    "but I will go back with Blackberry "
    Please do.
    Good ridance

  • Button Activation Sequence.

    Hi Everyone,
    I am creating a program which controls a voice coil controller.  In the program, I have a series of buttons that need to be pressed in a specific order, in order for the controller to operate correctly.  Various users will be using this program so it's imperative that they are used in the correct order to prevent controller malfunction.  I was wondering if there was a way, for when the program starts, all of the buttons except one be disabled.  Once that first button is clicked, a second one becomes enabled, and so on.. until they all have been clicked in the right order.  Finally, when a stop or reset button is clicked, the initial state of only one button active becomes true.  I have attached the project if anyone would like to view the GUI.  "Updated GUI Fretter" is the program and the "Test Control" tab is the one I am referring to.  I'd initially like the "Download Program" button to be active, then once that is clicked, "set home position" becomes available for use, and so on to the right.  
    Any ideas or suggestions on how to make this function are greatly appreciated.
    Attachments:
    UPDATED GUI Fretter.vi ‏63 KB

    I take it back. Event structure is just what you need:
    Attachments:
    buttons.vi ‏15 KB

  • Question about activating iPhone

    I'm getting a iPhone soon, and have a question about activation. Is a credit card or debit card required during activation?

    The credit card is used to setup an iTunes Store account, Small tip. Set one up before activation to cut down on activation setup time.
    You can remove the credit card info off your iTunes account after it is setup. It is simply used for when you want to purchase music, videos, etc. off the iTunes Store.
    If you do not have a credit or debit card, Try going down to your local Walmart or Drug store, Some of these places sell Fillable Credit cards. You can buy the cheapest one they have and use it for Setup of the account. And simply refill it if you need more money for any purchases.

  • Why does the Back button require two mouse clicks?

    I've just upgraded to ver. 9 and now the Back button requires two mous clicks/

    I might not have used the word "Normal".  "Typical" maybe.  I suppose "Normal" is acceptable in the context of "SNAFU".
    Wait until you make an edit on one of your own posts to fix a stupid typo, then later look to find the typo back and you can no longer edit it.  And what's up with that messed-up Javascript that shows up at the top of some quoted messages?
    These forums are barely usable, but a bright spot is the color-managed photo attachment capability (i.e., you can upload an image with a non-sRGB color profile and the server will convert it).  I suppose if anything Adobe could have been expected to get that part right.
    -Noel

  • In  Zoom Burst Effect Guided Edit, when i use the  Add Focus Area button instead of focusing on what i choose it bring the entire photo into focus.

    In Zoom Burst Effect in Guided Edit, when I use the Add Focus Area button instead of focusing on what I chose it brings the entire photo into focus.

    I'd try resetting the pse 12 preferences by going to Adobe Photoshop Elements Editor (Edit)>Preferences>General
    and click on Reset Preferences on next launch, then restart pse 12.

  • Side buttons of mighty mouse

    I was just wondering if anyone knew if there was a script for making the side buttons on the mouse the foward and back buttons when youre browsing the web.

    lol if only it was that easy, unfortunately they don't offer those commands unless I'm totally missing something. I found a program called SteerMouse that lets you but you eventually have to buy it.

  • HOWTO: Enabling Forward, Back Buttons, Logitech MX1000 Mouse

    Enabling Forward and Back Buttons, Logitech MX1000 Mouse
    (and Microsoft Wireless Intellimouse Explorer, apparently)
    Step 1: Get, Install evdev
    ==========================
    First, use evdev as the Xorg mouse driver.
    Get this module, install it, and make sure it is loaded each time you run Linux.
    For Arch, this means:
    # pacman --sync xf86-input-evdev
    and adding "evdev" to the modules list in /etc/rc.conf.
    Step 2: Modify xorg.conf to Use evdev as Your Mouse Driver
    ==========================================================
    Next, in /etc/X11/xorg.conf, create an evdev-based input device that specifies your mouse:
    # evdev based section for Logitech MX1000 mouse
    Section "InputDevice"
    Identifier "Evdev Mouse"
    Driver "evdev"
    Option "Name" "Logitech USB Receiver"
    Option "CorePointer"
    EndSection
    Note: then "Name" field above is important. Find out the name for your device via:
    % egrep "Name|Handlers" /proc/bus/input/device
    In the case of the Logitech MX1000 mouse, which is wireless, it is: "Logitech USB Receiver".
    Step 3: Modify Xorg ServerLayout to Use Your evdev Mouse
    ========================================================
    Now modify the Xorg server layout to use this mouse entry:
    Section "ServerLayout"
    Identifier "Xorg Configured"
    Screen 0 "Screen0" 0 0
    InputDevice "Keyboard0" "CoreKeyboard"
    InputDevice "Evdev Mouse" "CorePointer"
    # PS/2 Mouse not detected
    # Serial Mouse not detected
    EndSection
    Step 4: Do Some Button Mapping for The Forward and Back Buttons
    ===============================================================
    Now, add the following to your .xinitrc, or somewhere where it will be executed each time X starts:
    % xmodmap -e "pointer = 1 2 3 4 5 8 9 6 7"
    You will receive the warning:
        Warning: Only changing the first 9 of 20 buttons.
    Don't worry about this - it is normal.
    Finally, to get those pesky Forward and Back buttons working in some Gnome apps such as Nautilus,
    get and install xvkbd and xbindkeys. Now create file ~/.xbindkeysrc, containing:
    # Mouse Buttons
    "/usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Left]""
    m:0x0 + b:6
    "/usr/bin/xvkbd -xsendevent -text "\[Alt_L]\[Right]""
    m:0x0 + b:7
    "/usr/bin/xvkbd -xsendevent -text "\[Left]""
    m:0x0 + b:8
    "/usr/bin/xvkbd -xsendevent -text "\[Right]""
    m:0x0 + b:9
    and add the following to your .xinitrc, or somewhere where it will be executed each time X starts:
    % xbindkeys
    That is it! Simple n'est pas? :-)
    Many, many thanks to Arch forum member MrWeatherbee, who provided most of the key elements of the above - thanks!
    Last edited by mac57 (2007-08-20 14:46:29)

    Hi Misfit138, I agree that the general ideas are there already in the Wiki, but even after reading that entry, I was not able to get things working. The existing entry is not specific enough to the MX1000 mouse. So, although I have never contributed to a Wiki before, I think it is likely a good idea to do so in this case. I will make sure that the entry is very MX1000 specific. It will address a small audience, but it is one way of giving back a little to the community.

  • Right mouse button and middle mouse button

    Hi,
    How can i add a right mouse button and middle mouse button
    click in captivate, is there a way out of this.

    Hi prem1280
    There is a Developer Center article that may help here.
    Click
    here to read it.
    Additionally, if you are planning on publishing to .EXE
    format, fellow Adobe Community Expert Paul Dewhurst has something
    at
    This
    Link that you may be interested in.
    Cheers... Rick

  • Batch Master Classification View - Inconsistent button active

    Hi
    We are encountering a problem of the Inconsistent button getting active in the Batch Master Classification tab (Material is batch controlled). We know the reason why this is getting active : Due to a wrong inbound value for a field called 'Sterilization Site' in the classification data (data element: ATWRT) through an interface from a legacy system.
    We also know the solution to get around this: Go into the batch master in edit mode and delete the inconsistency by clicking on the Inconsistent button and then the delete button on the pop-up screen which gives the inconsistent value.
    My requirement is: <b>How do we identify all the 'inconsistent' batches in the system?</b>  Is there a way to identify a batch having an inconsistent characteristic value?  (inconsistent value => value not existing in the allowed list of values for the particular characteristic)
    When I try to do a F1 on the 'inconsistent' button, I get a help screen giving "Program: SAPLCHRG; Function: VCON".
    Thanks
    Chandra

    Steve,
    You have given me the right solution, but in this one particular case that I am tracking, I think there is an aberration.
    I've got an output of all batches by using the option 'Show Incomplete Status' in CL2A. But this particular batch has the 'Inconsistent' button active, yet the classification status is showing as 'Released'
    Any idea how to deal with such batches and extract this information?
    Regards
    Chandra

Maybe you are looking for