*** Funny (Buffered)InputStream behavior ****

Hi,
could anyone give me a hint regarding the problem I have in the following code... I have a class that calls a factory (Manager) and passes to it a FileInputStream, which is received in Manager as an InputStream. Manager on its turn encapsulates this stream in a BufferedInputStream and constructs a SamplePlayer, which has an instance variable that points to this BufferedinputStream for posterior use but when I use it in the method javax.sound.sampled.MidiSystem.getSequence(InputStream stream) I get the following Exception thrown:
=========================
javax.sound.midi.InvalidMidiDataException: could not get sequence from input stream
     at javax.sound.midi.MidiSystem.getSequence(MidiSystem.java:766)
     at org.me4se.impl.java2.media.SamplePlayer.prefetch(SamplePlayer.java:241)
     at testMIDletForm.playMedia(testMIDletForm.java:108)
     at testMIDletForm.commandAction(testMIDletForm.java:58)
     at javax.microedition.lcdui.Displayable.handleCommand(Displayable.java:174)
     at javax.microedition.lcdui.CommandList.commandAction(CommandList.java:44)
     at javax.microedition.lcdui.Displayable.handleCommand(Displayable.java:174)
     at javax.microedition.lcdui.List$1.actionPerformed(List.java:52)
     at javax.microedition.lcdui.ScmDeviceLabel.action(ScmDeviceLabel.java:54)
     at javax.microedition.lcdui.ScmDeviceLabel.mouseClicked(ScmDeviceLabel.java:104)
     at org.me4se.scm.ScmContainer.mouseClicked(ScmContainer.java:187)
     at org.me4se.scm.ScmContainer.mouseClicked(ScmContainer.java:187)
     at org.me4se.scm.ScmContainer.mouseClicked(ScmContainer.java:187)
     at org.me4se.scm.ScmContainer.mouseClicked(ScmContainer.java:187)
     at org.me4se.scm.ScmWrapper.mouseClicked(ScmWrapper.java:226)
     at java.awt.Component.processMouseEvent(Component.java:5491)
     at java.awt.Component.processEvent(Component.java:5253)
     at java.awt.Component.dispatchEventImpl(Component.java:3955)
     at java.awt.Component.dispatchEvent(Component.java:3803)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "Thread-7" java.lang.IllegalStateException: Sequencer is not open
     at org.tritonus.share.midi.TSequencer.checkOpen(TSequencer.java:295)
     at org.tritonus.share.midi.TSequencer.start(TSequencer.java:233)
     at org.me4se.impl.java2.media.SamplePlayer.run(SamplePlayer.java:406)
     at java.lang.Thread.run(Thread.java:595)
