KeyEvent.consume() doesn't work

I have JFormattedTextField subclassed and implement a KeyListener to avoid typing invalid characters. so i implemented:
     * Implements KeyListener.
    public void keyPressed(KeyEvent event) {
        System.out.println("keyPressed: "+event);
        //verify:
        int keyCode = event.getKeyCode();
        switch (keyCode) {
        case KeyEvent.VK_T :
            System.out.println("valid: "+keyCode);
            break;
        default:
            System.out.println("invalid: "+keyCode);
            event.consume();
            break;
    }//keyPressed()The system out's are correct ("valid", "invalid"), but the invalid characters are still typed in the textfield - even though i call event.consume(). ?

i had to introduce a class variable as a flag and also implement the other methods of KeyListener:
     * Implements KeyListener.
    public void keyPressed(KeyEvent event) {
        //verify:
        int keyCode = event.getKeyCode();
        switch (keyCode) {
        case KeyEvent.VK_T :
        case KeyEvent.VK_ESCAPE :
            isKeyConsumed = false;
            break;
        default:
            event.consume();
            isKeyConsumed = true;
            break;
    }//keyPressed()
     * Implements KeyListener.
    public void keyTyped(KeyEvent event) {
        if (isKeyConsumed) {
            event.consume();
    }//keyTyped()
     * Implements KeyListener.
    public void keyReleased(KeyEvent event) {
       if (isKeyConsumed) {
           event.consume();
    }//keyReleased()not pretty, but it works as expected.

Similar Messages

  • Mdnsresponder will not quit.  Consumes above 100% CPU and kills my battery.  Also causes my fan to run constantly and my computer to get extremely hot.  Force quitting doesn't work.  It just comes back.

    The mdnsresponder will not quit.  Consumes above 100% CPU and kills my battery.  Also causes my fan to run constantly and my computer to get extremely hot.  Force quitting doesn't work.  It just comes back.   I posted about this earlier and never got an answer.  Somebody, please help. 
    Thanks.

    mDNSResponder is a background process that runs all the time. If you kill it, it's relaunched automatically.
    Please launch the Console application and select "system.log" from the file list. Enter "mDNSResponder" (without the quotes) in the search field. Post a sample of the log messages in the Console window -- only one example of each repeated message, please.

  • JTextField keyEvent consume()

    This question is related to the keyEvent-architecture.
    The JTextField (or any JTextComponent for that matter) is designed to use the keyEvents but NOT consume it. Which means the JTextField modifies its internal Document-model and leaves the keyEvent to propagate further for any body (parent-component etc.) to use it.
    I dont really understand why the design leaves that event to be used by anybody with key-mapping for that keyEvent !?!
    In the specific problem that I have, I am putting JTextField in MainFrame which also has zoomIn/zoomOut Menu-actions attached to Minus(-) and Plus(+) keys respectively.
    What I notice is whenever I type, Minus(-) in JTextField, zoomIn is invoked !!
    Well, I was able to prevent that from happening by attaching a keyListener to my JTextField whose ONLY JOB is to consume() ALL keyevents. (ConsumeAllKeysListener)
    This preety much solves my problem. But I would like to know, is this the correct way to prevent STRAY keyEvent propagation ?
    Also until now, I thought that the JTextField uses InputMap/ActionMap to append all the regular keys that are typed. This assumption is does not seem to be true since even when I consume all the keyEvents by attaching the "ConsumeAllKeysListener" the keys actually end up being typed in the JTextField (although that is what I want).
    But, this behaviour makes me think that JTextField has its Document/model setup as keyListener to itself rather that handling the keyEvent using InputMap/ActionMap. Is this true ?
    Hope I am not confusing the matter !?!
    Thanks in anticipation,
    -sharad

    As mentioned above the correct way to do this is to use a Document to edit any characters as they are typed. The reason for this is that this approach will work whether data is 'typed' or 'pasted' into the text field. Check out this section from the Swing tutorial for more information on Documents and examples:
    http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html#validation
    I do not recommend using a KeyListener, but here is the reason why it doesn't work.
    Three events are generated every time you type a character into a text field:
    1) key pressed
    2) key typed
    3) key released
    The key typed event seems to be the important event for adding text to the text field so you could add code in the keyTyped(..) method:
    if (e.getKeyChar() == ',')
        e.consume();

  • Time Machine Just Doesn't Work Anymore

    I was a happy Time Machine (with Time Capsule) user for months. But it just doesn't work anymore. It takes longer than an hour to do every hourly backup so it is backing up 24 hours a day. It finds hundreds of thousands of files changed every hour and tries to back them up. Finders says only tens of files have been modified all of today. I have tried rebuilding my spotlight indexes, repairing my Time Capsule with Disk Utility and starting over with a brand new backup. But it just backs up hundreds of thousands of files every hour. So I am turning off Time capsule since it is clearly broken. If anyone has any suggestions at all I would welcome them.

    Marcia,
    Consider the following, it might give you some ideas:
    Time Machine performs backups at the file level. If a single bit in a large file is changed, the WHOLE file is backed up again. This is a problem for programs that save data to monolithic virtual disk files that are modified frequently. These include Parallels, VMware Fusion, Aperture vaults, or the databases that Entourage and Thunderbird create. These should be excluded from backup using the Time Machine Preference Exclusion list. You will, however, need to backup these files manually to another external disk.
    One poster observed regarding Photoshop: “If you find yourself working with large files, you may discover that TM is suddenly backing up your scratch disk's temp files. This is useless, find out how to exclude these (I'm not actually sure here). Alternatively, turn off TM whilst you work in Photoshop.” (http://discussions.apple.com/thread.jspa?threadID=1209412)
    If you do a lot of movie editing, unless these files are excluded, expect Time Machine to treat revised versions of a single movie as entirely new files.
    If you frequently download software or video files that you only expect to keep for a short time, consider excluding the folder these are stored in from Time Machine backups.
    If you have recently created a new disk image or burned a DVD, Time Machine will target these files for backup unless they are deleted or excluded from backup.
    Installing new software, upgrading existing software, or updating Mac OS X system software can created major changes in the structure of your directories. Time Machine will backup every file that has changed since the installation.
    Files or folders that are simply moved or renamed are counted as NEW files or folders. If you rename any file or folder, Time Machine will back up the ENTIRE file or folder again no matter how big or small it is.
    George Schreyer describes this behavior: “If you should want to do some massive rearrangement of your disk, Time Machine will interpret the rearranged files as new files and back them up again in their new locations. Just renaming a folder will cause this to happen. This is OK if you've got lots of room on your backup disk. Eventually, Time Machine will thin those backups and the space consumed will be recovered. However, if you really want recover the space in the backup volume immediately, you can. To do this, bring a Finder window to the front and then click the Time Machine icon on the dock. This will activate the Time Machine user interface. Navigate back in time to where the old stuff exists and select it. Then pull down the "action" menu (the gear thing) and select "delete all backups" and the older stuff vanishes.” (http://www.girr.org/mac_stuff/backups.html)
    *TechTool Pro Directory Protection*
    This disk utility feature creates backup copies of your system directories. Obviously these directories are changing all the time. So, depending on how it is configured, these backup files will be changing as well which is interpreted by Time Machine as new data to backup. Excluding the folder these backups are stored in will eliminate this effect.
    *Backups WAY Too Large*
    If an initial full backup or subsequent incremental backup is tens or hundreds of Gigs larger than expected, check to see that all unwanted external hard disks are still excluded from Time Machine backups.
    This includes the Time Machine backup drive ITSELF. Normally, Time Machine is set to exclude itself by default. But on rare occasions it can forget. When your backup begins, Time Machine mounts the backup on your desktop. (For Time Capsule users it appears as a white drive icon labeled something like “Backup of (your computer)”.) If, while it is mounted, it does not show up in the Time Machine Prefs “Do not back up” list, then Time Machine will attempt to back ITSELF up. If it is not listed while the drive is mounted, then you need to add it to the list.
    *FileVault / Boot Camp / iDisk Syncing*
    Note: Leopard has changed the way it deals with FileVault disk images, so it is not necessary to exclude your Home folder if you have FileVault activated. Additionally, Time Machine ignores Boot Camp partitions as the manner in which they are formatted is incompatible. Finally, if you have your iDisk Synced to your desktop, it is not necessary to exclude the disk image file it creates as that has been changed to a sparsebundle as well in Leopard.
    Let us know if any of this helps.
    Cheers!

  • Cannot print with a Samsung ML2160 printer (mono laser) and Pages. Print function doesn't work, only drag and drop in printer's queue

    Hello,
    I just purchased a Samsung ML2160 printer and it doesn't work with nor my Pages program, nor the Preview (to print PDF). No matter the way I tried, the Print function doesn't work and I cannot neither print or even enter the printer preferrences menu! My MacBook Pro has worked before with other printers, but now with the Samsung it doesn't work at all... Though, if I drag and drop a document, jpg, pdf in the printer queue, it prints just fine, but that method gives me absolutely no freedom to the printing... Could it be something from the Computer -> Machintosh HD -> Library -> Printers? Because a friend of mine was recently trying to save me some disk space, and therefore erasing part of the HP printer (to remove the previous printer I owned)...
    If anyone has any idea, that would be much appreciated
    Thank you in advance

    Do the sensible thing, as you say neither Preview nor Pages print, try other programs eg TextEdit. If none of them print then it is a System problem and very likely the printer drivers are AWOL or were never installed.
    Go to Samsung's website and download their software for the Mac:
    http://www.samsung.com/uk/consumer/print-solutions/print-solutions/mono-printers /ML-2160/XEU-support
    http://www.samsung.com/uk/support/model/ML-2160/XEU-downloads
    Peter

  • Numbers 3.2 has changed too much, it doesn't work with my project anymore. How do I revert back to the previous version I was using?

    Numbers 3.2 has changed too much, it doesn't work with my project anymore. 1) The sheet panels used to be on the left hand side and easily reviewable and searchable, but now they are on the top and it's harder to find a specific folder without scrolling (too time consuming), 2) I used to be able to duplicate a folder within my sheet panel window by simply clicking on a folder and hitting Command D, but that doesn't work now so it looks like I'll have to spend even more time to recreate the same tables that used to be easily duplicated, and 3) I can't choose fill colors that matched my project anymore because there are only limited choices available now. And these are only the changes that I'm aware of. I am very disappointed and frustrated. Whatever the motivation was to limit Numbers 3.2, I want the previous version back. How do I revert back to the previous version I was using?

    The sheet panels used to be on the left hand side and easily reviewable and searchable, but now they are on the top and it's harder to find a specific folder without scrolling (too time consuming),
    You can scroll more quickly between sheets if you don't use the left-right triangles, but instead move the cursor up into the bands with the "tabs" and drag right or left.
    Also, if you have a lot if sheets for which you want a quick vertical list, then you can try the following have something like this pop up (showing your sheet names automatically) whenever you hit a keyboard shortcut (in my case shift-command-j):
    This is done via a Jump to Sheet Automator Service (Dropbox download).  To install just doubleclick the .workflow package and (if needed) click 'Download Anyway' in System Preferences > Privacy & Security.
    This will cause a new item to appear in your Numbers > Services menu.  Then, if you want a keyboard shortcut, go here in System Preferences and add one:
    You can rename or remove the service by holding down the option key in Finder and choosing Go > Library > Services. You can also view the AppleScript contaned within the service by opening the .workflow package in Automator.
    This particular service jumps to the first cell of the first table of the sheet you choose from an automatically generated list of all sheets in the current document.
    SG

  • No Compiling Error but doesn't work

    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import java.applet.*;
    public class javacw extends Applet implements KeyListener, Runnable
         Area pandaArea;
         Graphics2D g2d;
         // Providing coordinate control for the Panda
         int pandax=20, panday=50;
         // Animation condition. True = animate, False = static.
         boolean pandabool=false, laidOut=false;
         boolean left;
         boolean right;
         boolean up;
         boolean down;
    Thread animThread;
    Dimension offDimension;          // Defines an offscreen Dimension
    Image offImage;                    // Defines an offscreen Image
    Graphics offGraphics;          // Defines an offscreen Graphics
         Image panda;                    // Defines an Image object for panda
         public void init() {
              // Set the layout of the applet to null
              setLayout(null);
              panda = getImage(getCodeBase(), "panda.gif");
              public void keyTyped(KeyEvent event){}
              public void keyPressed(KeyEvent event)
                   if (event.getKeyCode() == KeyEvent.VK_LEFT) left = true;
                   if (event.getKeyCode() == KeyEvent.VK_RIGHT) right = true;
                   if (event.getKeyCode() == KeyEvent.VK_DOWN) down = true;
                   if (event.getKeyCode() == KeyEvent.VK_UP) up = true;
                   repaint();
              public void keyReleased(KeyEvent e)
                   if (e.getKeyCode() == KeyEvent.VK_LEFT) left = false;
                   if (e.getKeyCode() == KeyEvent.VK_RIGHT) right = false;
                   if (e.getKeyCode() == KeyEvent.VK_UP) up = false;
                   if (e.getKeyCode() == KeyEvent.VK_DOWN) down = false;
                   repaint();
    public void start()
              // Make sure the thread hasn already been created
         if (animThread == null) {
         animThread = new Thread(this, "anim");
         animThread.start();
    public void run() {
              // Create a current thread.
              Thread myThread = Thread.currentThread();
         // As long as the thread is created, keep redrawing the
         // canvas and then pausing for 10 miliseconds.
         while (animThread == myThread) {
                   repaint();
         try {
              Thread.sleep(10);
         } catch (InterruptedException e){}
    public void paint(Graphics g) {
              if (offImage != null) {
              g.drawImage(offImage, 0, 0, null);
         // Overide the update() method
    public void update(Graphics g) {
              Dimension d = getSize();
              // Create the offscreen graphics context
              if ((offGraphics == null)
              || (d.width != offDimension.width)
              || (d.height != offDimension.height)) {
              offDimension = d;
              offImage = createImage(d.width, d.height);
              offGraphics = offImage.getGraphics();
              // Erase the previous image
              offGraphics.setColor(getBackground());
              offGraphics.fillRect(0, 0, d.width, d.height);
              offGraphics.setColor(Color.black);
              paintFrame(offGraphics);               // Paint the frame into the image
              g.drawImage(offImage, 0, 0, null);     // Paint the image onto the screen
    public void paintFrame(Graphics g) {
              Graphics2D g2d = (Graphics2D)g;
              g2d.drawImage(panda, pandax, panday, this);
              if (pandabool) {               // If pandabool==true, animate the panda =)
                   if (pandax>400) pandax=0;
                   if(pandax<0)pandax=400;
    public void stop()
         animThread = null;
              offImage = null;
              offGraphics = null;
    public void destroy(){}
              public void Move ()
                   if (left) {
                        pandax-=10;
                   if (right) {
                        pandax+=10;
                   if (up){
                        panday-=10;
                   if (down){
                        panday+=10;
    i was trying to add the keylistener to makes my pic move and there are no compiling problem but it doesn't work when i press the key
    thx for everyone

    One problem might be your lack of a setVisible( true ). It would be easier to read if you put code tags around your code.

  • OpenAL doesn't work... BF2 O NO O NO!!!!!!!!!!!!!!

    I think my openAL software stuff doesn't work... I can't set X-fi on?Battlefield 2?and when I try to use sound on Eternal Lands, which contains openAL.dll, the game freezes. I have to set the BF2 sound settings to "high" to get the 3-d sound on, but it cause small freezes in sudden sound bursts like the repeated ticks of gunfire or the repeated zt of a helecopter blade, or a lot of people moving or a lot of grass making grass noise, etc, etc,etc. Also, when I try to use the "test" feature of CMSS-3d in gaming mode, the console freezes and the task manager shows it's using up one of my cores.
    Angry consumer part>>>I contacted CRE-A-TIVE for SUPPORT AND THEY SENT ME A EMAIL FULL OF USELESS ARTICLES!!! THE RETURN ADRESS WAS INVAILD for ((SOME))) REASON!!!!<<<End of angry consumer part
    . I got the new drivers, but they did the same thing. This all started when I took it in to frys electro and had my Motherboard changed for a Nforce 680i to a Asus P5K-E/Wi-fi. Maybe they damaged the card?
    Conclusion>>> Anyone else have this problem? Thanks for any help.

    My MAC still can't get mail out.
    I did that (started to set up the MAIL Account) and it couldn't find the
    outgoing mal server again. I called my ISP to make sure their server was
    working. All is well there.They said it could be that some of the MAC
    wireless settings had changed so we gave it the acid test of reality by
    hardwiring the MAC (plugged it into) to the wireless network router.
    I did that (plugged it in) and the MAC proceeded to complete the setting up of the MAIL
    account. All of the inbox stuff is there but not the sentbox stuff. I now
    have an "ON MY MAC item under my mail boxes that I never noticed before. If
    we ever get this problem with getting mail out on the MAC will I ever be
    able to get the outbox contents back?
    At this point I thought all was well. I tried to reply to you on the MAC and
    it still couldn't "find the server". Remember now it is still hardwired.
    The ISP suggested changing the server to smtp.sentex.net. The MAC still did
    not find the out server.
    It shouldn't be a "wireless" issue or a "server spec issue" because this
    ACER is right beside the MAC about 15 feet away from the wireless router and
    is using the same outgoing server. And SAFARI is working as further proof of signal\connection.
    Also the SEND icon in creating an email mode doesn't work now either, so I now can't even test the set up by attempting to sending an email.
    Any suggestions?
    WIN XP is starting to look pretty good compared to this O/S
    Thanks for your patience. I wish I still had mine!
    Bill

  • Urgent! please help: why socket.setSoTimeout(ms) doesn't work precisely

    I wanted to set timeout for the sockets accepted by server as:
    Socket socket = server.accept();
    socket.setSoTimeout(5);
    Since I want the server to process next request (another thread) as soon as read block happened on the current one, I set the timeout to be extremely short. But it doesn't work. I intentionly blocked my testing client and timed my first .read() method from server. 200 ms actually escaped, no timeout happened. What could be the problem?

    You can't really expect processors to be that fine-grained. There are multiple factors:
    1) other apps are running (such as the OS), consuming processor time as well
    2) processor speed
    3) etc.

  • Transient doesn't work ?

    Hello Jaders,
    I've got a problem with serialization of my SystemAgent class. I got the exception
    java.io.NotSerializableException: jacs.core.debug.ACLAppenderPlease see the code below:
    public class SystemAgent extends Agent {
      protected transient Logger logger;
      protected void setup() {
        logger = Logger.getLogger(getLoggerName());
        logger.addAppender(new ACLAppender(this));
    }ACLAppender is non-serilizable, since it extends non-serializable AppenderSkeleton (from log4j project). As you see. ACLAppender have reference to instance of SystemAgent (passed via constructor) but I'm not sure whether this causes Exception.
    Why transient prefix doesn't work with that?
    Regards,
    Maciej

    Please suggest me how can I conclude from stack trace, where that this exception comes from? What kind of tools could help me. I've tried debug the code (step by step) with Eclipse, but it looks like "never ending story":
    Stack trace:
    java.io.NotSerializableException: jacs.core.debug.ACLAppender
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeArray(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
         at java.util.Vector.writeObject(Unknown Source)
         at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
         at jade.util.leap.LinkedList.writeObject(LinkedList.java:226)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
         at java.io.ObjectOutputStream.defaultWriteObject(Unknown Source)
         at jade.core.Agent.writeObject(Agent.java:1666)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
         at java.lang.reflect.Method.invoke(Unknown Source)
         at java.io.ObjectStreamClass.invokeWriteObject(Unknown Source)
         at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
         at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
         at java.io.ObjectOutputStream.writeObject0(Unknown Source)
         at java.io.ObjectOutputStream.writeObject(Unknown Source)
         at jade.core.mobility.AgentMobilityService$CommandSourceSink.
      handleInformMoved(AgentMobilityService.java:300)
         at jade.core.mobility.AgentMobilityService$CommandSourceSink.
      consume(AgentMobilityService.java:184)
         at jade.core.CommandProcessor$SinksFilter.
      accept(CommandProcessor.java:253)
         at jade.core.Filter.filter(Filter.java:91)
         at jade.core.Filter.filter(Filter.java:92)
         at jade.core.Filter.filter(Filter.java:92)
         at jade.core.CommandProcessor.processOutgoing(CommandProcessor.java:216)
         at jade.core.BaseService.submit(BaseService.java:250)
         at jade.core.mobility.
      AgentMobilityService$TransitLifeCycle.informMoved(AgentMobilityService.java:1305)
         at jade.core.mobility.AgentMobilityService$TransitLifeCycle.
      execute(AgentMobilityService.java:1260)
         at jade.core.Agent.run(Agent.java:1379)
         at java.lang.Thread.run(Unknown Source)

  • KeyEvent.consume() problem for BACKSPACE

    Hi!
    I have the following problem - I want to disable the BACKSPACE key input for a JTextArea. I�ve done it like this:
    private class MyKeyAdapter extends KeyAdapter {
    public void keyPressed (KeyEvent e) {
    if (e.getKeyCode()==KeyEvent.VK_BACK_SPACE) e.consume();
    This method works for other keys but why not for BACKSPACE? Checking if the event has been consumed with KeyEvent.isConsumed() returns "true" like it should, but the event still gets processed in JTextArea.
    Thanx in advance,
    bbruno

    Here, try the following with a document filter that filters out VK_DELETE and VK_BACK_SPACE:
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.event.*;
    public class TxtDemo extends JFrame {
       public static void main(String[] args) {
          JFrame F=new TxtDemo("Test Window");
          F.pack();
          F.setVisible(true);
          F.addWindowListener(new WindowAdapter() {
             public void windowClosing(WindowEvent e) {
                System.exit(0);
       TxtDemo(String title) {
          super(title);
          JTextArea textArea = new JTextArea(5, 20);
          DocumentFilter filter = new DocumentFilter() {
             public void insertString(DocumentFilter.FilterBypass fb,int offset, String string, AttributeSet attr) throws BadLocationException {
                super.insertString(fb,offset,string,attr);
             public void remove(DocumentFilter.FilterBypass fb, int offset, int length) {  
                // do nothing
             public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
                super.replace(fb,offset,length,text,attrs);
          ((AbstractDocument) textArea.getDocument()).setDocumentFilter(filter);
          getContentPane().add(textArea);
    }Here is the same version that can be cut-n-paste:
    import javax.swing.*;
    import javax.swing.text.*;
    import java.awt.event.*;
    public class TxtDemo extends JFrame {
    public static void main(String[] args) {
    JFrame F=new TxtDemo("Test Window");
    F.pack();
    F.setVisible(true);
    F.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    TxtDemo(String title) {
    super(title);
    JTextArea textArea = new JTextArea(5, 20);
    DocumentFilter filter = new DocumentFilter() {
    public void insertString(DocumentFilter.FilterBypass fb,int offset, String string, AttributeSet attr) throws BadLocationException {
    super.insertString(fb,offset,string,attr);
    public void remove(DocumentFilter.FilterBypass fb, int offset, int length) {  
    // do nothing
    public void replace(DocumentFilter.FilterBypass fb, int offset, int length, String text, AttributeSet attrs) throws BadLocationException {
    super.replace(fb,offset,length,text,attrs);
    ((AbstractDocument) textArea.getDocument()).setDocumentFilter(filter);
    getContentPane().add(textArea);
    ;o)
    V.V.

  • Generated WSDL doesn't work in Visual Studio

    After an update of SAP we have some problems with our web service (WSDL).
    First of all we created a webservice using SE80. The generated WSDL url mentioned in SE80 doesn't work in visual studio which is in our opinion weird. When we use the url from the SOAMANAGER "Open WSDL document for selected binding" in visual studio we get a little bit further but it still doesn't work. The problem seems to be the "parameter(s)" with or without "s". Does anyone know how we can generated a WSDL with only "parameters"?
    ExampleWSDL:
    <wsdl:message name="ZPIQ_GET_LEERWEGResponse">
    <wsdl:part name="parameter" element="tns:ZPIQ_GET_LEERWEGResponse"/>
    </wsdl:message>
    u2212
    <wsdl:message name="ZPIQ_GET_NATIO">
    <wsdl:part name="parameters" element="tns:ZPIQ_GET_NATIO"/>
    </wsdl:message>
    SAP ECC 6.0
    SAPKA70014
    SAPKB70014
    SAPKW70015

    Hi Ralph,
    In order to consume SAP services in Microsoft Visual Studio .NET, you need to convert WSDL from SAP (Document style) to Microsoft (RPC style) standard. This conversion is transparent to you, if you use [ES Explorer for .NET|https://www.sdn.sap.com/irj/sdn/dotnet?rid=/library/uuid/c0319dc4-d76d-2a10-d19f-e4f4ff315bde].
    Best Regards,
    Rima.

  • My KeyListener doesn´t work, why?

    Hi!
    I am trying to ge my KeyListener working.
    My code is as follows:
    class C extends JPanel
              public C()
                   addMouseListener(new MListener());
                            addKeyListener(new KListener());Furher down in the code I have this:
    class KListener extends KeyAdapter
                public void keyPressed(KeyEvent e)
                       System.out.println(KeyEvent.getKeyText(e.getKeyCode()) + " was pressed");
                public void keyReleased(KeyEvent e)
                     System.out.println(KeyEvent.getKeyText(e.getKeyCode()) + " was released");
           }I do not get any errors when compiling the code but the KeyListener doesn´t work. The mouse listeners work perfekt.
    What´s wrong with my key listener?

    Add your keyListener to the JFrame and it will probably work, the JFrame has the focus when you use your JPanel.
    package Junk;
    import java.awt.Dimension;
    import java.awt.event.KeyAdapter;
    import java.awt.event.KeyEvent;
    import javax.swing.JFrame;
    class Junk extends JFrame {
      Junk(){
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        addKeyListener(new KListener());
        setPreferredSize(new Dimension(256, 256));
        setVisible(true);
      public static void main(String[] args){
        new Junk();
      class KListener extends KeyAdapter {
        public void keyPressed(KeyEvent e) {
                System.out.println(KeyEvent.getKeyText(e.getKeyCode()) + " was pressed");
              public void keyReleased(KeyEvent e) {
             System.out.println(KeyEvent.getKeyText(e.getKeyCode()) + " was released");
    }

  • Asynchronous consumer doesn't consume?

    Can anyone tell my why my message consumer doesn't consume a TextMessage put in a Queue by a MessageDrivenBean?
    Another part of my client successfully sent a message to the MDB, and the MDB put a TextMessage in another Queue (queue\goAdminOut) with this property set on the message:
    key="Selector"
    value="ADCD"
    I know the TextMessage is waiting on the Queue, because I can see it using the servers web-consloe.
    Its just that the message does not trigger the onMessage () method of the Listener I set on the MessageConsumer in my client.
    The MessageConsumer was created with:
    Session.createConsumer(Destination destination, java.lang.String messageSelector)
    Here is a list of the relevant code included below.
    1. Two classes the mimic my client.
    TestConsumerView
    -- A JFrame that stays alive till it is closed.
    TestConsumer
    -- An object that is instantiated as a field in TestConsumerView
    -- It establishes the connection, session and message consumer
    2. The screen print when I run TestConsumerView
    3. A screen print from the JBoss JMX web console confirming that the message is in the queue
    TestConsumerView Codeimport javax.swing.JFrame;
    class TestConsumerView extends JFrame {
      // members
      private static final long    serialVersionUID = 1L;
      private TestConsumer consumer;
      // main ()
      public static void main(String args[]) {
        System.out.println ("** BEGIN: TestConsumerView.main ()");
        System.out.println ("** instantiate TestConsumerView");
        new TestConsumerView();
        System.out.println ("\n** TestConsumerView instantiated");
        System.out.println ("** END:   TestConsumerView.main ()");
      // constructor
      private TestConsumerView () {
        super ();
        System.out.println ("\n**** BEGIN: TestConsumerView.constructor");
        consumer = new TestConsumer ();
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible (true);
        System.out.println ("\n**** END:   TestConsumerView.constructor");
    } TestConsumer Code import javax.swing.JFrame;
    class TestConsumerView extends JFrame {
      // members
      private static final long    serialVersionUID = 1L;
      private TestConsumer consumer;
      // main ()
      public static void main(String args[]) {
        System.out.println ("** BEGIN: TestConsumerView.main ()");
        System.out.println ("** instantiate TestConsumerView");
        new TestConsumerView();
        System.out.println ("\n** TestConsumerView instantiated");
        System.out.println ("** END:   TestConsumerView.main ()");
      // constructor
      private TestConsumerView () {
        super ();
        System.out.println ("\n**** BEGIN: TestConsumerView.constructor");
        consumer = new TestConsumer ();
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible (true);
        System.out.println ("\n**** END:   TestConsumerView.constructor");
    }Screen Output ** BEGIN: TestConsumerView.main ()
    ** instantiate TestConsumerView
    **** BEGIN: TestConsumerView.constructor
    ****** BEGIN: TestConsumer.constructor
    ****** calling connect ()
    ******** BEGIN: TestConsumer.connect ()
    ******** InitialContext Returned
    ******** Connection instantiated
    ******** Session instantiated
    ******** MessageConsumer instantiated with the selector phrase = Selector='ABCD'
    ******** add a MessageListener to consumer
    ********** TCListener.constructor called
    ******** MessageListener added
    ******** Connection started
    ******** END:   TestConsumer.connect ()
    ****** call to connnect () completed
    ****** END:   TestConsumer.constructor
    **** END:   TestConsumerView.constructor
    ** TestConsumerView instantiated
    ** END:   TestConsumerView.main () WEB CONSOLE OUTPUT [SpyTextMessage {
    Header {
       jmsDestination  : QUEUE.goAdminOut
       jmsDeliveryMode : 2
       jmsExpiration   : 0
       jmsPriority     : 4
       jmsMessageID    : ID:9-11218101942431
       jmsTimeStamp    : 1121810194243
       jmsCorrelationID: null
       jmsReplyTo      : null
       jmsType         : null
       jmsRedelivered  : false
       jmsProperties   : {Selector='ABCD'}
       jmsPropReadWrite: false
       msgReadOnly     : true
       producerClientId: ID:9
    Body {
       text            :The DialogPack was received

    Sorry,
    I guess I screwed up and put TestConsumerView code twice.
    Anyway, the missing TestConsumer code is below.
    I am not sure I understand your comment about MDB and a Java GUI client.
    Right now I am testing my app on a local server.
    Ultimately I intend to use a remote server that mediates between two WebStart downloaded Java GUI clients running on independent PCs.
    Kind of a game model with two players.
    Both clients can send ObjectMessages to a server side Queue that is listened to by an MDB (i.e. the object would contain all the data needed to enroll a new player, or to describe a new play by one client to the other).
    The MDB would process the data in the object attached to the Object Message using Entity Beans and any other server side components required, i.e. to add the new member to the database or update the copy ot the game history.
    When done, the MDB would send messages to one or two Queues.
    Queue-1 would be listend to by the client that sent the origianl ObjectMessage letting it know if the object was processed correctly.
    That is why I want to use a selector. There could be multiple pairs of clients being served by the MDB, so I need to attach a selector to the original Object message that the MDB then sets on its response message so the original client can find the MDB response in Queue-1.
    Queue-2 would be listened to by the other client (i.e. to let it know a play has been made). Same concept.
    Right now I am just trying to test the original client cycle, i.e. the original client listening to Queue-1 to see if the MDB succeeded.
    The Object message to MDB and the MDB message to Queue-1 works because I can use the JBoss web-consloe to see the TextMessaage waiing with the correct selector in the correct Queue.
    I just can't seem to write code for an asynchromous consumer in the original client that continuously listens to Queue-1.
    Anyway here is the code.
    TestConsumer CODEimport java.util.Hashtable;
    import javax.jms.JMSException;
    import javax.jms.ConnectionFactory;
    import javax.jms.Connection;
    import javax.jms.Message;
    import javax.jms.MessageConsumer;
    import javax.jms.MessageListener;
    import javax.jms.Destination;
    import javax.jms.Session;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    public class TestConsumer {
      // constructor
      public TestConsumer () {
        super ();
        System.out.println ("\n****** BEGIN: TestConsumer.constructor");
        System.out.println ("****** calling connect ()");
        connect ();
        System.out.println ("\n****** call to connnect () completed");
        System.out.println ("****** END:   TestConsumer.constructor");
      // members
      private final String selector = "Selector='ABCD'";
      private Session session;
      // members - inner class
      private class TCListener implements MessageListener {
        TCListener () {
          super ();
          System.out.println ("\n********** TCListener.constructor called\n");
        public void onMessage (Message msg) {
          try {
            System.out.println ("    ** BEGIN: TestConsumer.Listen.onMessage ()");
            System.out.println ("       Msg property 'Selector'=" + "\"" + msg.getStringProperty ("Selector") + "\"");
          } catch (JMSException e) {
            System.out.println ("       JMSException");
          System.out.println ("    ** END:   TestConsumer.Listen.onMessage ()");
      // methods
      private void connect () {
        System.out.println ("\n******** BEGIN: TestConsumer.connect ()");
        try {
           Hashtable<String, String> env =
             new Hashtable<String, String> ();
           env.put(Context.INITIAL_CONTEXT_FACTORY,
                  "org.jboss.naming.HttpNamingContextFactory");
           env.put(Context.PROVIDER_URL,
                  "http://localhost:8080/invoker/JNDIFactory");
           env.put(Context.URL_PKG_PREFIXES,
                   "org.jboss.naming:org.jnp.interfaces");
          Context jndiContext = new InitialContext(env);
          System.out.println ("******** InitialContext Returned\n");
          ConnectionFactory factory = (ConnectionFactory)
              jndiContext.lookup("HTTPConnectionFactory");
          Connection connection = factory.createConnection();
          System.out.println ("\n******** Connection instantiated");
          session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
          System.out.println ("******** Session instantiated");
          Destination destination = (Destination) jndiContext.lookup("queue/goAdminOut");
          MessageConsumer consumer = session.createConsumer(destination, selector);
          System.out.println ("******** MessageConsumer instantiated with the selector phrase = " + selector);
          System.out.println ("******** add a MessageListener to consumer");
          consumer.setMessageListener (new TCListener ());
          System.out.println ("******** MessageListener added");
          connection.start ();
          System.out.println ("******** Connection started");
        } catch (NamingException e) {
          System.out.println ("******** Naming Exception");
        } catch (JMSException e) {
          System.out.println ("******** JMS Execption");
        System.out.println ("******** END:   TestConsumer.connect ()");
    }

  • In new Mozilla doesn't works scroll through touchpad. Through mouse - all fine. In old version of Firefox all was ok.

    Hi,
    could you check please, why on my PC doesn't works scrolling, using touch pad.

    OK, I am back in town. I tried the first thing you said -
    Try deleting the <hard drive>/Library/Printers/Canon folder, connecting the printer and turning it on, then using Software Update to install the updated Canon drivers.
    Software update had no mention of any Canon drivers, it just wanted to update iTunes.
    I checked the link at http://support.apple.com/kb/HT3669?viewlocale=en_US which shows that this printer needs driver 10.30.3.0, but there are no links on this page to show me where I might find this version.
    So I follow the link to the Canon website, and I'm directed to this page -
    http://www.usa.canon.com/consumer/controller?act=ModelInfoAct&tabact=DownloadDet ailTabAct&fcategoryid=334&modelid=18639&defaultos=snowleopard
    but this one only shows the mp490sosxcp102600ea8-2.dmg driver, which is dated 9/27/09,
    obviously not the latest one.
    I tried to enter Canon 10.30.3.0 driver in a Google search to see if I could find it somewhere else, but the closest thing I could find was for a MP560 printer, which did not work either.

Maybe you are looking for