Consuming an event

Hello,
I have a JList and a KeyListener registered to it. The KeyListener class code is attached below:
private class ListCancelKeysListener extends KeyAdapter
    public void keyTyped(KeyEvent e) { e.consume(); }
}The problem is that the events are not consumed by the listener! I still get the JList's responses to key presses processed!
Can anyone please tell me what I'm doing wrong?
Thanks.

Real work might need tweaking the UI level, but this also works, virtually.
import java.awt.*;
import javax.swing.*;
public class ColdList{
  JFrame frame;
  Container con;
  JList list;
  public ColdList(){
    frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    con = frame.getContentPane();
    list = new JList(new String[] {"Socket", "HTTP", "HTML", "CSS",
     "JavaScript", "Flash", "Servlet", "JSP", "JSF", "Facelet"});
    list.setCellRenderer(new CellNoRen());
    con.add(list, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
  public static void main(String[] args){
    new ColdList();
class CellNoRen extends DefaultListCellRenderer{
  public Component getListCellRendererComponent(JList list, Object value,
   int index, boolean isSelected, boolean cellHasFocus){
    Component com = super.getListCellRendererComponent(list, value, index,
     isSelected, cellHasFocus);
     com.setBackground(list.getBackground());
     com.setForeground(list.getForeground());
     ((JLabel)(com)).setBorder(null);
     return com;
}Beware, selection(s) is/are still being generated from this list.

Similar Messages

  • How to consume key events

    I would like to create a subclass of TextBox that only allows numeric input. My idea was to provide my own onKeyType() handler and consume any key events that do not correspond to digits. However, I can't find any way to consume key events from further processing. How do I do this?
    Are there any other suggestions how to accomplish the task of providing your own filter concerning valid key input?
    /Bengt

    I also wanted a kind of validators for the TextBox class of JavaFX. So I've tried solving the problem using the SwingTextField class and some Java APIs. The following is my code for a SwingTextField accepting only digits, but I do want it to be much simpler.
    import java.awt.AWTEvent;
    import java.awt.event.AWTEventListener;
    import java.awt.event.KeyEvent;
    import java.awt.Toolkit;
    import javafx.ext.swing.SwingTextField;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javax.swing.JComponent;
    class DigitKeyEventHookListener extends AWTEventListener {
        public-init var  source:JComponent;
        public  override function  eventDispatched( event:AWTEvent):Void {
            if (event.getSource().equals(source)) {
                var keyEvent : KeyEvent = event as KeyEvent;
                var keyCharacter = keyEvent.getKeyChar();
                var isDigit = false;
                var code = keyEvent.getKeyCode();
               if ((KeyEvent.VK_0 <= keyCharacter) and (keyCharacter <= KeyEvent.VK_9)) {
                       isDigit = true;
                if ((code ==KeyEvent.VK_DELETE) or (code ==KeyEvent.VK_BACK_SPACE)) {
                    isDigit = true;
                if ((code ==KeyEvent.VK_LEFT) or (code ==KeyEvent.VK_RIGHT)) {
                    isDigit = true;
               if (not isDigit) {
                    keyEvent.consume();
    function createSwingTextField() : SwingTextField{
        var field = SwingTextField {
            columns:12
        var listener =  DigitKeyEventHookListener{
            source: field.getJTextField()
        Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
        return field;
    Stage {
        title: "Digit Box"
        width: 200
        height: 80
        scene: Scene {
            content: createSwingTextField()
    }

  • Can SOA consume business events using non-apps datasource ?

    Hi Gurus & Experts,
    We have a scenario where EBS raises custom business event to be consumed by SOA.
    Everything works fine using APPS login, however we need to non-apps datasource in some environements (custom schema user)
    Can SOA consume business events using non-apps datasource ?
    Please let me know.
    Thanks,
    Rev

    Hi Srini,
    Even i have a similar requirement . Could you please send me the link for OracleEBSAdapterUserGuide(b_28351). ?
    Did you come to know how to check whether WF_Listener is running ?
    Thanks in advance
    Nutan

  • Producer Consumer & User Events with user input windows

    Hello All,
    I am planning to build Labview code using the Producer Consumer & User events pattern, the application needs multiple user input windows for things like personal data, feature selection etc, there could be around 15 or 20 distincts screen/panels required.
    The main question from me is... Is there a best practive approach to navigating/loading from one window to another etc, and also providing a way to to retrun to the previous window.
    Also I may need need to be running some slow logging and control hardware in the background while navigating some of the screens, this seems like the producer consumer vi will be running in the background while the user input causes a load/display window event.
    A simple Producer Consumer multiple winjdoow example would be very welcome. Thanks.
    Regards Chris

    I will second Mike's suggestion to use a central VI with subpanel(s).  It is usually less confusing than multiple windows.  Typically, the selection/navigation mechanism is on the left of the main panel, global info (like help) on the right, and the subpanel(s) in the center.
    The advantage of subpanels/subVIs is that you can launch your subVIs and keep them active in the background, even though they are not being used.  This means they will keep their state information and load into the subpanel almost instantaneously the next time you need them.  For a short tutorial on subpanels, check out this link.  Scroll down to the fourth reply for working code.  The original code posted is broken.
    Communication between your VIs or loops is typically done with either queues or event structures.  State information in each should be shift registers in the respective VIs.  If you have the time, I would highly recommend you learn how to use LabVIEW classes.  The command pattern is tailor made for this kind of application.
    Finally, avoid global data if you can.  Global data is anything that you can get to from anywhere (globals, functional globals, etc.).  Use of these can speed your development, but can also lead to sloppy design which will cause you major problems later.  If you really need globally available data, use a data value reference.  It is unnamed and requires a reference, which tends to enforce better programming practice.  Yes, there are instances where you truly need globally available, named data, but they are fairly rare.  You should only use them if you are experienced and really know what you are doing.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How to consume an event in windowClosing()

    Hi,
    I need to consume the window event once it has been serviced.
    class SymWindow extends java.awt.event.WindowAdapter
    public void windowClosing(WindowEvent event)
    // blah blah
    My_WindowClosing(event);
    My_WindowClosing(event) in turn pops up a JOptionDialog with YES, NO, CANCEL options. For YES, I can close this GUI by calling dispose(). But for NO, this windowClosing() gets called again, instead of closing this JOptionDialog. Also Close(x) for this JOptionDialog doesnt work ( windowClosing() gets called recursively again)
    My issue is that windowClosing() is being called recursively.
    So, what I want is that once this event has been serviced ( My_WindowClosing(event);), this windowClosing() should not be called again.
    Any suggestions please.
    Regards,
    Ashish

    Ashish, this forum is for Java-Collections,
    please post your question in appropriate places like AWT.

  • WDA Consume UI events (table selection)

    Hello,
    I have the following situation:
    I have a table (populated by supp-method A) and some other UI elements (populated by supp-method B showing additional information / details to the table entry).
    Supp-method B is executed anytime the lead selection of the table changes.
    If some of these values in the underlying UI elements are changed, I'd like to prompt the user with a "Save"-dialog if he changes the lead selection of the table. Unlikely the PopUp dialog runs asynchronously and the change to the lead selection occurs in the background while the PopUp dialog is being displayed. I can avoid the execution of the supp-method B (so the data isn't lost), but the lead selection is still on the wrong table line.
    Is there a way to "consume" or redirect the events provided by UI elements (similar to the IF_WD_COMPONENT->CANCEL_NAVIGATION( ) method) ?
    Best Regards
      Waldemar

    Hi Waldemar
    To avoid changing of lead-selection in background that you mentioned
    you can try to set 'selectionChangeBehaviour' property to MANUAL. The following passage is from help.
    This selection change behaviour determines that the table does not change its data source's lead selection upon user interaction, but only fires the onLeadSelect event. It is the event handler's responsibility to actually change the lead selection, or else the table will not be functional in a master-detail scenario. This behaviour allows application code to first evaluate if a lead selection change is to be allowed or not.
    BR
    Sergei

  • Consuming scheduler events

    Not too sure what I am doing wrong:
    1. Created an agent using:
    SQL> exec dbms_scheduler.add_event_queue_subscriber('feedback_agent');
    2. Created a table to hold the feedback:
    SQL> create table test_event(a timestamp with time zone, b varchar2(100) );
    Table created.
    SQL> commit;
    3. Submitted both the jobs:
    v_job_name := 'job_'||p_job_id';
    dbms_scheduler.create_job (
    job_name => v_job_name,
    job_type => 'EXECUTABLE',
    job_action => '/home/user/testscript.sh',
    number_of_arguments => 2,
    start_date => p_start_time,
    enabled => false,
    auto_drop => true);
    -- set the arguments
    dbms_scheduler.set_job_argument_value (
    job_name => v_job_name,
    argument_position => 1,
    argument_value => p_arg1_val);
    dbms_scheduler.set_job_argument_value (
    job_name => v_job_name,
    argument_position => 2,
    argument_value => p_arg2_val);
    DBMS_SCHEDULER.SET_ATTRIBUTE(v_job_name, 'raise_events', DBMS_SCHEDULER.JOB_SUCCEEDED);
    dbms_scheduler.create_job('Feedback_'||p_job_id,
    job_type=>'plsql_block',
    job_action=>
    'insert into test_event values(systimestamp, ''second job runs'');commit;',
    event_condition => 'tab.user_data.object_name = '''||v_job_name||'''',
    queue_spec =>'sys.scheduler$_event_queue,feedback_agent',
    enabled=>true);
    -- Enable the first job so that it starts running
    dbms_scheduler.enable(v_job_name);
    4. The actual jobs execute - but the feedback event is never captured. I see the "feedback_x" jobs sitting in the queue with teh following query:
    select *
    from user_scheduler_jobs

    Hi,
    I found one bug in your code - in the event condition you are using v_job_name which is e.g. 'job_1' but the actual job name will be canonicalized so the actual job name will be 'JOB_1' . You can fix this in several ways
    - start off with v_job_name being uppercased
    - put it in double-quotes when creating the job so the job name will remain lowercased
    - in the event condition use UPPER()
    Here is a simple test case which works (note that we use an uppercased J1 in the event condition).
    Hope this helps,
    Ravi.
    -- simple event job
    exec dbms_scheduler.add_event_queue_subscriber('feedback_agent');
    create table test_event(a timestamp with time zone, b varchar2(100) );
    begin
      dbms_scheduler.create_job (
        job_name => 'j1',job_type => 'plsql_block',
        job_action =>
    'insert into test_event values(systimestamp, ''first job runs'');commit;',
        number_of_arguments => 0, enabled => false, auto_drop => true);
      dbms_scheduler.set_attribute('j1', 'raise_events', DBMS_SCHEDULER.JOB_SUCCEEDED);
    end;
    begin
      dbms_scheduler.create_job('j2',
        job_type=>'plsql_block',
        job_action=>
      'insert into test_event values(systimestamp, ''second job runs'');commit;',
        event_condition => 'tab.user_data.object_name = ''J1''',
        queue_spec =>'sys.scheduler$_event_queue,feedback_agent',
        enabled=>true);
      -- Enable the first job so that it starts running
      dbms_scheduler.enable('j1');
    end;
    /

  • How to consume ETW events data in C#

    Hi,
    I am using Microsoft.BizTalk.CAT.BestPractices.Framework for tracing data in Custom Pipeline Components, Maps and Orchestrations.
    I want to capture events data in Real-time by using C# code.
    Can someone help how can i capture events data in c#?
    Thanks,
    Shahzad

    Hi Shahzad,
    When you use the Microsoft BizTalk CAT Teams logging framework for instrumenting your BizTalk solution then
    it will write events to the Windows ETW sub system. You need to write a component,lets call it as a monitor that will capture these events and write to database. There is an excellent project in codeplex titled 'Testing inside BizTalk using ETW Tracing'.See
    here .
    It is basically a console app that detect events published to ETW by the BizTalk logging framework and then
    publish them onto an MSMQ queue .See the source code for this project and you can implement the same in your C# component.
    Regards,
    Sajith C P Nair
    Please mark as answer if this helps

  • Consumer producer event control button top VI

    I am trying to control the main.vi example that create the “create project wizard” called “Continuous Measurement and logging” from a top lever VI.
    The problem I have is that, I will not start the main.vi unless it’s done by an event created by an operator. How can I control programmatically those buttons from another VI?
    I am attaching the block diagram picture from the wizard and the simple top_level VI to control that VI. Thanks
    Attachments:
    mainVI.png ‏62 KB
    top_level_VI.png ‏16 KB

    That main VI is meant to act as a top level VI.  It is recommended you add on to that VI if you need more capability.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to Find out who is consuming a keyboard event

    Our app handles copying of an object using a copy action that is active in a specific situation. This has an accelerator from the edit menu (Ctrl -C).
    If I open the menu then hit Ctrl-C it works but if the menu isn't open the action never gets triggered. It seems that some component along the way is consuming the Ctrl-C event so it never gets to the JMenuBar.
    Is there a way to find out who is consuming the event?
    Thanks
    Joey

    I'm not sure what's happening with your app. I wrote on up to see if it could handle the CTRL-C. Seems to work fine. Do you have any other JMenuItems with the same accelerator?
    import java.awt.event.*;
    import javax.swing.*;
    public class Copy extends JFrame {
         public Copy() {
              this.initMenuBar();
              this.setSize(400, 300);
              this.setVisible(true);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         private void initMenuBar() {
              JMenuBar menubar = new JMenuBar();
              JMenu edit = new JMenu("Edit");
              JMenuItem copy = new JMenuItem(new CopyAction("Copy"));
              edit.setMnemonic(KeyEvent.VK_E);
              copy.setMnemonic(KeyEvent.VK_C);
              copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_MASK));
              edit.add(copy);
              menubar.add(edit);
              this.setJMenuBar(menubar);
         public static void main(String[] args) {
              new Copy();
         private class CopyAction extends AbstractAction {
              public CopyAction(String label) {
                   super(label);
              public void actionPerformed(ActionEvent e) {
                   System.out.println("Action Performed.");
    }

  • Consumer application using ETW events for TCPIP tarffic message

    I am planning to build a consumer application using ETW events in real time mode. My application is already set with  EVENT_TRACE_REAL_TIME_MODE for KERNEL_LOGGER_NAME. And successfully consume the Registry and file events.
    Interested in consuming Network events for TCP/UDP and looking for sample code (C++) that gets relevant data from _EVENT_RECORD structure.
    Any sample application and relevant documentation will be of great help.
    Thanks.

    I know they are in this kit
    http://www.microsoft.com/en-us/download/details.aspx?id=3138
    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com

  • Order of elements and events.

    INTRO
    Hi Oracle community.
    A while ago I started a thread here on the forum where I had put three different subjects to be treated. The user jsmith guided me saying that I was supposed to separate things, dividing each subject in a separate thread. The original discussion is at the following link:
    Interesting things, however, unknown? StackPane, animations and filters.
    ABOUT
    So in this discussion, I will be talking about input events and maybe about event filters. I created a JavaFX 8 (b123) application that checks the mouse click on certain nodes. Basically I have a panel of buttons. Behind this panel, I have a scroll pane with rectangles. The rectangles are contained within a Group, and the buttons are in a VBox. The Group is set as ScrollPane content. VBox and ScrollPane are within a StackPane, which becomes the root of scene graph. If we observe the nodes tree, we'll find the following scenario:
    IMAGE
    Here is my source code:
    import javafx.application.Application;
    import javafx.event.EventHandler;
    import javafx.geometry.Pos;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ScrollPane;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.Rectangle;
    import javafx.stage.Stage;
    public class ScrollTest extends Application
        //                                                                                                       MAIN
        public static void main(String[] args)
            Application.launch(args);
        //                                                                                                 INSTÂNCIAS
        // CONTROLS
        private Rectangle[] rectangles;
        private ScrollPane scrollP;
        private Button[] buttons;
        // LAYOUTS
        private StackPane root;
        private Group group;
        private VBox vbox;
        //                                                                                                  INÍCIO FX
        @Override public void start(Stage estagio) throws Exception
            this.iniFX();
            this.confFX();
            this.adFX();
            this.evFX();
            Scene cenario = new Scene(this.root , 640, 480);
            estagio.setScene(cenario);
            estagio.setTitle("Programa JavaFX - RDS");
            estagio.show();
        /** Just instantiate JavaFX objects.*/
        protected void iniFX()
            // CONTROLS
            this.rectangles = new Rectangle[5];
            this.scrollP = new ScrollPane();
            this.buttons = new Button[6];
            // LAYOUTS
            this.root = new StackPane();
            this.group = new Group();
            this.vbox = new VBox();
        /** Just sets the JavaFX objects.*/
        protected void confFX()
            // CONTROLS
            for(int count = 0 ; count < this.rectangles.length ; count++)
                this.rectangles[count] = new Rectangle();
                this.rectangles[count].setWidth(Math.random() * 100 + 20);
                this.rectangles[count].setHeight(Math.random() * 100 + 20);
                this.rectangles[count].setFill(Color.rgb((int) (Math.random() * 255) , (int) (Math.random() * 255) , (int) (Math.random() * 255)));
                this.rectangles[count].setTranslateX(Math.random() * 600);
                this.rectangles[count].setTranslateY(Math.random() * 600);
                this.rectangles[count].setRotate(Math.random() * 360);
            for(int count = 0 ; count < this.buttons.length ; count++)
                this.buttons[count] = new Button("Button - " + count);
            // this.scrollP.setVbarPolicy(ScrollBarPolicy.ALWAYS);
            // this.scrollP.setHbarPolicy(ScrollBarPolicy.ALWAYS);
            this.scrollP.setPrefSize(400 , 400);
            // LAYOUTS
            this.vbox.setAlignment(Pos.CENTER);
            this.vbox.setSpacing(20);
            // This doesn't solve my problem.
            // this.vbox.setMouseTransparent(true);
        /** Just create the realtion between nodes, and the root.*/
        protected void adFX()
            for(int count = 0 ; count < this.rectangles.length ; count++)
                this.group.getChildren().add(this.rectangles[count]);
            for(int count = 0 ; count < this.buttons.length ; count++)
                this.vbox.getChildren().add(this.buttons[count]);
            this.scrollP.setContent(this.group);
            this.root.getChildren().add(this.scrollP);
            this.root.getChildren().add(this.vbox);
        /** Just add some events to some nodes for debugging.*/
        protected void evFX()
            this.vbox.setOnMousePressed(new EventHandler<MouseEvent>()
                @Override public void handle(MouseEvent e)
                    System.out.println("Mouse pressed inside VBox.");
            this.scrollP.setOnMousePressed(new EventHandler<MouseEvent>()
                @Override public void handle(MouseEvent e)
                    System.out.println("Mouse pressed inside ScrollPane.");
            if(this.rectangles.length > 0)
                this.rectangles[0].setOnMousePressed(new EventHandler<MouseEvent>()
                    @Override public void handle(MouseEvent e)
                        System.out.println("Rectangle pressed.");
                        rectangles[0].setFill(Color.rgb((int) (Math.random() * 255) , (int) (Math.random() * 255) , (int) (Math.random() * 255)));
    THE PROBLEM
    I wish I could click the mouse on VBox buttons, but also in the scroll pane, and in it's internal contents (the rectangles). I tried changing the VBox mouseTransparent property to true, and modify mouseTransparent to false on each VBox button, but that did not work. I've been reading the JavaFX documentation talking about routing events, and found the following:
    The route can be modified as event filters and event handlers along the route process the event. Also, if an event filter or event handler consumes the event at any point, some nodes on the initial route might not receive the event.
    Could it be that VBox is filtering events so they do not reach ScrollPane? Or is this being done by StackPane in some other manner? Does anyone have any idea what I could do?
    In any case, I thank you for your attention.

    You might need to modify the event dispatch tree so that the events get beyond the VBox. I'm not saying this is the right thing to do, but something worth looking at.
    root.setEventDispatcher(new EventDispatcher() {
    @Override
    public Event dispatchEvent(Event event, EventDispatchChain tail) {
    tail.append(group.getEventDispatcher());
    return tail.dispatchEvent(event);
    There is some info on event processing at Handling JavaFX Events: Processing Events | JavaFX 2 Tutorials and Documentation

  • How do I determine the size of an event queue?

    Hi,
    I'd like to be able to programmatically determine how many events are in queue so that I can change how they are processed based on how far behind the loop is.
    Is there a way to easily do this in labview? 
    I suppose I could create an identical parallel event loop that just counts the events as they come in, and then subtract the ones that get processed by the main event loop, but it seems like there should be an easier way.
    I'm using LV 8.1
    Thanks,
    Greg

    So you are recomending running two event loops, one waiting for the faster events and one waiting for the slower events?
    I wouldn't put it that way.
    Any event that takes 'long' (eg. a significant amount of time), should be processed in a consumer loop.
    So the event arives in the normal event structure, and is than feed to a consumer loop via a queue.
    In the LabVIEW examples there is a framework example called 'Produces/consumer with events' (or something like that).
    If you have a specific type of event generating very fast and you are only interested in the last a notifier might be usefull.
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Running subVI in parallel with itself using producer-consumer pattern

    I'm using the procuder-consumer pattern to create what I call threads in response to various events much like in Producer Consumer with Event Structure and Queues
    I have several physical instruments, and would like to run the exact
    same test in parallel on each of the instruments.  I have a subVI
    that takes as inputs a VISA resource and a few control references among
    other things and then performs the desired experiment.  I have a
    separate consumer loop for each physical instrument, with this subVI
    inside each consumer loop.
    My test VI worked great; each consumer loop was a simple while loop
    incrementing a numeric indicator (not using my real subVI above). 
    However, my real program can only run one consumer loop at a time much
    to my dismay.  Reworking my simple test VI to use a subVI to
    increment the indicator rather than just explicitly coding everything
    resulted in the same problem: only a single consumer loop ran at a time
    (and as I stopped the running loop, another would get a chance to
    begin). The subVI in this case was extremely
    simple taking only a ref to the indicator and a ref to a boolean to
    stop, and incrementing the indicator in a while-loop.
    Is there a way around this?  Now that I've spent the time making a
    nice subVI to do the entire experiment on on the physical instrument, I
    thought it would be fairly trivial to extend this to control multiple
    instruments performing the same experiment in parallel.  It seems
    only one instance of a given subVI may run at one time.  Is this
    true?  If it is indeed true, what other options do I have?  I
    have little desire to recode my subVI to manually handle multiple
    physical instruments; this would also result in a loss of functionality
    as all parallel experiments would run more or less in lock step without
    much more complexity.
    Thank you.

    You need to make your subvi reentrant.  Then it can run several instances at any time with each instance occupying its own unique memory space.  Click on File - VI Properties - Execution, and check the reentry execution checkbox.  Then save the vi.
    - tbob
    Inventor of the WORM Global

  • JOptionPane event blocking problem

    Hi,
    JOptionPane is causing me a problem.
    I have a simple frame that contains a text field and a button.
    Pressing the button should write something to the standard output.
    When the text field loses focus a JOptionPane in poped to the user.
    The following scenario is problematic:
    1. The text field owns the focus.
    2. The user presses the button.
    Expected result:
    The JOptionPane appears due to the lost focus event on the text field.
    After closing it some text is written to the standard output due to the action event on the button.
    The actual result:
    The JOptionPane does appears but after closing it nothing is written to the standard output. The button stays in a curious state (when the mouse hovers over the button the button looks pressed, and when the mouse doesn't hover over the button the button looks unpressed).
    Probable reason for this behaviour:
    The JOptionPane blocks all awt/swing events while it is opened. Some of the button code is perfomed due to the button press, but the ActionListener's actionPerformed method is not invoked.
    I need the actionPerfomed method to be invoked.
    Can anyone help me?
    Here is the source code:
    package test;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Test {
    public Test() {
    public static void main(String[] args) {
    //Test test1 = new Test();
    final JFrame f = new JFrame("Test");
    JButton b = new JButton("Click Here");
    JTextField tField = new JTextField("Text", 10);
    f.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    b.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.out.println("Button pressed!");
    tField.addFocusListener(new FocusAdapter() {
    public void focusLost(FocusEvent e) {
    if (e.isTemporary()) return;
    JOptionPane.showMessageDialog(f,
    "Focus lost",
    "Title",
    JOptionPane.INFORMATION_MESSAGE);
    JPanel content = (JPanel)f.getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.X_AXIS));
    content.add(tField);
    content.add(Box.createHorizontalStrut(5));
    content.add(b);
    f.pack();
    f.show();
    Thanks,
    Shai

    Hello Shai.
    The JOptionPane seems to consume all events when its shown. (Check the stack after JOptionPane is shown.) I've solved a similar problem with the SwingUtilities.invokeLater() method. Maybe the following example will help:
    Runnable doDlgError = new Runnable() {
    public void run() {
    JOptionPane.showMessageDialog(this, "Error", "Error",
    JOptionPane.ERROR_MESSAGE);
    SwingUtilities.invokeLater(doDlgError);
    -Olaf

Maybe you are looking for

  • IPod showing up in computer but not iTunes

    So i have this iPod classic and it is stuck on a screen that says plug into itunes to restore. But when i plug it into itunes it just doesnt show up. It shows up in my computer but not itunes. Any solutions?

  • Please help, I am running Windows 7 Home Premium and have problems with loading FLASH Player

    Everytime I attempt to load Adobe Flash Player, it says it is installing but then I get a screen that say, must close Internet Explorer, which I do, then the down load continues.  It eventually takes me to a window that is for Adobe Photoshop Element

  • Business Model and Mapping layer

    I am trying to create a logical dimension table by dragging the corresponding table from the physical layer. However, in the business model layer it shows up with a yellow icon indicating it is a logical fact table. Please help me how I create a logi

  • Is there a way to clip adjustment layers to multiple layers??

    When you click on the "Clip to layer" button in the Adjustments panel it will only clip the adjustment layer to the layer directly below the selected adjustment layer. I'm wanting to have an adjustment layer 'affect' (clip to) a couple of layers belo

  • 7th generation ipod icon won't display in itunes

    I just purchased the 7th Generation Ipod Nano.  I have gone through the troubleshooting in the Support section and it still will not display.  I used to have a 3rd generation Nano and that still shows up when I plug it into my laptop.  Any assistance