=====================================================
Here is the code excerpt:
=====================================================
Manager (builds a SamplePlayer):
BufferedInputStream bis = new BufferedInputStream(stream);
aff = AudioSystem.getAudioFileFormat(bis);
strType = aff.getType().toString();
mff = MidiSystem.getMidiFileFormat(bis); --> First use of BufferedInputStream OK
SamplePlayer(bis, mff, aff, strType);
In SamplePlayer:
BufferedInputStream bufMediaStream;
this.bufMediaStream = bis;
public void prefetch() throws MediaException {
this.bufMediaStream.reset();
playSequence = MidiSystem.getSequence(bufMediaStream); => Exception thrown here!
sequencer.open();
sequencer.setSequence(playSequence);
class 3 (uses SamplePlayer):
BufferedInputStream bfis = null;
fis = new java.io.FileInputStream("C:/eclipse/workspace/smtk-gdse-demo/filesystem/0/futureal.mp3");
bfis = new BufferedInputStream(fis);
testPlayer = Manager.createPlayer(fis, null); --> Calls Manager to create player
testPlayer.realize();
testPlayer.prefetch(); ---> Calls Player.prefetch()
==================
Thanks...!

I get the FileInputStream here (this is a test class):
try {
               fis = new java.io.FileInputStream(
                         "C:/eclipse/workspace/smtk-gdse-demo/filesystem/0/ogg.ogg");
          } catch (java.io.FileNotFoundException fnfe) {
               fnfe.printStackTrace();
          try {
               if (fis != null) {
                    this.append("Opening audio file...");
                    //bfis = new BufferedInputStream(fis);
                    testPlayer = Manager.createPlayer(fis, null);As you can see, the stream is passed to the following class:
public static Player createPlayer(InputStream stream, String type)
    throws IOException, MediaException {
       return managerImpl.createPlayer(stream, type);
    }And passed forward to the ManagerImpl class where the BufferedInputStream is created:
public Player createPlayer(InputStream stream, String type)
               throws IOException, MediaException {
          String strType = "";
          AudioFileFormat aff = null;
          MidiFileFormat mff = null;
          BufferedInputStream bis = new BufferedInputStream(stream);
          // Guessing the type when its null:
          if (type == null) {
               try {
                    // Sampled audio:
                    aff = AudioSystem.getAudioFileFormat(bis);
                    strType = aff.getType().toString();
               } catch (UnsupportedAudioFileException uafe) {Then, on the test class, after the player is created, I have the following code:
if (testPlayer != null) {
               try {
                    this.append("Playing back file...");
                    testPlayer.realize();
                    testPlayer.prefetch();
                    testPlayer.start();
               } catch (MediaException me) {And in the player implementation, in the prefetch() we have:
public void prefetch() throws MediaException {
          if (state != REALIZED)
               throw new IllegalStateException();
          if (media.equals("audio/midi")) {
               try {
                    System.out.println("bytes: " + bufMediaStream.available());
                    playSequence = MidiSystem.getSequence(bufMediaStream);And in the last code line above I get the exception (playSequence attribution)...
The player constructor is the following:
public SamplePlayer(BufferedInputStream bis, String type)
               throws IOException, MediaException {
          if (type.equals("MIDI")) {
               media = "audio/midi";
          } else {
               media = "audio/sampled";
               try {
                    ais = AudioSystem.getAudioInputStream(bis);
               } catch (UnsupportedAudioFileException uafe) {
                    throw new MediaException(uafe.toString());
          String MIMEType = normalizeType(type);
          this.type = MIMEType;
          this.bufMediaStream = bis;
          state = UNREALIZED;
     }

Similar Messages

  • How do I fix this 'funny' JavaScript/Ajax behavior?

    Hello all!
    I have this kind of funny problem, or, well, a funny result...
    The problem is almost solved tho, but it's just this strange behavior that I can't solve.
    You can see what I mean here:
    http://apex.oracle.com/pls/apex/f?p=9949:101:1370355978553401
    Username: visitor
    Password: visitor
    Login first, then edit the URL to go to page 24 (or just click on "Web Platform", then in the submenu click on "Meals and templates", and then in the custom menu on the left click on "Show templates".
    If you have done that, click on any of the two links in the report.
    You'll see that suddenly, the whole page seems to be shown inside another region (the region named "Menu2", underneath the normal menu region).
    It's like... A page within a page. Pageception (Inception... Pageception... Get it?).
    Now, all this happens WITHOUT refreshing. Yes, I want this to be dynamic. My question is:
    How do I change my code in such a way, that it does NOT display the whole page 24 inside that menu2 region? Because I want to display a popup, not a page within a page...
    My code for doing so is in my Page Attributes. In the JavaScript tab, I have the following code for the popup, and in it you will find the code to get these values in the page items as well:
    $( function(){
      $('#ModalForm').dialog(
         modal: true,
         autoOpen: false,
         width: 500,
         height: 350,
         buttons:{ Calculate: function(){calculateTotal();},
                   Close: function(){closeForm();}        
    function openForm(pFoodTemplateId, pMealTypeId)
    var getone = new htmldb_Get('shiny',&APP_ID., null, 24); // initialize get
    getone.add('P24_TEMPLATEID', pFoodTemplateId);
    getone.add('P24_MEALID', pMealTypeId);
    gReturn = getone.get();
    getone = null;
    $('#ModalForm').dialog('open');
    function closeForm()
    { $('#ModalForm').dialog('close');}
    $(document).ready(function()
        {$('a.temppop').click(function() {openForm();});
    });"Shiny" is the name of the ID of my "menu2" region.
    In case I'm not clear (which I probably am, since I'm in a rush):
    I have 2 page items that get the value of the selected row's foodtemplateid and mealtypeid. The column link URL from my report is:
    javascript: openForm(#FOODTEMPLATEID#, #MEALTYPEID#); So, in a nutshell, item :P24_TEMPLATEID gets the value of the foodtemplateid that corresponds to the row you selected, and item :P24_MEALID gets the value of the mealtypeid that corresponds to the row you selected.
    Thank you for your time. I really appreciate it.
    Apex version: 4.1.1.00.23

    Hi,
    Maybe JavaScript should be something like this
    function openForm(pFoodTemplateId, pMealTypeId){
    $("#P24_TEMPLATEID").text(pFoodTemplateId);
    $("#P24_MEALID").text(pMealTypeId);
    var getone = new htmldb_Get(null, &APP_ID., "APPLICATION_PROCESS=DUMMY", &APP_PAGE_ID.);
    getone.add("P24_TEMPLATEID", pFoodTemplateId);
    getone.add("P24_MEALID", pMealTypeId);
    gReturn = getone.get();
    getone = null;
    $("#ModalForm").dialog("open");
    }Or
    function openForm(pFoodTemplateId, pMealTypeId){
    $s("P24_TEMPLATEID", pFoodTemplateId);
    $s("P24_MEALID", pMealTypeId);
    var getone = new htmldb_Get(null,&APP_ID.,"APPLICATION_PROCESS=DUMMY",&APP_PAGE_ID.);
    getone.add("P24_TEMPLATEID", pFoodTemplateId);
    getone.add("P24_MEALID", pMealTypeId);
    gReturn = getone.get();
    getone = null;
    $("#ModalForm").dialog("open");
    }Regards,
    Jari
    My Blog: http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0
    Twitter: http://www.twitter.com/jariolai
    Edited by: jarola on Apr 19, 2012 3:56 PM

  • Copies of InputStream

    Hi All,
    I need to know whether we can copy a stream object. e.g.
    InputStream is = new inputStream();
    Now can I get a copy of this 'is' object. If I do InputStream is_second = is This would rather set the reference but I need a copy
    I don't want to read the whole stream and write it to other stream as it
    would set the first stream empty. I can't use mark and reset as they are not supported in input Stream. I have tried using Bufferent InputStream and used mark and reset functions but have thrown exceptions as 'invalid mark' so I need a way of using the same inputstream
    Regards
    Wahaj

    Seems like there is no easy solution to it..
    Currently the solution is that If I have an FileinputStream (call it MainInputStream) then I need to created another FileInputStream by calling FileInputStream's constructor.
    Creating another InputStream on a File seems not a big deal but consider scenarios when you have a large data structure stored in a file. You read the header and reach a point where data starts, you get the inputstream for that and start reading data, Fine but the next time you require to read it you need to create the MainInputStream, either skip the header if you know the size or read it till you reach the actuall data, create an inputstream on actuall data and then process it. A really good design would be to be able to get multiple inputStream on the same actauall data. One can design a function which can parse the headers and return the inputstream on actuall data but its better to have a functionality which can easily replicate inputStreams.. Another proposed solution can be to copy the inputstreams' data some where so in later usage no header parsing is involved but again either one has to store it in memory or hard disk which can be costly if data is huge say in GBs

  • My Xserve does not wake up every Saturday from a cold start / cold boot up.

    Hello, everyone,
    This is my first time using this Apple Discussions Forum here and so hope any expert out there who can solve my problem, I'd deeply appreciated. Basically the problem is like this.
    I configured Xserve to
    wake up 8:50 am wake up every morning.
    shut down system 1:00 am every morning.
    There are two places to be configured here:
    1. System Preferences' Energy Saver
    2. Workgroup Manager>Computer List>Preferences> Schedules>Mac OS X Server.
    The time schedules in those two places are ensured to be at the same setting.
    (does anyone know which is the main one?)
    Furthermore,
    I have a clock timer set to 2:00 am to shut down the main power supply to the Xserve. And so,
    Power Supply timer provides power to Xserve:
    8:40 am every morning (before scheduled Xserve waking up time, 8:50 am)
    Power supply cut down the power to Xserve:
    2:00 am every morning (after scheduled Xserve shutting down time, 1:00 am)
    Why am I doing this? Because I think it is good for Xserve's power supply fan. If I let Xserve's power supply run 24/7 for years, the motor is wearing down soon. It also saves some energy for me.
    Normally the power supply would first provides the power to Xserve before Xserve would boot up as scheduled.
    Now, this setting works pretty well for me for months until recently.
    My Xserve will not boot up every Saturday morning as scheduled. I cannot figure out why it does this weird behavior.
    I tried to search forums and google many many places, and find no solution.
    Here are a list of things I have tried:
    I changed 2 new PRAM battery twice in one month.
    I have tried to reset SMC.
    I have tried to reset PRAM.
    I tried to reset PRAM before SMC reset. I also tried to reset SMC before PRAM reset.
    Worse yet, on Saturday morning, Xserve is like in a deep coma, I tried to remotely boot it up by LOM, it does not even respond to my LOM waking up call. It is like a naughty kid refusing to wake up in the Saturday morning. The only way to wake it up is that I I have to take a long walk and physically go to my Xserve and hold the power button for 5 seconds and press it again and so it wakes up. Note that if I just press the power button once, it does not boot up neither. Why?
    Then the next day, it is normal again for another 6 days until next Saturday. I could not figure out why it does this. Why just Saturday? Why not Sunday or any other day between Monday to Friday?
    Funny and strange behavior.
    The problem is periodic and so I believe it has something to do with the software and/or the PRAM caching the alarm time, which may influence the SMC setting.
    Note: the Apple website says SMC controls the waking time while Apple manual also says PRAM is responsible for alarm clock.
    I would normally
    shut down system
    unplug the cable
    hold the power button for 5 seconds and let it go
    plug back the power cable.
    Xserve should either boot up by itself or stay cold for me to boot up.
    note: the manual just say unplug the cable for 5 sec but did not say hold the power button for 5 second, and I think that is wrong; you have indeed have to hold the power button for 5 seconds as the Apple website said. Otherwise when I cut down power supply every day, my SMC is reset by itself every day.
    I have a voltage regulator before my Xserve's power supply and so the voltage is very stable.
    Any Xserve experts out there has the same problem like I do??

    Hi, MrHoffman , I couldn't agree more with your view point. Xserve not only reacts poorly to sudden power shortage, its HDDs may also get hurt during sudden power removal. Therefore, I was extremely careful when resetting SMC. Bad SMC procedure can hurt HDD.
    MrHoffman , my problem is not totally solved and you knew I will come back, right? I do accidentally find your blog. Is the site yours?
    http://labs.hoffmanlabs.com/node/976
    Your blog and threads from here has inspired me to investigate in the direction on LOM issue. Thank you.
    http://discussions.apple.com/thread.jspa?messageID=11911509
    http://discussions.info.apple.com/message.jspa?messageID=11902981
    http://discussions.apple.com/thread.jspa?messageID=11255905&#11255905
    I've come to narrow down the problem and suspect the root cause is LOM bug. Basically this is what happens in the last 4 days.
    After nearly 3 weeks of monitoring my Xserve, it was running perfectly normal until 4 days ago. Suddenly, my Xserve fails to wake up for 4 days in a row. I almost made it---a perfect run for 1 month without ever having to reset SMC once! This time, the failed waking-up event took place during normal weekdays. So it is still a mystery to me that why my Xserve previously fails to wake up only on Saturday (perhaps, hackers prefer Saturday because that's when they are free?---just kidding). However, at least I now know the problem can take place at anytime.
    Maybe I should first list my Xserve's specification.
    Xserve Late 2006 Model
    2.0 GHz Dual-Core Intel Xeon
    8G RAM
    Mac OS X Leopard Server 10.5.8 (Build 9L34)
    Boot ROM: XS11.0080.B01
    LOM version: 1.2.8
    I am only using en0 for both LAN and LOM.
    So since I was not able to wake up my Xserve remotely by LOM, it is intuitive to check Server Monitor on Xserve side.
    On my Xserve side, I had
    Name: Nothing (it was localhost)
    IP Address: 127.0.0.1
    Status Summary: Software is not installed properly on server.
    At this point, I was wondering where did my Status Summary go? So as an incentive move, I delete the 127.0.0.1 from Server Monitor list and go to >Server Monitor>Server>Configure Local Machine, trying to re-add the localhost server back to Server Monitor list. Then it is when all of the troubles occur.
    The Server Monitor simply hangs there. When check Finder>Force Quit Applications, I see Server Monitor (not responding).
    So I was questioning myself that if this failed waking-up event is a software issue or a hardware sensor issue. Before answering to this question, as a good habit, let me post my log file.
    Jul 31 13:27:06 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:27:36: --- last message repeated 4 times ---
    Jul 31 13:27:40 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:28:10: --- last message repeated 4 times ---
    Jul 31 13:28:15 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:28:45: --- last message repeated 4 times ---
    Jul 31 13:28:49 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:29:19: --- last message repeated 4 times ---
    Jul 31 13:29:23 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:29:53: --- last message repeated 4 times ---
    Jul 31 13:29:58 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:30:21: --- last message repeated 3 times ---
    Jul 31 13:30:21 xserve01 /usr/sbin/spindump[2056]: process 2006 is being monitored
    Jul 31 13:30:23 xserve01 /usr/sbin/spindump[2056]: process 2006 is being force quit
    Jul 31 13:30:26 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:30:29 xserve01 /usr/sbin/spindump[2056]: process 2006 is being no longer being monitored
    Jul 31 13:30:33 xserve01 kernel[0]: AppleKCS::waitForIBF timed out!
    Jul 31 13:30:32 xserve01 com.apple.launchd[250] ([0x0-0x27027].com.apple.servermonitor[2006]): Exited: Killed
    Hardly can I find any reference about AppleKCS::waitForIBF timed out! on Google. So any senior Apple Xserve engineer please helps!

  • Aynchronous and Synchronous communication TCP socket

    Hi All,
    I have written a client/server test application to test the performance of the java socket library. I tested the application in two scenarios,
    1) Asynchronous communication between client and server, client sends data(packet size is 500bytes) without waiting for the server response. I tried to upload 1mb file. The time took was 1.5mb/sec which is reasonable.
    2) Synchronous communication between client and server, client sends data (again, packet size is 500bytes) and waits for the server response (all server responds is OK (1 byte data)). The amazing thing in this test was the performance went down drastically!!! it came down to 5-10kb/sec, which is unbelievably nonsense or I am doing something nonsense.
    code snippet (server side)
    //reading from the socket (tried both buffered and non-buffered )
    inputstream = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
    //writing to the outputstream of the socket (server side)
    outstream = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream))
    //then flush the data, in case
    client side code is very simple,
    while(not EOF)
    outputstream.write(buffer); //buffer size is 500bytes, as I mentioned above
    if(synchronous)
    wait for server response, otherwise don't
    I don't know why in case of synchronous communication it should bring down the speed so much, may be I am using wrong java classes or java sucks!
    I would greatly appreciate any help on this.
    Platform used: JDK 1.3.1, WIN2K.

    I have to break it up because that's how it's done in the real application. The test application that I have written is just part of the product that I am working on.
    To give you the background, we have C++ product where we are porting server side of the whole product to java.
    The client(which is written in c++) sends data(which is basically attributes), of size 500bytes in every request. The no. of request depends on how big the model(3D Model) is. In case of very huge models (will have MBs of attributes) the client takes long time to send all the attributes, which is the case with java server (client still in c++). But the in case c++ server it doesn't make any difference, the data transfer rate is same no matter how big the model is.
    I know if I increase the size of the packet I will get higher performance, but unfortunately I can't do that. That's how the client is designed to do it.
    thanks,
    Ganesh

  • Access Denied to windowClosing

    Hi,
    I have written a Java application that runs perfectly well under windows XP
    i then tried to compile it using javac at the command prompt on windows98 and got an access denied: windowClosing error.
    Any ideas as to how to fix?
    will provide more information if needed.
    Many Thanks

    and the code is:
    import javax.swing.*;
    import javax.swing.ImageIcon;
    import java.awt.*;
    import java.awt.event.*;
    import java.sql.*;
    import java.util.ArrayList;
    import java.io.*;
    * Main GUI Window
    * For TimeCost
    * Created:
    * Alex Kilgour
    * 2004
    public class gui extends JFrame implements ActionListener, HomeEventListener {
    // INSTANCE VARIABLES
         JPanel buttonPanel = new JPanel();
         GridBagLayout gridbag = new GridBagLayout();
         GridBagConstraints c = new GridBagConstraints();
         JScrollPane main;
         String password;
         newRecords newrec;
         home homeoptions;
         createClientRecord createCR;
         createJobRecord createJR;
         enterFeeAccounts enterFA;
         enterSettlement enterS;
         enterTimesheet enterTS;
         enterDisbursement enterD;
         chargeTime chargeT;
         chargeDisbursements chargeD;
         staff staffFrame;
         changeExisting changeExist;
         amendTimeCost amend;
         Container cont;
         JButton ok, cancel, menu, exit, staff, print, amendTC, changePass;
         String currentView;
         String url = "jdbc:odbc:DRIVER=Microsoft Access Driver (*.mdb);DBQ=client.mdb;PWD=mypass";
         Connection con;
         Statement stmt;
    public gui() {
         try {
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
         } catch(java.lang.ClassNotFoundException e) {
              JOptionPane.showMessageDialog(this, "Database drivers not found!" + "\n" + "Details:" + "\n"+ e.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
         setTitle("TimeCost - Time and Disbursement Control System"); // set the frame title
         setSize(850,550);
         setResizable(false);
         setVisible(true);
         setBackground(new Color(204,204,204));
         // create a OK Button
         ok = new JButton("OK");
         ok.setActionCommand("ok");
         ok.setEnabled(false);
         ok.setMnemonic(KeyEvent.VK_O); // Alt + O
         ok.setFont(new Font("null", Font.PLAIN, 14));     
         ok.setToolTipText("Confirm these actions and proceed");
         ok.addActionListener(this);
         // create a Cancel Button
         cancel = new JButton("Cancel");
         cancel.setActionCommand("cancel");
         cancel.setEnabled(false);
         cancel.setMnemonic(KeyEvent.VK_C); // Alt + C
         cancel.setFont(new Font("null", Font.PLAIN, 14));     
         cancel.setToolTipText("Cancel these actions and return to previous screen");
         cancel.addActionListener(this);
         // create a Main Menu Button
         menu = new JButton("Main Menu");
         menu.setActionCommand("menu");
         menu.setEnabled(false);
         menu.setMnemonic(KeyEvent.VK_M); // Alt + M
         menu.setFont(new Font("null", Font.PLAIN, 14));     
         menu.setToolTipText("Return to opening screen");
         menu.addActionListener(this);
         // create a Staff Button
         staff = new JButton("Staff");
         staff.setActionCommand("staff");
         staff.setEnabled(true);
         staff.setMnemonic(KeyEvent.VK_S); // Alt + S
         staff.setFont(new Font("null", Font.PLAIN, 14));     
         staff.setToolTipText("Setup the members of staff");
         staff.addActionListener(this);
         // create a Amend Button
         amendTC = new JButton("Amend Rates");
         amendTC.setActionCommand("amend");
         amendTC.setEnabled(true);
         amendTC.setMnemonic(KeyEvent.VK_A); // Alt + A
         amendTC.setFont(new Font("null", Font.PLAIN, 14));     
         amendTC.setToolTipText("Amend time and cost rates");
         amendTC.addActionListener(this);
         // create a Print Button
         print = new JButton("Print");
         print.setActionCommand("print");
         print.setEnabled(false);
         print.setMnemonic(KeyEvent.VK_P); // Alt + P
         print.setFont(new Font("null", Font.PLAIN, 14));     
         print.setToolTipText("Print the current generated information");
         print.addActionListener(this);
         // create a ChangePass Button
         changePass = new JButton("Password");
         changePass.setActionCommand("pass");
         changePass.setEnabled(true);
         changePass.setMnemonic(KeyEvent.VK_P); // Alt + P
         changePass.setFont(new Font("null", Font.PLAIN, 14));     
         changePass.setToolTipText("Change the password used to access some areas of the program");
         changePass.addActionListener(this);
         // create a Exit Button
         exit = new JButton("Exit TimeCost");
         exit.setActionCommand("exit");
         exit.setEnabled(true);
         exit.setMnemonic(KeyEvent.VK_E); // Alt + E
         exit.setFont(new Font("null", Font.PLAIN, 14));     
         exit.setToolTipText("Exit the timecost program");
         exit.addActionListener(this);
         buttonPanel.setLayout( new BoxLayout(buttonPanel, BoxLayout.X_AXIS) );
         buttonPanel.setBorder(BorderFactory.createEmptyBorder(15,0,15,0));     
         buttonPanel.setBackground(Color.LIGHT_GRAY);
         buttonPanel.add(Box.createHorizontalGlue());     
         buttonPanel.add(ok);
         buttonPanel.add(Box.createRigidArea(new Dimension(3,0)));
         buttonPanel.add(cancel);
         buttonPanel.add(Box.createRigidArea(new Dimension(3,0)));
         buttonPanel.add(print);
         buttonPanel.add(Box.createRigidArea(new Dimension(3,0)));
         buttonPanel.add(menu);
         buttonPanel.add(Box.createRigidArea(new Dimension(30,0)));     
         buttonPanel.add(staff);
         buttonPanel.add(Box.createRigidArea(new Dimension(3,0)));
         buttonPanel.add(amendTC);
         buttonPanel.add(Box.createRigidArea(new Dimension(3,0)));
         buttonPanel.add(changePass);
         buttonPanel.add(Box.createRigidArea(new Dimension(30,0)));
         buttonPanel.add(exit);     
         buttonPanel.add(Box.createHorizontalGlue());
         // create a JLabel that displays the ********* Logo
         ImageIcon icon = new ImageIcon("***.png", "****** Logo");
         JLabel label = new JLabel(icon);
         label.setBackground(new Color(204,204,204));
         label.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
         label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
         label.setVerticalAlignment(javax.swing.SwingConstants.CENTER);
         label.setVisible(true);
         // create the Panels
         homeoptions = new home();
         newrec = new newRecords();
         createCR = new createClientRecord();
         createJR = new createJobRecord();
         enterFA = new enterFeeAccounts();
         enterS = new enterSettlement();
         enterTS = new enterTimesheet();
         enterD = new enterDisbursement();
         chargeT = new chargeTime();
         chargeD     = new chargeDisbursements();
         changeExist = new changeExisting();
         amend = new amendTimeCost();
         amend.setVisible(false);
         staffFrame = new staff();
         staffFrame.setVisible(false);
         // add Listeners
         homeoptions.addHomeListener(this);
         newrec.addHomeListener(this);
         createCR.addHomeListener(this);
         createJR.addHomeListener(this);
         enterFA.addHomeListener(this);
         enterS.addHomeListener(this);
         enterTS.addHomeListener(this);
         enterD.addHomeListener(this);
         chargeT.addHomeListener(this);
         chargeD.addHomeListener(this);
         changeExist.addHomeListener(this);
         // add the mainPane to a JScrollpane
         main = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         main.setViewportView(homeoptions);
         main.setBackground(new Color(204,204,204));
         main.setBorder(BorderFactory.createEmptyBorder(8,8,8,8));
         // create a Container for the JFrame
         cont = getContentPane();
    cont.setLayout(new BorderLayout());
    cont.setBackground(new Color(204,204,204));
    cont.add(label, BorderLayout.NORTH);
    cont.add(main, BorderLayout.CENTER);
         cont.add(buttonPanel, BorderLayout.SOUTH);
         // get the password
         File file = new File("pw.ser");
         if(file.exists()){
              ObjectInput input = null;
         try{
              //use buffering
              InputStream filein = new FileInputStream( "pw.ser" );
              InputStream buffer = new BufferedInputStream( filein );
              input = new ObjectInputStream ( buffer );
              //deserialize the List
              password = (String)input.readObject();           
         } catch(IOException ex){
              JOptionPane.showMessageDialog(this, "Cannot perform setup operation."+"\n"+"Details:"+"\n"+ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
         } catch (ClassNotFoundException ex){
              JOptionPane.showMessageDialog(this, "Unexpected class found upon input."+"\n"+"Details:"+"\n"+ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
         } // end catch
         finally{
              try {
              if ( input != null ) {
                   //close "input" and its underlying streams
                   input.close();
              } // end if
              } catch (IOException ex){                  
              JOptionPane.showMessageDialog(this, "Cannot Close Input Stream."+"\n"+"Details:"+"\n"+ex.getMessage(), "Warning", JOptionPane.WARNING_MESSAGE);
              } // end catch
         } // end finally
         } else {
              password = "";                     
         // Add Window Listener to the JFrame
         addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent e) {
              int n = JOptionPane.showOptionDialog(null,
    "Are you sure you wish to close the TimeCost program \n"+
    "Any unconfirmed changes will not be saved \n"+
    "Exit TimeCost?",
    " Exit TimeCost",
    JOptionPane.YES_NO_OPTION,
    JOptionPane.QUESTION_MESSAGE,
    null, null, null);
    if (n == JOptionPane.YES_OPTION) {
         System.exit(0);
    } else if (n == JOptionPane.NO_OPTION) {
         return;
    } // end window closing
         this.validate();
         this.setLocationRelativeTo( null ); // put in centre of screen     
    } // end gui Constructor
    // code removed
    // Main Method
    static public void main (String args[]) {
         try{
              UIManager.setLookAndFeel(
                   "javax.swing.plaf.metal.MetalLookAndFeel");
         } catch (Exception e){}
         JFrame.setDefaultLookAndFeelDecorated(true);
         JDialog.setDefaultLookAndFeelDecorated(true);
    gui frame = new gui();
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);     
    } // end main method
    } // end of gui Class

  • Reading from http server

    Hi guys and girls,
    I've got a simple problem: i'm busy programming a browser (for now it's a simple text based browser) and everything works fine, the connection works and it gets all http headers and the html file. But once and a while my program doesn't terminate properly and i think it's got something to do with the following loop:
    /* Read the first line returned by the server */
    String fromServer = input.readLine();
    while (fromServer != null){
    System.out.print(fromServer+"\r\n");
    /* Read the next line untill that line is blank*/
    fromServer = input.readLine();
    Sometimes this works, sometimes it doesnt (mind you: the http headers are received before this loop, so that's not the problem). This loop should get the html file at the specified url: at some locations it just keeps running and it doesn't exit, so this loop isn't exited because right after it i close my connections and perform a System.exit().
    Does anyone have any idea what my problem is? The loop should stop when the server doesn't send anymore lines from the html file: it shows the html closing tag everytime so that is the last line from the html file, yet it fails to exit the loop. The weird thing is: sometimes it works properly, sometimes it doesn't., and when it doesn't it doesn't show input anymore so all html text is sent by the server.
    Are there other ways to make the program exit the loop when all the lines from the html file are sent?
    The input stream i use is a buffered inputstream reader:
    input = new BufferedReader(new InputStreamReader(c.getInputStream()));
    Hope you understand the problem :)

    1. You didn't show what kind of connection u get. For example HttpConnection may be looped due
    to response redirection.
    2. I think the best practice for the case is to read bytes from the stream but not lines, for instance:
    int c = 0;
    while( (c=in.read())>=0 ){
    .... do something
    }

  • Embedding a pdf in a jsp

    Hello,
    I have a unique situation here. I have a byte array of a pdf document. I want to display it in a frame on a JSP. Is there any way to do this? Any suggestions?

    Write a servlet which takes the byte array (I recommend you to use a buffered inputstream (ByteArrayInputStream) rather) and writes it to the outputstream of the response. Map this servlet in your web.xml and call this servlet in the url of the (i)frame, if necessary with a request parameter so that the servlet knows which PDF file it should pick up.

  • Runtime.exec("ftp") , but cann't read from Process.getInputStream()

    first, Runtime.exec("ftp")
    then I read from Process.getInputStream()
    but I get nohting. why ?
    I think I should read a prompt string "ftp>"
    and, Process.getInputStream() return a BufferedInputStream, how can I get a non-buffered InputStream from it ?

    Disregarding your actual question, I'll take a stab at the REAL issue.
    If you're going to script an FTP session, why not use ftp -s:<filename>?

  • Funny behavior with Item Editors

    I have a DataGrid which has a column with CheckBoxes (item
    editors), initially they are all unselected (suppose there are 5
    rows), if i click on the 5 of them quickly to change them to
    selected then something funny happens, some of them change to
    selected and then to unselected again. If i do this slowly, then it
    works fine. And the same happens if they are all selected and then
    i quickly click on the 5 of them to unselect them, some of them
    became selected again.
    It is as if Flex wasn't able to process the changes so fast,
    so by the time it is processing a CheckBox's change another one
    changes too and it reverts the first one to its previous state.
    Any idea why this happens? is it a bug, a mistake in my code,
    a normal behavior? what is it?

    Code:
    <mx:DataGrid id="dgcatalogo" width="100%" editable="true"
    height="236" dataProvider="{arrCCostoDisplay}" >
    <mx:columns>
    <mx:DataGridColumn dataField="ccoEstatus"
    headerText="{resource.getString('incluir')}" width="50"
    editable="true" rendererIsEditor="true"
    itemRenderer="renderer.CheckRenderer"
    editorDataField="result"/>
    <mx:DataGridColumn dataField="ccoDescripcion"
    headerText="{resource.getString('descripcion')}" editable="false"
    width="200"/>
    </mx2:columns>
    </mx:DataGrid>
    where CheckRender is:
    <mx:VBox xmlns:mx="
    http://www.adobe.com/2006/mxml"
    horizontalAlign="center">
    <mx:Script>
    <![CDATA[
    // Define a property for returning the new value to the
    cell.
    public var result : Boolean = false;
    ]]>
    </mx:Script>
    <mx:Binding source="editor.selected" destination="result"
    />
    <mx:CheckBox id="editor"
    selected="{data.ccoEstatus}"/>
    </mx:VBox>
    That's the code, and like i said, it behaves funny when you
    select/unselect the checkboxes quickly

  • (261205913) Q SYNCH-14 Is the client behavior still synchronous for buffered methods?

    Q<SYNCH-14> Is the client behavior still synchronous for buffered methods?
    Q<SYNCH-14> For buffered methods the client invocation is essentially asynchronous
    since the return type for the method is void. Quote from BEA Workshop documentation:
    If you add a message buffer to a method of your web service, incoming messages
    (invocations of the method) are buffered on the local machine. The method invocation
    returns to the client immediately. This prevents the client from waiting until
    your web service processes the request. Note that since the buffering occurs on
    your end of the wire, the client still must wait for the network roundtrip even
    though it will return a void result. But the client does not have to wait for
    your service to process the message

    Futher information about the possibility of callback:
    It may be possible for a synchronous only web service (i.e. MS .net) to even paticipant
    in the callback functionality of asynchronous web services. If the client implements
    the appropriate methods for the callback but listens for them on a different port
    or binding than the SOAP request, then web service may be able to build a response
    if the client's "callback URL" is submitted as the beginning part of a conversation.
    Watch the BEA developer forum (http://dev2dev.bea.com) for more information about
    this approach and other tips and techniques for building web services.
    "Adam FitzGerald" <[email protected]> wrote:
    >
    Q<SYNCH-03> I heard that MS .net only implements synchrnonus method? If
    this is true.
    Does it means my async methods will only work with J2EE clients?
    A<SYNCH-03> I do not know the limitations of .net but let me point out that
    is very
    difficult to provide asynchronous web service method invocation (this is
    different
    from an asynchronous web service). HTTP as a general communication protocol
    is based
    on a request and response paradigm so your client libraries will mostly
    likely be
    expecting a response even if it is empty (check the asynchronous example
    from today
    to see that the start method still returns an empty response). You must
    distinguish
    this from the notion of an asynchronous web service which is a business
    operation
    that occurs on the server whose return value/result is not directly associated
    with
    building response to the client. An asynchronous web service can (and generally
    will)
    be started and stopped with web service operations that are invoked synchronously.
    Thus MS .net clients can still be client to WLS hosted web services.

  • Buffered reader / data inputstream

    I need to find out how to enter array numbers in from the keyboard
    i think it might be by using buffered reader, but i dont know th exact code can
    anybody help me!
    Cheers

    Do you need to keep array of numbers?
    It's simply and not powerfull solution:
    import java.io.*;
    import java.util.Vector;
    public class test
    public static void main (String argv[])
    BufferedReader theIn = new BufferedReader (new InputStreamReader (System.in));
    int nValue;
    int nSumma = 0;
    Vector theItems = new Vector (0, 10);
    while (true)
    try
    nValue = Integer.parseInt (theIn.readLine ());
    nSumma += nValue;
    theItems.addElement (new Integer (nValue));
    catch (Exception e)
    break;
    System.out.println ("Summa: " + nSumma);
    }

  • Funny behavior with port 25

    hi,
    i am developing an SMTP server, and therefore have to use port 25. the thing is i use a printwriter for the output and a bufferedstreaminput for the input. the program works well on any other port, except port 25 where it will only chuck out a line and one has to click enter for it to chuck the other. this then crashes the program has it should. i am using sdk1.4 and windows 2000. any idea has to why this odd behavior?
    thanks

    that is the joy of it, it doesn't give me any exception, it just doesn't work properly on port 25. that is what i don't understand. is it something to do with my setup of windows 2000, or is it a bug of some sort?
    the code for 2 of the classes is shown below
    import java.net.*;
    import java.util.*;
    class EmailServer implements Runnable {
         ServerSocket server = null;
         public static void main(String[] args) {
              Thread email = new Thread(new EmailServer());
              email.start();
         public void run()
              try {
                   server = new ServerSocket(26);
                   System.out.println("The server has started");
                   while (true) {
                        Socket socket = server.accept();
                        Thread request = new Thread(new EmailRequest(socket));
                   request.setDaemon(true);
                        request.start();
              catch (Exception e) {
                   System.err.println("Unable to start EmailServer: " + e.getMessage());
                   e.printStackTrace();
    import java.net.*;
    import java.io.*;
    import java.util.*;
    class EmailRequest implements Runnable {
    private Socket clientconnection;
         String word = "";
              PrintWriter output;
         BufferedReader in;
         String line =""     ;
    public EmailRequest(Socket clientconnection) {
    this.clientconnection = clientconnection;
    private void process()
              try
                   System.out.println("The connection has opened.");
                   output = new      PrintWriter(clientconnection.getOutputStream(),true);
                   in = new BufferedReader(new InputStreamReader(clientconnection.getInputStream()));
                   boolean OPEN=true;
                   SMTPRequest request = new SMTPRequest(clientconnection.getOutputStream(),clientconnection.getInputStream());
    //               SMTPPlay playing = new SMTPPlay(clientconnection.getOutputStream());
    //               playing.PrintIt();
                   output.println("220 192.168.0.27");
                   while (OPEN)
                        line = in.readLine().trim();
                        System.out.println(line);
                        output.println(line);     
                        if (line.compareToIgnoreCase("QUIT")==0)
                             OPEN=false;
                             in.close();
                             clientconnection.close();
                        else
                             request.commandParser(line);
                   if (request.MAIL)
                        request.PrintEmail();
                   System.out.println("The connection has closed");
              } catch (Exception e) {
              System.err.println("There was an error with EmailServer: " + e.getMessage());
    //               e.printStackTrace();
    public void run()
         try
              process();
         }catch(Exception e)
              System.out.println("upss");
    }

  • More funny ToC behavior

    Even though I'm Dutch and live in Holland, I normally use English for the sytem-language. Now I found that when you create a new iBook, in the ToC you'll find Chapter 1, Chapter 2 etc. There seems to be no way to change that. But when I set my system-language to Dutch and create a new iBook, I get the Dutch words for Chapter (Hoofdstuk) and Section (Sectie). However, an iBook started while the system-language was English retains the English ToC.
    That means that if I create a book in English first and than decide to make a Dutch (or French or whatever) translation I will need to do the book from scratch just to get the ToC in the desired language...
    Am I missing something or is this another entry for the to-do-list @ Apple?
    Arjen

    This is a great thing to send to Apple Feedback.
    - Fabe

  • Google search textbox funny cursor behavior

    # Open new tab in Firefox V6.0.2
    # Enter string eg. "firefox support" to search bar (select Google as your Search engine)
    # on results page set your cursor between the word and try to enter eg. "user" string
    # Result: after input of 1st character the cursor will reset position to the last position in textbox

    That can be caused by the "Keystroke protection" in Comcast Constant Guard.
    "Configure Anti-Keylogging Settings" -> disable
    *[[/questions/874709]]
    *[[/questions/870165]]

Maybe you are looking for

  • Monitoring SAN through OpsMgr 2012 R2

    Hello All..................I am trying to monitor SAN through OpsMgr 2012 R2. 1.  What would be required for such a configuration?  I have following -   Management Pack for SAN -   IP Address -   User Name and Password 2.  WHat would be high level st

  • Business Intelligence crash when accessing repository

    Hi! I have a strange problem. When I login and try to access a universe or the options menu my Business Intelligence client crashes with Faulting application busobj.exe, version 12.1.7.1144, faulting module msvcr80.dll, version 8.0.50727.1433, fault

  • Files keep locking themselves in CS4?

    Hi Just installed Snow Lepeard with CS4 and whenever im saving over or saving as, i keep getting the message that the file is locked and i need to unlock it to save over it"? This is sending me nuts, does anyone know how to stop it? All files are on

  • Installing oracle R12 on windows 2003

    hi i downloaded the suite for windows server 2003. now i need the complete set of instructions for installing them.are there any documents that can guide me with the installation steps. i have 160 gb harddrive and 2 gb ram in my system.will this conf

  • Library organization multiple ablbum covers

    Ok well i have my library organized by cd and it shows the album cover but some CD's have multiple covers one for each song i have tried to go in and change the album name so each are the same and it worked on some but for other CD's it did not work