Midi synthesizer applet working with appletviewer , but no in IE browser

Hi ,
The following code works OK using appletviewer , but not working with IE browser . The user can play notes from C to G , using the corresponding keyboard keys (only when typing small A,B,C,D,E,F or G , a corresponding midi note would be produced) .
When running it using appletviewer , the notes are being heard ;
this isn't the case when running the applet using IE browser (after removing the security warning (of showing active content) - here , the applet simply doesn't respond to the key events .
The code is :
import java.awt.event.*;
import javax.swing.*;
import javax.sound.midi.*;
public class RandomNotes extends JApplet implements KeyListener
     private MidiChannel midiChannel;
     private int note ;
     private long timeWhilePress;
     private long timeAfterPress;
     private int firstTime = 0;
     public void start()
          try
               Synthesizer synthesizer = MidiSystem.getSynthesizer();
                  synthesizer.open();
              midiChannel = synthesizer.getChannels()[0];
          catch(Exception ex)
               ex.printStackTrace();
          addKeyListener(this);
     public void keyPressed(KeyEvent e)
          firstTime++;
          switch (e.getKeyChar())
               case 'c':
                    note = 60;
                    break;
               case 'd':
                    note = 62;
                    break;
               case 'e':
                    note = 64;
                    break;
               case 'f':
                    note = 65;
                    break;
               case 'g':
                    note = 67;
                    break;
               case 'a':
                    note = 69;
                    break;
               case 'b':
                    note = 71;
                    break;
               default:
                    note = -1;
                    break;
          timeWhilePress = System.currentTimeMillis();
          if (firstTime == 1)
               midiChannel.noteOn(note, 127);
     public void keyReleased(KeyEvent e)
          timeAfterPress = System.currentTimeMillis();
         try
               Thread.currentThread().sleep(timeAfterPress - timeWhilePress);
          catch (InterruptedException exception)
               exception.printStackTrace();     
        midiChannel.noteOff(note);
        firstTime = 0;
     public void keyTyped(KeyEvent e)
}Why it runs OK using appletviewer and not under IE browser , and how can I correct the problem please , so under IE browser , the applet should respond to key events ?
Thanks in advance ,
Lior .

The problem is related to the Midi itself , not to the keyPressed event - I've just checked it :
If I add a JOptionPane.showMessageDialog(null,"Lior"); statement
as the first line of the keyPressed method ,
then also when running the applet under IE browser , when clicking on any letter character (eg. "j") , I see the "Lior" message appears on screen . So the problem is not with the keyboard event handling , but something related to the Midi itself .
If you don't mind , I should post this question also in the Java sound forum (unless this is considered a crosspost , then I'll not do that) .
Thanks in advance ,
Lior .

Similar Messages

  • Applet works in appletviewer but not in IE - Applet notinited

    Hi, i have written a simple applet which uses swing components, ie swing labels and buttons. The buttons and labels also have icons with the text. The icons are in a folder called "icons" inside the same folder that the class is in. Everything works fine in the appletviewer, the icons are all displayed correctly, however when i try to open it through Internet Explorer i get this error in the java console window:
    Java(TM) Plug-in: Version 1.4.0
    Using JRE version 1.4.0 Java HotSpot(TM) Client VM
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    p: reload proxy configuration
    q: hide console
    r: reload policy configuration
    s: dump system properties
    t: dump thread list
    x: clear classloader cache
    0-5: set trace level to <n>
    java.security.AccessControlException: access denied (java.io.FilePermission icons/world.jpg read)
         at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)
         at java.security.AccessController.checkPermission(AccessController.java:401)
         at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)
         at java.lang.SecurityManager.checkRead(SecurityManager.java:887)
         at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java:408)
         at sun.awt.SunToolkit.getImage(SunToolkit.java:422)
         at javax.swing.ImageIcon.<init>(ImageIcon.java:81)
         at javax.swing.ImageIcon.<init>(ImageIcon.java:107)
         at atm.init(atm.java:23)
         at sun.applet.AppletPanel.run(AppletPanel.java:341)
         at java.lang.Thread.run(Thread.java:536)
    Can anyone help me with this problem? I desperately need this applet working in the browser and not just the appletviewer.
    Many thanks in advance,
    Adrian

    Hi, i don't think it is a problem with the security settings, the problem definately lies in these lines
    inside the init method:
         Icon worldIcon = new ImageIcon(getDocumentBase(),"icons/world.jpg");
         JLabel myIconLbl = new JLabel("My Icon and Label", worldIcon, SwingConstants.CENTER);     
    add(myIconLbl);
    If i take the ' getDocumentBase() ' part out of the first line, the applet compiles and the worldIcon is correctly displayed in the appletviewer but not in Internet Explorer (the problem i orriginally sited).
    However by leaving the getDocumentBase() line in the code, the applet correctly compiles but does not show the icons at all in either appletviewer or IE!!
    Any suggestions?
    Adrian

  • Applet works on appletviewer but not browser

    Hi,
    I have just started using Java. I'm so new the only program I've tried to compile and run is "Hello World". I'm already having problems running the applet. I'm using Java 2 SDK on Windows 2000. The applet works just fine on appletviewer, but I can't get it to work on Netscape or MS Internet Explorer. What am I missing?

    posting stuff like the error message you get, and a section of the html page might help.

  • Applet works with IE8 but aborts with Firefox 3.6.3

    This link starts an Applet (a funny St.Valentine's one) that works perfect with IE8. Same link does some initial steps from Firefox 3.6.3 but aborts. Looking into Java Console it errors with ... but as I said, it works PERFECT with IE8!!!
    What's the problem with Firefox?
    Of course, Applets are activated in my Firefox:
    Tools/Add-ons/Plugins/JavaPlatform ... 6.0.200.2
    Note: Other Applets of my own work fine, as expected.

    Sorry, but I don't know why my previous post OMMITTED the linkand the error I was providing!
    The link I mentioned was:
    [http://www.chezmaya.com/applet/valentin.htm St.Valentine'Applet]
    and the error I've seen in the Java Console:
    Uncaught exception: string contains an invalid character
    BUT it works with IE8 and aborts with Firefox!

  • Applet works on eclipse but not on reg browser (not inited error)

    Hi everybody,
    I've just made an applet, but I don't know why it can't be shown. I'm working with Eclipse, and when I run the .java file, everything works fine. It even works fine when I specify parameters through the eclipse build file parameter arguments.
    Now I would like this to work by using the appletviewer and my html file. When I do this, the application doesn't work anymore and I get this error: Start applet not inited and shows loading java Applet failed when I scroll over to the java applet box on the browser. (Mozilla)
    I used this code in the html file:
    <html>
    <head>
    <title>MicroToolBus Example Plugin Applet 2 </title>
    </head>
    <body>
    <h1>MicroToolBus Example Plugin Applet 2 </h1>
    <hr>
    <applet code =MicroToolBus.class width=400 height=100>
    <param name="ModelName" value="edu.vt.vbi.pathport.client.plugin.microarray.MicroarrayModel">
         <param name="DataLocation" value="c:/eclipse/workspace/PathPort/xml/samples/mageml/pmml.xml">
    </applet>
    </hr>
    </body>
    </html>
    which is located at
    C:\eclipse\workspace\PathPort\build\edu\vt\vbi\pathport\client\toolbus\MicroToolBus.html
    The MicroToolBus.class file is located in the same directory. What am I doing wrong. I tried putting the class file and the html in the same directory as the actual .java file of the applet, but that didn't seem to work either. Thanks in advance; your help and suggestions are much appreciated,

    What am I doing wrong?Your getting caught in the Sun/Microsoft war. Numerous casualties. For rehab, see:
    http://www.MartinRinehart.com
    Click "Articles", "Launching Applets".
    Warning: make a big mug of java before you start. This is not trivial stuff.

  • I upgraded for Firefox 4 and now my simplePass identity protection (biometric scanner) on my laptop will not work. WHY? It still works with IE but I don't use IE.

    I upgraded for Firefox 4 and now my HP SimplePass Identity Protection (biometric scanner) on my laptop will not work. WHY? It still works with IE but I don't use IE. It worked with the previous Firefox version but now when I use the internet, it doesn't even acknowledge I have the scanner. When I run my finger over it, it opens the settings panel but does not allow use of the already saved information or allow new information to be entered. I need this corrected. Any suggestions?

    I asked this same question, and just received a response:
    "Thank you for contacting DigitalPersona. There will be no update releases
    for DigitalPersona Personal in the future. There will be no updates for
    Firefox 4 nor Internet Explorer 9. IF they work they work, if they do
    not work with DPPersonal, then you will have to decide to either keep
    DPPersonal and forgo Firefox 4 or IE 9, or vice versa. DigitalPersona
    is leaving the consumer market and is focusing on business applications.
    In fact, DigitalPersona Personal will not longer be supported after
    Mid-April of this year.
    We apologize for any inconvenience this might cause. Sincerely, Tech Team "
    In other words, there will be NO update.

  • Will a Midi to usb work with a korg triton pro x?

    I'm considering buying a korg triton pro x 88 key. but I want to use garageband lessons to learn to get better on the piano, so will a Midi to usb work with it?

    JourneyMan24 wrote:
    I'm considering buying a korg triton pro x 88 key [...] will a Midi to usb work with it?
    MIDI is MIDI.
    if the keyboard has MIDI-OUT, and the MIDI interface you buy is Mac compatible, it will work

  • The "new" hotmail no longer works with safari, but works with firefox. Hmm.

    The "new" hotmail no longer works with safari, but works with firefox. Hmm. i find this very convenient being a microsoft product. anybody else wonder why this new version happens to not be safari compatible? does anybody know if it works on the PC version of safari? if not, i find this to be a blatant move on microsofts part to bias the safari browser (especially since its basicly new on the window platform). forcing safari/hotmail users to "have" to use another browser to access their hotmail accounts.

    I have been successfully using Hotmail and Gmail with Safari for a long time. For roughly the past month, that relationship is rocky at best. At times, one of the following actions suddenly opens Hotmail, but it is a short-lived solution:
    (a) Hotmail directly
    (b) Hotmail Home>Hotmail
    (c) Sign up to Windows Hotmail
    (d) Deletion of prescribed cookies, resetting, etc. - made no difference
    Both Firefox and Opera work fine with Hotmail - especially Opera is very fast.
    In addition, Safari and Gmail does not work with Attachments, but otherwise Gmail is OK.
    I suspect I have to wait for a Safari fix because in my case I do not wish to abandon Hotmail, and Safari is a given. I would think that Safari would want to stay competitive with the two biggies, Hotmail and Gmail, which must have large numbers of users.
    I certainly would appreciate any other suggested fixes.

  • My i message seems that is working with everyone but with a particular phone is not?, My i message seems that is working with everyone but with a particular phone is not?

    My I message is working with everyone BUT with one phone, Same thong happen with this other phone i message works with everyone else but with me What did i did?

    Actually she does,  her i message is working with everyine else but me, and viceversa

  • Strange on - Wake on LAN (WOL) works with Win2K3, but not Windows 7

    Hi,
    I have a PC that I originally had Windows 2003 on.  With Win2K3, I can send a wakeonlan (magic) packet (WOL) and get it to power on remotely from my home network/LAN.
    I just installed Windows 7 Ultimate 64-bit, in a dual-boot configuration, i.e., so I can boot the machine to either Windows 7 Ultimate 64-bit or Win2K3.
    As mentioned, I can power the machine up remotely (from my home network/LAN), but if I've LAST booted into Win7, then shutdown, it doesn't respond to the WOL packet.
    I've confirmed that if I boot into Win2K3, then shutdown, the WOL works fine.
    I have another PC that has both Win2K3 and Windows 7 (also dual boot), and that works fine with WOL.
    One difference between the one that doesn't work vs. the one that works is that the one that works is a machine that I just built a couple of weeks ago, which uses an MSI 880gm-E43 motherboard.
    The one that doesn't work also has an MSI motherboard, but it's an older one, an MSI K9NBPM2-FID.
    I've cross-checked the various Windows power management settings between the one that works, and the one that doesn't work, but I just can't get WOL to work with Win7 on that older machine.  I've even turned the Windows Firewall off completely on the machine where WOL isn't working, but no matter what I've tried thus far, no joy :(...
    The only thing that I can think of is that the network card driver (it's the MS one, from the Win7 distribution) might not work with WOL, but I've checked, and it's the latest driver from MS (Nvidia Nforce Networking Controller - 10/17/2008 - 1.0.1.211), and MSI doesn't have a specific Win7 64-bit driver for this motherboard.
    So, I was wondering if anyone has any ideas about this?
    Is there some registry setting or something that might allow WOL to work?
    Thanks in advance,
    Jim

    Hi,
    Unbelievable!
    Just for the record, I got WOL working with the older machine, JUST after I posted the original msg.
    Here's what I did:
    - I was in Device Manager, and did Update Driver, but
    - I selected to let me choose, and then I checked the "Show Compatible devices" checkbox
    Then, a 2nd, older (10/6/2006 - 6.2.0.127) driver appeared, so I figured, "what the heck?" and tried that.  I then shut the machine down, and sent a WOL packet to it, and kind of forgot about it (machines in a different room), but a few minutes later "bing!", the machine had powered up and booted into Win7!!
    Anyway, as I said, for the record, and hope that this helps someone in the future.
    Jim

  • My bank id works with IE but not in Firefox, even if I run without extensions. What is the problem?

    My bank id works with IE but not in Firefox, even if I run without extensions. What is the problem?

    Make sure you are using the correct user name / password.
    https://support.mozilla.org/en-US/kb/firefox-cant-load-websites-other-browsers-can
    https://support.mozilla.org/en-US/kb/secure-connection-failed-error-message

  • XPath query works with CLOB but not with object relational

    hi all
    i have the following queries,the XQuery work with all, but XPath queries work with XMLType CLOB and Binary XML, but they do not work with XMLType as Object relational,
    select extract (object_value,'movies/directorfilms/films/film [studios/studio = "Gaumont"]')
    from xorm;
    select extract (object_value,'movies/directorfilms[director/dirname = "L.Cohen"]/films/film[position()=2]/t')
    from xorm;
    they shows this message
    ORA-00932: inconsistent datatypes: expectd SYSTEM.name683_COLL got CHAR
    thanks

    Hi Marco
    fisrt here is my RO
    BEGIN
    DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL=>'http://......../ORMovies.xsd',
    SCHEMADOC=>bfilename('DB','Movies.xsd'),
    LOCAL =>false,
    GENTYPES=>true,
    GENTABLES=>FALSE,
    CSID=>nls_charset_id('AL32UTF8'));
    END;
    create table XORM of xmltype
    xmltype store as object relational
    XMLSCHEMA "http://......../ORMovies.xsd"
    ELEMENT "movies";
    INSERT INTO XORM
    VALUES(XMLType(BFILENAME('DB','ORMovies.xml'),nls_charset_id('AL32UTF8')));
    here the XQuery format that work fine with the OR
    A/D
    select XMLQuery ('for $a in movies/directorfilms/films/film
              where $a/studios/studio = "Gaumont"
              return $a'
         passing object_value
         returning CONTENT)"TitleX"
    from xorm;
    child element query
    select XMLQuery ('for $a in movies/directorfilms/director[dirname = "Feyder"]
              let $b:=$a/../films/film[position()=2]
              return $b/t'
         passing object_value
         returning CONTENT)"TitleX"
    from xorm;
    here is the XPath format which doesn't work
    select extract (object_value,'movies/directorfilms/films/film [studios/studio = "Gaumont"]')
    from xorm;
    select extract (object_value,'movies/directorfilms[director/dirname = "Feyder"]/films/film[position()=2]/t')
    from xorm;
    by the way all queries work fine with the CLOB or Binary XML
    many thanx Marco

  • Apple says  Reminders works with Outlook, but I can't find where the lists are displayed in Office or Outlook  once they are synced.

    Apple says  Reminders works with Outlook, but I can't find where the lists are displayed in Office or Outlook  once they are synced. Any suggestions?

    I'll guess you've already discovered the answer to this, but just in case:
    Reminders works with Outlook tasks by syncing with iCloud, or through Exchange. You can't sync iOS Reminders with Outlook Tasks via USB/iTunes (like you can do with Notes, Calendar, Contacts).
    So the marketing material on Reminders is a little misleading in that it's not specific enough -- there is no syncing without one of those intermediary systems mentioned above.
    On a side note, syncing Tasks/Reminders via iCloud is not very good in my opinion:
    Requires that you sync to the cloud, even if you have no other use for storing personal data in the cloud.
    Requires that the iCloud Control Panel be installed on your PC (not sure about Mac).
    After syncing, you'll find new Calendar and Task groups called "iCloud" have been created in Outlook. The calendar groups appear to be created even if you're only syncing Tasks/Remminders (not sure why).
    Reminders are stored in the new group (noted above) called "iCloud" rather than in your default Tasks group. This seems to me to be a sort of "parallel" sync, rather than a true sync with Outlook. There are oter implications of your synced tasks being in the new group that I won't go into here, but you can search the interwebs to learn more.
    In my own case, I tried iCloud syncing, decided that I didn't like it for the reasons stated above, and then uninstalled (Control Panel and new Outlook groups) with no apparent ill effects.
    Though I don't guarantee you'll have the same results, it might be worth a try to see if it suits your purposes.

  • Airplay works with Remote but cuts out for every other App

    Remote works perfectly fine but whenever I try another AirPlay app it cuts in and out.  Driving me crazy. I have att wifi with an airport express.  Any ideas?  Why would AirPlay work with Remote but fail with every other app?

    Remote does not use AirPlay.

  • I bought the external DVD player/burner for my Macbook.  I tried using it with my Dell laptop but it will not work.  Is it not configured to work with anything but apple operating systems?

    I bought the external DVD player/burner for my Macbook.  I tried using it with my Dell laptop but it will not work.  Is it not configured to work with anything but apple operating systems?

    If you purchased the Apple USB SuperDrive, it will only work with select Apple devices. It won't work, for example, on my Late 2011 model that has a SuperDrive built-in, but it will work with an Air, Retina model, new 'drive-less' iMacs, etc.
    As far as I know, though, you can only hack the drive to work with some other Apple devices, but not with Windows PCs. Which is a shame as other, less expensive DVD/CD devices will work with just about any machine.
    Sorry,
    Clinton

Maybe you are looking for

  • CCM Catalog Mass upload problem

    Dear Experts, Could you please help me to find an answer to the below issue? We are doing a mass catalog upload in CCM 2.0 => we are uploading our CSV file as follows: Supplier ID A => Supplier name A =>  Item details A Supplier ID B => Supplier name

  • Nokia C7 sideways

    Hi, I've been wondering is there any way to make my C7 display change direction when the phone is turned right? Or even better - the navigation and menu keys on the screen to be moved on the left. It would be easier for me, since I mostly use my left

  • Biztalk XSLT

    I am new to use XSLT. i have a requirement where i have to create a node in output schema. my input schema is as below   <?xml version="1.0" encoding="utf-16" ?> - <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://XSLTt.Sch

  • Can you show different applications in different Dialog instances?

    Hi, We have a requirement but I don´t know if it is possible. We have a Portal installation with One CI and 5 DI´s, let´s say that the requirement is to show in CI and DI(1) two applications, in DI(2) and DI(3) three applications different from the o

  • Property Chooser dialog from Add Correlation Set dialog Doesn't Expand

    We are using Windows XP with NetBeans IDE 6.0 Preview (M9, build 070502). We are creating a BPEL workflow. We want to create a correlation set. 1. In the Navigator, we right clicked on Correlation Sets, and and chose "Add Correlation Set ..." from th