FileDialog problem

I have a frame with KeyListener. The problem: It's opens the FileDialog sometimes, and after that the KeyListener doesn't work. I have to select some another window and then select my frame again. After that it works again. How can I avoid this?

Add requestFocus() to the next logical component that you want your cursor after the FiDi closes.

Similar Messages

  • Problem with filedialog

    Hello I have this code to open a txtfile
    Frame parent = new Frame();
    FileDialog fd = new FileDialog(parent, "Please choose a file:",FileDialog.LOAD);
    fd.setDirectory(directory);
    fd.show();
    and this is my directory String
    String directory="C:/Progra~1/IRSBeh~1/inlogdata/"; // Directory where the txtfiles are placedWhen I open the dialog it doesn't start with the directory I want but the directory where I run the program. I thought it should start with the directory.
    I run the program on a windows pc.
    Is there something wrong with my code??

    No I didn't because I'am now on an other computer but
    will try later.
    But do you think it works because why should the way
    I did it work for the images en reading of textfiles
    directly but not for the filedialog.
    Or is there a difference between them?
    public class FileDialogTest {
    public static void main(String[] args) {
       String directory="C:\\Michael Howard\\Work\\test\\";
       Frame parent = new Frame();
       FileDialog fd = new FileDialog(parent, "Please choose a file:",FileDialog.LOAD);
       fd.setDirectory(directory);
       fd.show();
    }This works for me. I had the same problem as you are having if I used forward slashes e.g.
    String directory="C:/Michael Howard/Work/test/"; , so change it to use \\ as the directory separator.

  • Problem in using FilenameFilter with FileDialog

    perhaps, i dont know how to use FilenameFilter with FileDialog because the following approach doesn' work
    FileDialog fd=new FileDialog(myframe,"Select an image");
    fd.setFilenameFilter(new filefilter());                                                                                                                           
                                                                                                             class filefilter implements FilenameFilter{
        public boolean accept(File dir, String name) {
            if(name.endsWith("jpg")||name.endsWith("gif")||name.endsWith("png")){
                          return true; 
                 return false;
    }if anyone have compatible idea then please let me know.
    thanks

    Did you print out the value of "dir" and "name" to make sure they contain what you expect?
    If you need further help then you need to create a "Short, Self Contained, Compilable and Executable, Example Program (SSCCE)", that demonstrates the incorrect behaviour.
    http://homepage1.nifty.com/algafield/sscce.html

  • From JavasSript called signed (FileDialog) Applet Problems...

    Hallo,
    I want to read a by JavaScript opened selected file with the FileDialog in a Byte[], and give this Byte[] back to JavaScript. I have this code for my unsigned applet working fine without reading the selected file in a byte[], but give the filepath and name back to JavaScript:
    import java.applet.Applet;
    import java.awt.FileDialog;
    import java.awt.Frame;
    import netscape.javascript.JSObject;
    public class OpenFileDialogJava6 extends Applet
         private static final long serialVersionUID = -1401553529888391702L;
         private Frame m_parent;
        private FileDialog m_fileDialog;
    *Displays a file dialog, calling standard JavaScript methods when the*
    user selects a file or cancels the dialog.
    *    public void newFileDialog(String onFileJS, String onCancelJS)*
    *          System.out.println("open Dialog...");*
    *         openDialog(onFileJS, onCancelJS);*
    *Displays a file dialog, calling the specified JavaScript functions when*
    the user selects a file or cancels the dialog.
    @param onFile The name of the function to call when the user selects a
    *file.*
    @param onCancel The name of the function to call when the user cancels
    *a dialog selection.*
        public void openDialog(final String onFile, final String onCancel)
             System.out.println("Calling open dialog...");
             if (m_parent == null)
                 m_parent = new Frame();
            if (m_fileDialog == null)
                 m_fileDialog = new FileDialog(m_parent, "Medien hinzufügen", FileDialog.LOAD);             
            m_fileDialog.setVisible(true);       
            m_fileDialog.toFront();
            final String directory = m_fileDialog.getDirectory();  
            final String returnFile = m_fileDialog.getFile();
             m_fileDialog.setVisible(false);     
            m_parent.setVisible(false);
            if (returnFile == null)
                 System.out.println("onCancel");
                 callJavaScript(onCancel);     
            else
                 System.out.println("onFile");
                 System.out.println(directory+returnFile);
                 callJavaScript(onFile, directory+returnFile);
         private void callJavaScript(final String func, final Object... args)
              final JSObject window = JSObject.getWindow(OpenFileDialogJava6.this);
              if (window == null)
                  System.out.println("Could not get window from JSObject!!!");
                  return;
              System.out.println("Calling func through window");
              try
                   window.call(func, args);
              catch (final Exception e)
                  System.out.println("Got error!!"+e.getMessage());
                  e.printStackTrace();
                  showError(e);
              System.out.println("Finished JavaScript call...");
         private void showError(final Exception e)
              final String[] args = new String[]{e.getMessage()};
              final JSObject window = JSObject.getWindow(this);
              try
                   window.call("alert", args);
              catch (final Exception ex)
                   System.out.println("Error showing error! "+ex);
    }I self-sign the Jar and write that byte[] test = (byte[]) java.security.AccessController.doPrivileged(
              new java.security.PrivilegedAction() to the code in where I want to read the file.....
    So now I started to change the code in the public void openDialog(final String onFile, final String onCancel) to get the Byte[] of the selected File
            final String directory = m_fileDialog.getDirectory();  
            final String returnFile = m_fileDialog.getFile();
            final File file = new File(directory+
                    File.separator +returnFile);
            byte[] test = (byte[]) java.security.AccessController.doPrivileged(
              new java.security.PrivilegedAction()
                   public Object run()
                      try
                          FileInputStream fileInputStream = new FileInputStream(file);
                          byte[] data = new byte[(int) file.length()];
                          try
                               fileInputStream.read(data);
                               fileInputStream.close();
                               return data;
                          catch(IOException iox)
                                System.out.println("File read error...");
                                iox.printStackTrace();
                                return null;
                     catch (FileNotFoundException fnf)
                           System.out.println("File not found...");
                           fnf.printStackTrace();
                           return null;
             m_fileDialog.setVisible(false);     
            m_parent.setVisible(false);
    .......Without signing the jar: I get this in IE 8:
    Meldung: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\xampp\htdocs\index.php" "read")
    Zeile: 6
    Zeichen: 1
    Code: 0
    URI: file:///E:/FH%20Kempten/Semester%206/Java/Java%20Projekte/OpenFileDialogJava6/bin/Neues%20Textdokument.html
    Ok this I understand, but when I sign it, I open my FileDialog, select a file, ok -> nothing happens: Firfox and IE show me:
    uncaught exception: java.lang.reflect.InvocationTargetException*
    And in Java Console nothing: Just my Output:
    open Dialog...
    Calling open dialog...

    Hallo,
    I want to read a by JavaScript opened selected file with the FileDialog in a Byte[], and give this Byte[] back to JavaScript. I have this code for my unsigned applet working fine without reading the selected file in a byte[], but give the filepath and name back to JavaScript:
    import java.applet.Applet;
    import java.awt.FileDialog;
    import java.awt.Frame;
    import netscape.javascript.JSObject;
    public class OpenFileDialogJava6 extends Applet
         private static final long serialVersionUID = -1401553529888391702L;
         private Frame m_parent;
        private FileDialog m_fileDialog;
    *Displays a file dialog, calling standard JavaScript methods when the*
    user selects a file or cancels the dialog.
    *    public void newFileDialog(String onFileJS, String onCancelJS)*
    *          System.out.println("open Dialog...");*
    *         openDialog(onFileJS, onCancelJS);*
    *Displays a file dialog, calling the specified JavaScript functions when*
    the user selects a file or cancels the dialog.
    @param onFile The name of the function to call when the user selects a
    *file.*
    @param onCancel The name of the function to call when the user cancels
    *a dialog selection.*
        public void openDialog(final String onFile, final String onCancel)
             System.out.println("Calling open dialog...");
             if (m_parent == null)
                 m_parent = new Frame();
            if (m_fileDialog == null)
                 m_fileDialog = new FileDialog(m_parent, "Medien hinzufügen", FileDialog.LOAD);             
            m_fileDialog.setVisible(true);       
            m_fileDialog.toFront();
            final String directory = m_fileDialog.getDirectory();  
            final String returnFile = m_fileDialog.getFile();
             m_fileDialog.setVisible(false);     
            m_parent.setVisible(false);
            if (returnFile == null)
                 System.out.println("onCancel");
                 callJavaScript(onCancel);     
            else
                 System.out.println("onFile");
                 System.out.println(directory+returnFile);
                 callJavaScript(onFile, directory+returnFile);
         private void callJavaScript(final String func, final Object... args)
              final JSObject window = JSObject.getWindow(OpenFileDialogJava6.this);
              if (window == null)
                  System.out.println("Could not get window from JSObject!!!");
                  return;
              System.out.println("Calling func through window");
              try
                   window.call(func, args);
              catch (final Exception e)
                  System.out.println("Got error!!"+e.getMessage());
                  e.printStackTrace();
                  showError(e);
              System.out.println("Finished JavaScript call...");
         private void showError(final Exception e)
              final String[] args = new String[]{e.getMessage()};
              final JSObject window = JSObject.getWindow(this);
              try
                   window.call("alert", args);
              catch (final Exception ex)
                   System.out.println("Error showing error! "+ex);
    }I self-sign the Jar and write that byte[] test = (byte[]) java.security.AccessController.doPrivileged(
              new java.security.PrivilegedAction() to the code in where I want to read the file.....
    So now I started to change the code in the public void openDialog(final String onFile, final String onCancel) to get the Byte[] of the selected File
            final String directory = m_fileDialog.getDirectory();  
            final String returnFile = m_fileDialog.getFile();
            final File file = new File(directory+
                    File.separator +returnFile);
            byte[] test = (byte[]) java.security.AccessController.doPrivileged(
              new java.security.PrivilegedAction()
                   public Object run()
                      try
                          FileInputStream fileInputStream = new FileInputStream(file);
                          byte[] data = new byte[(int) file.length()];
                          try
                               fileInputStream.read(data);
                               fileInputStream.close();
                               return data;
                          catch(IOException iox)
                                System.out.println("File read error...");
                                iox.printStackTrace();
                                return null;
                     catch (FileNotFoundException fnf)
                           System.out.println("File not found...");
                           fnf.printStackTrace();
                           return null;
             m_fileDialog.setVisible(false);     
            m_parent.setVisible(false);
    .......Without signing the jar: I get this in IE 8:
    Meldung: java.security.AccessControlException: access denied ("java.io.FilePermission" "C:\xampp\htdocs\index.php" "read")
    Zeile: 6
    Zeichen: 1
    Code: 0
    URI: file:///E:/FH%20Kempten/Semester%206/Java/Java%20Projekte/OpenFileDialogJava6/bin/Neues%20Textdokument.html
    Ok this I understand, but when I sign it, I open my FileDialog, select a file, ok -> nothing happens: Firfox and IE show me:
    uncaught exception: java.lang.reflect.InvocationTargetException*
    And in Java Console nothing: Just my Output:
    open Dialog...
    Calling open dialog...

  • Problem in FileDialog

    Hi,
    i am new in event handling programs and i make a small program using FileDialog . but FileDialog is nor working properly .
    here is my code
    import java.awt.event.*;
    import java.awt.*;
    import java.io.*;
    public class frameopen extends Frame
    frameopen f;
    String msg = "";
    Panel p1 = new Panel();
    Panel p2 = new Panel();
    Label l = new Label("Enter URL");
    Label l2 = new Label("");
    TextField t = new TextField(50);
    Button b = new Button("OPEN");
    Button b1 = new Button("Browse");
    public frameopen()
    public void frame(frameopen object)
    f=object;
    setTitle("FILE OPENER");
    setBackground(Color.cyan);
    setForeground(Color.red);
    setSize(600,200);
    setLocation(250,250);
    p1.add(l);
    p1.add(t);
    p1.add(b1);
    p2.add(b);
    p1.add(l2);
    add("North",p1);
    add("Center",p2);
    b.addMouseListener(new my(b));
    b1.addMouseListener(new my(b1));
    addWindowListener(new my1());
    class my extends MouseAdapter
    Button temp;
    String s;
              my(Button obj)
                        temp=obj;
    s=temp.getLabel();
              public void mousePressed(MouseEvent evt)
                        if(s.equals(b.getLabel()))
                                  try
                                       File f1 = new File(t.getText());
                                       if(f1.exists())
                                                 Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + f1.getAbsolutePath());
                                       else
                                                 msg = " File Not Found. Please Check URL.";
                                                 error e1 = new error(f,msg);
                                                 e1.setVisible(true);
                                  catch (Exception e)
                                       msg = "" + e;
                                       error e1 = new error(f,msg);
                                       e1.setVisible(true);
                        else
                                  try
    File fd = new File(f,"SELECT");
                                  fd.setVisible(true);
    t.setText(fd.text());
    catch (Exception e)
                                       msg = "" + e;
                                       error e1 = new error(f,msg);
                                       e1.setVisible(true);
    class my1 extends WindowAdapter
    public void windowClosing(WindowEvent evt)
    System.exit(0);
    public static void main(String args[])
    frameopen f = new frameopen();
    f.frame(f);
    f.setVisible(true);
    class error extends Dialog implements ActionListener
    String msg = "";
    Panel p = new Panel();
    Panel p1 = new Panel();
    Label l = new Label();
    Button b= new Button("OK");
    error(Frame parent ,String title)
    super(parent , "ERROR" , false);
    setSize(300,100);
    setLocation(150,50);
    msg = title ;
    l.setText(msg);
    p.add(l);
    p1.add(b);
    add("North",p);
    add("Center",p1);
    b.addActionListener(this);
    addWindowListener(new my());
    public void actionPerformed(ActionEvent evt)
    dispose();
    class my extends WindowAdapter
    public void windowClosing(WindowEvent evt)
    dispose();
    class file extends FileDialog implements ActionListener
    file ob = new file();
    file(Frame obj , String Title)
    super(f,title);
    public void windowClosing(ActionEvent evt)
    dispose();
    public String text()
    String msg = ob.getDirectory()+ ob.getFile();
    in this code all is running well except FileDialog which is extended in file class. event handling of other component are also effected by FileDialog. on executing this code i got one text file of name
    **hs_err_pid3208**
    and the matter inside the file is
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7ca2cd53, pid=3208, tid=1320
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_08-b03 mixed mode)
    # Problematic frame:
    # C [SHELL32.DLL+0x6cd53]
    --------------- T H R E A D ---------------
    Current thread (0x0acae058): JavaThread "AWT-Windows" daemon [_thread_in_native, id=1320]
    siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
    Registers:
    EAX=0x00000000, EBX=0x000df570, ECX=0x000df570, EDX=0x7c90eb94
    ESP=0x0af5d49c, EBP=0x0af5d4b0, ESI=0x000df570, EDI=0x000df6dc
    EIP=0x7ca2cd53, EFLAGS=0x00010246
    Top of Stack: (sp=0x0af5d49c)
    0x0af5d49c: 000df6dc 00000000 000df570 ffffffff
    0x0af5d4ac: 00000000 0af5d504 7c9f8268 00000001
    0x0af5d4bc: 00000000 000af0a0 0af5d538 00002000
    0x0af5d4cc: 0af5d498 0af5d4e0 0af5e450 77d7046f
    0x0af5d4dc: 77d48840 ffffffff 77d4883a 00010015
    0x0af5d4ec: 000ba0f8 00000000 002a01ec 0000000b
    0x0af5d4fc: 00000000 00000000 0af5d538 7ca2cf8a
    0x0af5d50c: 00000003 00000063 00000000 00000000
    Instructions: (pc=0x7ca2cd53)
    0x7ca2cd43: 83 4d f8 ff 83 65 fc 00 53 56 57 8b f1 8b 46 3c
    0x7ca2cd53: 8b 08 8d 96 38 02 00 00 52 8d 55 f8 52 6a 08 bf
    Stack: [0x0af20000,0x0af60000), sp=0x0af5d49c, free space=245k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C [SHELL32.DLL+0x6cd53]
    C [SHELL32.DLL+0x38268]
    C [SHELL32.DLL+0x6cf8a]
    C [COMDLG32.DLL+0x46d4]
    C [COMDLG32.DLL+0x44cc]
    C [COMDLG32.DLL+0x433c]
    C [COMDLG32.DLL+0x3eed]
    C [COMDLG32.DLL+0x3e41]
    C [COMDLG32.DLL+0x3dc4]
    C [COMDLG32.DLL+0x3a84]
    C [COMDLG32.DLL+0x3678]
    C [USER32.dll+0x8744]
    C [USER32.dll+0x15324]
    C [USER32.dll+0x14d17]
    C [USER32.dll+0x14f44]
    C [USER32.dll+0x8744]
    C [USER32.dll+0x8826]
    C [USER32.dll+0xb8ab]
    C [USER32.dll+0x15b68]
    C [USER32.dll+0x16f01]
    C [USER32.dll+0x16f56]
    C [USER32.dll+0x22066]
    C [COMDLG32.DLL+0x35de]
    C [COMDLG32.DLL+0x33e5]
    C [COMDLG32.DLL+0x33bc]
    C [COMDLG32.DLL+0x17cc7]
    C [awt.dll+0xcf68d]
    C [USER32.dll+0x8744]
    C [USER32.dll+0x8826]
    C [USER32.dll+0xb8ab]
    C [USER32.dll+0xb913]
    C [awt.dll+0xcf682]
    C [awt.dll+0xe56e4]
    C [USER32.dll+0x8744]
    C [USER32.dll+0x8826]
    C [USER32.dll+0xb4d0]
    C [USER32.dll+0xb51c]
    C [ntdll.dll+0xeae3]
    C [USER32.dll+0x9412]
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j sun.awt.windows.WToolkit.eventLoop()V+0
    j sun.awt.windows.WToolkit.run()V+69
    j java.lang.Thread.run()V+11
    v ~StubRoutines::call_stub
    --------------- P R O C E S S ---------------
    Java Threads: ( => current thread )
    0x0ac6ac10 JavaThread "Thread-1" daemon [_thread_in_native, id=3212]
    0x0ac6a9e8 JavaThread "SIGTERM handler" daemon [_thread_blocked, id=3360]
    0x0ac69150 JavaThread "Thread-10" [_thread_in_native, id=2884]
    0x00035858 JavaThread "DestroyJavaVM" [_thread_blocked, id=3204]
    0x0acb3b18 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=3232]
    =>0x0acae058 JavaThread "AWT-Windows" daemon [_thread_in_native, id=1320]
    0x0acadca0 JavaThread "AWT-Shutdown" [_thread_blocked, id=2836]
    0x00acdb30 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=1636]
    0x00a93f28 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1392]
    0x00a92af8 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3220]
    0x00a91ed8 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1356]
    0x00a88ed8 JavaThread "Finalizer" daemon [_thread_blocked, id=1404]
    0x00a87a90 JavaThread "Reference Handler" daemon [_thread_blocked, id=1408]
    Other Threads:
    0x00a47fb0 VMThread [id=1412]
    0x00a95108 WatcherThread [id=1340]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 576K, used 373K [0x02ad0000, 0x02b70000, 0x02fb0000)
    eden space 512K, 60% used [0x02ad0000, 0x02b1d4a8, 0x02b50000)
    from space 64K, 100% used [0x02b60000, 0x02b70000, 0x02b70000)
    to space 64K, 0% used [0x02b50000, 0x02b50000, 0x02b60000)
    tenured generation total 1408K, used 191K [0x02fb0000, 0x03110000, 0x06ad0000)
    the space 1408K, 13% used [0x02fb0000, 0x02fdfef0, 0x02fe0000, 0x03110000)
    compacting perm gen total 8192K, used 3898K [0x06ad0000, 0x072d0000, 0x0aad0000)
    the space 8192K, 47% used [0x06ad0000, 0x06e9eb38, 0x06e9ec00, 0x072d0000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040d000      C:\jdk1.5.0_08\bin\java.exe
    0x7c900000 - 0x7c9b0000      C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c8f4000      C:\WINDOWS\system32\kernel32.dll
    0x77dd0000 - 0x77e6b000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77e70000 - 0x77f01000      C:\WINDOWS\system32\RPCRT4.dll
    0x77c10000 - 0x77c68000      C:\WINDOWS\system32\MSVCRT.dll
    0x6d730000 - 0x6d8cb000      C:\jdk1.5.0_08\jre\bin\client\jvm.dll
    0x77d40000 - 0x77dd0000      C:\WINDOWS\system32\USER32.dll
    0x77f10000 - 0x77f57000      C:\WINDOWS\system32\GDI32.dll
    0x76b40000 - 0x76b6d000      C:\WINDOWS\system32\WINMM.dll
    0x6d2f0000 - 0x6d2f8000      C:\jdk1.5.0_08\jre\bin\hpi.dll
    0x76bf0000 - 0x76bfb000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d700000 - 0x6d70c000      C:\jdk1.5.0_08\jre\bin\verify.dll
    0x6d370000 - 0x6d38d000      C:\jdk1.5.0_08\jre\bin\java.dll
    0x6d720000 - 0x6d72f000      C:\jdk1.5.0_08\jre\bin\zip.dll
    0x6d070000 - 0x6d1d9000      C:\jdk1.5.0_08\jre\bin\awt.dll
    0x73000000 - 0x73026000      C:\WINDOWS\system32\WINSPOOL.DRV
    0x76390000 - 0x763ad000      C:\WINDOWS\system32\IMM32.dll
    0x774e0000 - 0x7761d000      C:\WINDOWS\system32\ole32.dll
    0x5ad70000 - 0x5ada8000      C:\WINDOWS\system32\uxtheme.dll
    0x73760000 - 0x737a9000      C:\WINDOWS\system32\ddraw.dll
    0x73bc0000 - 0x73bc6000      C:\WINDOWS\system32\DCIMAN32.dll
    0x6d2b0000 - 0x6d2ef000      C:\jdk1.5.0_08\jre\bin\fontmanager.dll
    0x10000000 - 0x10007000      C:\Internet Download Manager\idmmkb.dll
    0x7c9c0000 - 0x7d399000      C:\WINDOWS\system32\SHELL32.DLL
    0x77f60000 - 0x77fd6000      C:\WINDOWS\system32\SHLWAPI.dll
    0x773d0000 - 0x774d3000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2649_x-ww_aac16c8b\comctl32.dll
    0x5d090000 - 0x5d12a000      C:\WINDOWS\system32\comctl32.dll
    0x763b0000 - 0x763f9000      C:\WINDOWS\system32\COMDLG32.DLL
    0x77b40000 - 0x77b62000      C:\WINDOWS\system32\appHelp.dll
    0x76fd0000 - 0x7704f000      C:\WINDOWS\system32\CLBCATQ.DLL
    0x77050000 - 0x77115000      C:\WINDOWS\system32\COMRes.dll
    0x77120000 - 0x771ac000      C:\WINDOWS\system32\OLEAUT32.dll
    0x77c00000 - 0x77c08000      C:\WINDOWS\system32\VERSION.dll
    0x77a20000 - 0x77a74000      C:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661d000      C:\WINDOWS\System32\CSCDLL.dll
    0x75f80000 - 0x7607d000      C:\WINDOWS\system32\browseui.dll
    0x769c0000 - 0x76a73000      C:\WINDOWS\system32\USERENV.dll
    0x77920000 - 0x77a13000      C:\WINDOWS\system32\SETUPAPI.dll
    0x76990000 - 0x769b5000      C:\WINDOWS\system32\ntshrui.dll
    0x76b20000 - 0x76b31000      C:\WINDOWS\system32\ATL.DLL
    0x5b860000 - 0x5b8b5000      C:\WINDOWS\system32\NETAPI32.dll
    0x77760000 - 0x778cf000      C:\WINDOWS\system32\shdocvw.dll
    0x77a80000 - 0x77b14000      C:\WINDOWS\system32\CRYPT32.dll
    0x77b20000 - 0x77b32000      C:\WINDOWS\system32\MSASN1.dll
    0x754d0000 - 0x75550000      C:\WINDOWS\system32\CRYPTUI.dll
    0x76c30000 - 0x76c5e000      C:\WINDOWS\system32\WINTRUST.dll
    0x76c90000 - 0x76cb8000      C:\WINDOWS\system32\IMAGEHLP.dll
    0x771b0000 - 0x77259000      C:\WINDOWS\system32\WININET.dll
    0x76f60000 - 0x76f8c000      C:\WINDOWS\system32\WLDAP32.dll
    0x20000000 - 0x202c9000      C:\WINDOWS\system32\xpsp2res.dll
    0x75e90000 - 0x75f40000      C:\WINDOWS\system32\SXS.DLL
    0x71b20000 - 0x71b32000      C:\WINDOWS\system32\MPR.dll
    0x75f60000 - 0x75f67000      C:\WINDOWS\System32\drprov.dll
    0x71c10000 - 0x71c1e000      C:\WINDOWS\System32\ntlanman.dll
    0x71cd0000 - 0x71ce7000      C:\WINDOWS\System32\NETUI0.dll
    0x71c90000 - 0x71cd0000      C:\WINDOWS\System32\NETUI1.dll
    0x71c80000 - 0x71c87000      C:\WINDOWS\System32\NETRAP.dll
    0x71bf0000 - 0x71c03000      C:\WINDOWS\System32\SAMLIB.dll
    0x75f70000 - 0x75f79000      C:\WINDOWS\System32\davclnt.dll
    0x0b600000 - 0x0b658000      C:\WINDOWS\system32\PortableDeviceApi.dll
    0x4d4f0000 - 0x4d548000      C:\WINDOWS\system32\WINHTTP.dll
    0x75970000 - 0x75ade000      C:\WINDOWS\system32\MSGINA.dll
    0x76360000 - 0x76370000      C:\WINDOWS\system32\WINSTA.dll
    0x74320000 - 0x7435d000      C:\WINDOWS\system32\ODBC32.dll
    0x0b8a0000 - 0x0b8b7000      C:\WINDOWS\system32\odbcint.dll
    0x77fe0000 - 0x77ff1000      C:\WINDOWS\system32\Secur32.dll
    VM Arguments:
    java_command: frameope
    Launcher Type: SUN_STANDARD
    Environment Variables:
    JAVA_HOME=C:\jdk1.5.0_08\
    CLASSPATH=.;c:\Tomcat\common\lib\servlet.jar;C:\tomcat\common\lib\servlet-api.jar;C:\classes\jl1.0.jar;C:\classes\mp3spi1.9.2.jar;C:\classes\tritonus_share.jar
    PATH=C:\jdk1.5.0_08\bin;E:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Sun\AppServer\bin;;C:\jdk1.5.0_08\bin
    USERNAME=abhishek
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel
    --------------- S Y S T E M ---------------
    OS: Windows XP Build 2600 Service Pack 2
    CPU:total 1 (cores per cpu 1, threads per core 1) family 15 model 2 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2
    Memory: 4k page, physical 253424k(68724k free), swap 620672k(203748k free)
    vm_info: Java HotSpot(TM) Client VM (1.5.0_08-b03) for windows-x86, built on Jul 26 2006 01:10:50 by "java_re" with MS VC++ 6.0
    PLEASE HELP ME TO UNDERSTAND THIS

    dude
    their is a prblm in FileDialog nt in my coding coz i got one file of after the execution of this code
    which states that their is aprblm in java hotspot virtual machine. Here is a content of the file and if u run this prgrm thn i
    think u also get tht. nd i m using java1.5
    # An unexpected error has been detected by HotSpot Virtual Machine:
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7ca2cd53, pid=1576, tid=560
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_08-b03 mixed mode)
    # Problematic frame:
    # C  [SHELL32.DLL+0x6cd53]
    ---------------  T H R E A D  ---------------
    Current thread (0x0acae058):  JavaThread "AWT-Windows" daemon [_thread_in_native, id=560]
    siginfo: ExceptionCode=0xc0000005, reading address 0x00000000
    Registers:
    EAX=0x00000000, EBX=0x000cd7d8, ECX=0x000cd7d8, EDX=0x7c90eb94
    ESP=0x0af5d49c, EBP=0x0af5d4b0, ESI=0x000cd7d8, EDI=0x000cd944
    EIP=0x7ca2cd53, EFLAGS=0x00010246
    Top of Stack: (sp=0x0af5d49c)
    0x0af5d49c:   000cd944 00000000 000cd7d8 ffffffff
    0x0af5d4ac:   00000000 0af5d504 7c9f8268 00000001
    0x0af5d4bc:   00000000 000af2a8 0af5d538 00002000
    0x0af5d4cc:   0af5d498 0af5d4e0 0af5e450 77d7046f
    0x0af5d4dc:   77d48840 ffffffff 77d4883a 00010015
    0x0af5d4ec:   000c3498 00000000 000d01f4 0000000b
    0x0af5d4fc:   00000000 00000000 0af5d538 7ca2cf8a
    0x0af5d50c:   00000003 00000063 00000000 00000000
    Instructions: (pc=0x7ca2cd53)
    0x7ca2cd43:   83 4d f8 ff 83 65 fc 00 53 56 57 8b f1 8b 46 3c
    0x7ca2cd53:   8b 08 8d 96 38 02 00 00 52 8d 55 f8 52 6a 08 bf
    Stack: [0x0af20000,0x0af60000),  sp=0x0af5d49c,  free space=245k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    C  [SHELL32.DLL+0x6cd53]
    C  [SHELL32.DLL+0x38268]
    C  [SHELL32.DLL+0x6cf8a]
    C  [COMDLG32.DLL+0x46d4]
    C  [COMDLG32.DLL+0x44cc]
    C  [COMDLG32.DLL+0x433c]
    C  [COMDLG32.DLL+0x3eed]
    C  [COMDLG32.DLL+0x3e41]
    C  [COMDLG32.DLL+0x3dc4]
    C  [COMDLG32.DLL+0x3a84]
    C  [COMDLG32.DLL+0x3678]
    C  [USER32.dll+0x8744]
    C  [USER32.dll+0x15324]
    C  [USER32.dll+0x14d17]
    C  [USER32.dll+0x14f44]
    C  [USER32.dll+0x8744]
    C  [USER32.dll+0x8826]
    C  [USER32.dll+0xb8ab]
    C  [USER32.dll+0x15b68]
    C  [USER32.dll+0x16f01]
    C  [USER32.dll+0x16f56]
    C  [USER32.dll+0x22066]
    C  [COMDLG32.DLL+0x35de]
    C  [COMDLG32.DLL+0x33e5]
    C  [COMDLG32.DLL+0x33bc]
    C  [COMDLG32.DLL+0x17cc7]
    C  [awt.dll+0xcf68d]
    C  [USER32.dll+0x8744]
    C  [USER32.dll+0x8826]
    C  [USER32.dll+0xb8ab]
    C  [USER32.dll+0xb913]
    C  [awt.dll+0xcf682]
    C  [awt.dll+0xe56e4]
    C  [USER32.dll+0x8744]
    C  [USER32.dll+0x8826]
    C  [USER32.dll+0xb4d0]
    C  [USER32.dll+0xb51c]
    C  [ntdll.dll+0xeae3]
    C  [USER32.dll+0x9412]
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j  sun.awt.windows.WToolkit.eventLoop()V+0
    j  sun.awt.windows.WToolkit.run()V+69
    j  java.lang.Thread.run()V+11
    v  ~StubRoutines::call_stub
    ---------------  P R O C E S S  ---------------
    Java Threads: ( => current thread )
      0x0ac6b1b8 JavaThread "Thread-1" daemon [_thread_in_native, id=256]
      0x0acc1cc8 JavaThread "SIGTERM handler" daemon [_thread_blocked, id=1648]
      0x00aca2e8 JavaThread "Thread-6" [_thread_in_native, id=928]
      0x00035858 JavaThread "DestroyJavaVM" [_thread_blocked, id=1824]
      0x0acb3900 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=800]
    =>0x0acae058 JavaThread "AWT-Windows" daemon [_thread_in_native, id=560]
      0x0acadca0 JavaThread "AWT-Shutdown" [_thread_blocked, id=1220]
      0x00acdb08 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=892]
      0x00a93f28 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1740]
      0x00a92c28 JavaThread "CompilerThread0" daemon [_thread_blocked, id=148]
      0x00a91d08 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=1240]
      0x00a88ed8 JavaThread "Finalizer" daemon [_thread_blocked, id=1904]
      0x00a87a90 JavaThread "Reference Handler" daemon [_thread_blocked, id=1644]
    Other Threads:
      0x00a47fb0 VMThread [id=1984]
      0x00a95108 WatcherThread [id=1232]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation   total 576K, used 376K [0x02ad0000, 0x02b70000, 0x02fb0000)
      eden space 512K,  61% used [0x02ad0000, 0x02b1e260, 0x02b50000)
      from space 64K, 100% used [0x02b60000, 0x02b70000, 0x02b70000)
      to   space 64K,   0% used [0x02b50000, 0x02b50000, 0x02b60000)
    tenured generation   total 1408K, used 194K [0x02fb0000, 0x03110000, 0x06ad0000)
       the space 1408K,  13% used [0x02fb0000, 0x02fe0ad8, 0x02fe0c00, 0x03110000)
    compacting perm gen  total 8192K, used 3920K [0x06ad0000, 0x072d0000, 0x0aad0000)
       the space 8192K,  47% used [0x06ad0000, 0x06ea42e8, 0x06ea4400, 0x072d0000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040d000      C:\jdk1.5.0_08\bin\java.exe
    0x7c900000 - 0x7c9b0000      C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c8f4000      C:\WINDOWS\system32\kernel32.dll
    0x77dd0000 - 0x77e6b000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77e70000 - 0x77f01000      C:\WINDOWS\system32\RPCRT4.dll
    0x77c10000 - 0x77c68000      C:\WINDOWS\system32\MSVCRT.dll
    0x6d730000 - 0x6d8cb000      C:\jdk1.5.0_08\jre\bin\client\jvm.dll
    0x77d40000 - 0x77dd0000      C:\WINDOWS\system32\USER32.dll
    0x77f10000 - 0x77f57000      C:\WINDOWS\system32\GDI32.dll
    0x76b40000 - 0x76b6d000      C:\WINDOWS\system32\WINMM.dll
    0x6d2f0000 - 0x6d2f8000      C:\jdk1.5.0_08\jre\bin\hpi.dll
    0x76bf0000 - 0x76bfb000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d700000 - 0x6d70c000      C:\jdk1.5.0_08\jre\bin\verify.dll
    0x6d370000 - 0x6d38d000      C:\jdk1.5.0_08\jre\bin\java.dll
    0x6d720000 - 0x6d72f000      C:\jdk1.5.0_08\jre\bin\zip.dll
    0x6d070000 - 0x6d1d9000      C:\jdk1.5.0_08\jre\bin\awt.dll
    0x73000000 - 0x73026000      C:\WINDOWS\system32\WINSPOOL.DRV
    0x76390000 - 0x763ad000      C:\WINDOWS\system32\IMM32.dll
    0x774e0000 - 0x7761d000      C:\WINDOWS\system32\ole32.dll
    0x5ad70000 - 0x5ada8000      C:\WINDOWS\system32\uxtheme.dll
    0x73760000 - 0x737a9000      C:\WINDOWS\system32\ddraw.dll
    0x73bc0000 - 0x73bc6000      C:\WINDOWS\system32\DCIMAN32.dll
    0x6d2b0000 - 0x6d2ef000      C:\jdk1.5.0_08\jre\bin\fontmanager.dll
    0x10000000 - 0x10007000      C:\Internet Download Manager\idmmkb.dll
    0x7c9c0000 - 0x7d399000      C:\WINDOWS\system32\SHELL32.DLL
    0x77f60000 - 0x77fd6000      C:\WINDOWS\system32\SHLWAPI.dll
    0x773d0000 - 0x774d3000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2649_x-ww_aac16c8b\comctl32.dll
    0x5d090000 - 0x5d12a000      C:\WINDOWS\system32\comctl32.dll
    0x763b0000 - 0x763f9000      C:\WINDOWS\system32\COMDLG32.DLL
    0x77b40000 - 0x77b62000      C:\WINDOWS\system32\appHelp.dll
    0x76fd0000 - 0x7704f000      C:\WINDOWS\system32\CLBCATQ.DLL
    0x77050000 - 0x77115000      C:\WINDOWS\system32\COMRes.dll
    0x77120000 - 0x771ac000      C:\WINDOWS\system32\OLEAUT32.dll
    0x77c00000 - 0x77c08000      C:\WINDOWS\system32\VERSION.dll
    0x77a20000 - 0x77a74000      C:\WINDOWS\System32\cscui.dll
    0x76600000 - 0x7661d000      C:\WINDOWS\System32\CSCDLL.dll
    0x75f80000 - 0x7607d000      C:\WINDOWS\system32\browseui.dll
    0x769c0000 - 0x76a73000      C:\WINDOWS\system32\USERENV.dll
    0x77920000 - 0x77a13000      C:\WINDOWS\system32\SETUPAPI.dll
    0x76990000 - 0x769b5000      C:\WINDOWS\system32\ntshrui.dll
    0x76b20000 - 0x76b31000      C:\WINDOWS\system32\ATL.DLL
    0x5b860000 - 0x5b8b5000      C:\WINDOWS\system32\NETAPI32.dll
    0x77760000 - 0x778cf000      C:\WINDOWS\system32\shdocvw.dll
    0x77a80000 - 0x77b14000      C:\WINDOWS\system32\CRYPT32.dll
    0x77b20000 - 0x77b32000      C:\WINDOWS\system32\MSASN1.dll
    0x754d0000 - 0x75550000      C:\WINDOWS\system32\CRYPTUI.dll
    0x76c30000 - 0x76c5e000      C:\WINDOWS\system32\WINTRUST.dll
    0x76c90000 - 0x76cb8000      C:\WINDOWS\system32\IMAGEHLP.dll
    0x771b0000 - 0x77259000      C:\WINDOWS\system32\WININET.dll
    0x76f60000 - 0x76f8c000      C:\WINDOWS\system32\WLDAP32.dll
    VM Arguments:
    java_command: frameopen
    Launcher Type: SUN_STANDARD
    Environment Variables:
    JAVA_HOME=C:\jdk1.5.0_08\
    CLASSPATH=.;c:\Tomcat\common\lib\servlet.jar;C:\tomcat\common\lib\servlet-api.jar;C:\classes\jl1.0.jar;C:\classes\mp3spi1.9.2.jar;C:\classes\tritonus_share.jar
    PATH=C:\jdk1.5.0_08\bin;E:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.3.1\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Sun\AppServer\bin;;C:\jdk1.5.0_08\bin
    USERNAME=abhishek
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel
    ---------------  S Y S T E M  ---------------
    OS: Windows XP Build 2600 Service Pack 2
    CPU:total 1 (cores per cpu 1, threads per core 1) family 15 model 2 stepping 9, cmov, cx8, fxsr, mmx, sse, sse2
    Memory: 4k page, physical 253424k(66708k free), swap 620672k(257232k free)
    vm_info: Java HotSpot(TM) Client VM (1.5.0_08-b03) for windows-x86, built on Jul 26 2006 01:10:50 by "java_re" with MS VC++ 6.0

  • FileDialog() setting title problem

    Hi, all:
    Normally, we can set the title of FileDialog through the constructure: FileDialog(parent, String title, int model). However, I don't want to set up title: "Open" or "Save" by this way due to the localization issue, say Japanese, French, Chinese Version. I prepfer letting VM pick up the title by setModel("Load" or "Save"). Microsoft VM did good job to auto-set up "Open" or "Save", however, sun plugin JVM didn't do this way, therefore, no title has been initialized.
    My question is is there an alternative way to let Sun JVM auto set up title "Open" or "Save"?
    Thanks, Java folks.
    --Paul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    Anyone any idea?
    I guess, it is impossible.
    --Paul                                                                                                                                                                                                           

  • FileDialog usage - having general problem

    I have a class that extends FileDialog in my application. I have a working File dialog box that opens, I set it to FileDialog.SAVE type.
    I would like the FileDialog to initially display the String
    "Whatever.txt" in the filename field. The setText() command for this class isn't what I want, but I do not know what else to look at and this is all I've tried.
    also, and most importantly, when user hits Save button on the FileDialog I want to have a handle to this action because I create a txt file of String records and save to the current path.
    thanks ahead of time,
    jmschrei

    any help or redirection to specific API location would be greatly appreciated..
    thanks again,
    jmschrei

  • FileDialog file extension problem

    Hi,
    How to show the FileDialog with specific extensions only. Like, needed extensions are put in a string array.
    String[] extensions = {"doc","docx","xls","xlsx"};I need to show the filedialog with these extensions only.
    Thanks in advance,
    Joe

    jomon_0012 wrote:
    ..How to show the FileDialog.. Why use FileDialog, or any of the AWT components for that matter, in this day and age?
    ..with specific extensions only. Like, needed extensions are put in a string array.
    String[] extensions = {"doc","docx","xls","xlsx"};
    See [FileDialog.setFilenameFilter(FilenameFilter)|http://java.sun.com/javase/6/docs/api/java/awt/FileDialog.html#setFilenameFilter(java.io.FilenameFilter)] ..
    I need to show the filedialog with these extensions only...but note the bit that starts with.. "Filename filters do not.."
    The JFileChooser file types functionality works just fine, as does the file dialog used by the JNLP API of Java Web Start. Use one of them instead.
    Thanks in advance,No worries.

  • File and FileInputStream problem

    Hi all
    I have downloaded from developpez.com a sample code to zip files. I modified it a bit to suit with my needs, and when I launched it, there was an exception. So I commented all the lines except for the first executable one; and when it succeeds then I uncomment the next executable line; and so on. When I arrived at the FileInputStream line , the exception raised. When I looked at the code, it seemed normal. So I want help how to solve it. Here is the code with the last executable line uncommented, and the exception stack :
    // Copyright (c) 2001
    package pack_zip;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import oracle.jdeveloper.layout.*;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    * A Swing-based top level window class.
    * <P>
    * @author a
    public class fzip extends JFrame implements ActionListener{
    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    JTextField szdir = new JTextField();
    JButton btn = new JButton();
    JButton bzip = new JButton();
         * Taille générique du tampon en lecture et écriture
    static final int BUFFER = 2048;
    * Constructs a new instance.
    public fzip() {
    super("Test zip");
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    * Initializes the state of this instance.
    private void jbInit() throws Exception {
    this.getContentPane().setLayout(xYLayout1);
         this.setSize(new Dimension(400, 300));
    btn.setText("btn");
    btn.setActionCommand("browse");
    btn.setLabel("Browse ...");
    btn.setFont(new Font("Dialog", 0, 14));
    bzip.setText("bzip");
    bzip.setActionCommand("zipper");
    bzip.setLabel("Zipper");
    bzip.setFont(new Font("Dialog", 0, 14));
    btn.addActionListener(this);
    bzip.addActionListener(this);
    bzip.setEnabled(false);
         this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
    this.getContentPane().add(szdir, new XYConstraints(23, 28, 252, 35));
    this.getContentPane().add(btn, new XYConstraints(279, 28, 103, 38));
    this.getContentPane().add(bzip, new XYConstraints(128, 71, 103, 38));
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand() == "browse")
    FileDialog fd = new FileDialog(this);
    fd.setVisible(true);
    szdir.setText(fd.getDirectory());
    bzip.setEnabled(true);
    else
              * Compression
         try {
              // création d'un flux d'écriture sur fichier
         FileOutputStream dest = new FileOutputStream("Test_archive.zip");
              // calcul du checksum : Adler32 (plus rapide) ou CRC32
         CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
              // création d'un buffer d'écriture
         BufferedOutputStream buff = new BufferedOutputStream(checksum);
              // création d'un flux d'écriture Zip
         ZipOutputStream out = new ZipOutputStream(buff);
         // spécification de la méthode de compression
         out.setMethod(ZipOutputStream.DEFLATED);
              // spécifier la qualité de la compression 0..9
         out.setLevel(Deflater.BEST_COMPRESSION);
         // buffer temporaire des données à écriture dans le flux de sortie
         byte data[] = new byte[BUFFER];
              // extraction de la liste des fichiers du répertoire courant
         File f = new File(szdir.getText());
         String files[] = f.list();
              // pour chacun des fichiers de la liste
         for (int i=0; i<files.length; i++) {
                   // en afficher le nom
              System.out.println("Adding: "+files);
    // création d'un flux de lecture
    FileInputStream fi = new FileInputStream(files[i]);
    /* // création d'un tampon de lecture sur ce flux
    BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
    // création d'en entrée Zip pour ce fichier
    ZipEntry entry = new ZipEntry(files[i]);
    // ajout de cette entrée dans le flux d'écriture de l'archive Zip
    out.putNextEntry(entry);
    // écriture du fichier par paquet de BUFFER octets
    // dans le flux d'écriture
    int count;
    while((count = buffi.read(data, 0, BUFFER)) != -1) {
              out.write(data, 0, count);
                   // Close the current entry
    out.closeEntry();
    // fermeture du flux de lecture
              buffi.close();*/
    /*     // fermeture du flux d'écriture
         out.close();
         buff.close();
         checksum.close();
         dest.close();
         System.out.println("checksum: " + checksum.getChecksum().getValue());*/
         // traitement de toute exception
    catch(Exception ex) {
              ex.printStackTrace();
    And here is the error stack :
    "D:\jdev32\java1.2\jre\bin\javaw.exe" -mx50m -classpath "D:\jdev32\myclasses;D:\jdev32\lib\jdev-rt.zip;D:\jdev32\jdbc\lib\oracle8.1.7\classes12.zip;D:\jdev32\lib\connectionmanager.zip;D:\jdev32\lib\jbcl2.0.zip;D:\jdev32\lib\jgl3.1.0.jar;D:\jdev32\java1.2\jre\lib\rt.jar" pack_zip.czip
    Adding: accueil188.cfm
    java.io.FileNotFoundException: accueil188.cfm (Le fichier spécifié est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
         void java.io.FileInputStream.<init>(java.lang.String)
         void pack_zip.fzip.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.setPressed(boolean)
         void javax.swing.plaf.basic.BasicButtonListener.mouseReleased(java.awt.event.MouseEvent)
         void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
         void java.awt.Component.processEvent(java.awt.AWTEvent)
         void java.awt.Container.processEvent(java.awt.AWTEvent)
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
         boolean java.awt.EventDispatchThread.pumpOneEvent()
         void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
         void java.awt.EventDispatchThread.run()
    Thank you very much

    One easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
    Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
    I hope these could help you.

  • Problem in JSF with Swing in a web application

    hi
    i am using jsf for my online projects.my problem is that when i use Swing concept ,the server is closed automatically when i click the swing dialog option 'OK', how can i protect server being closed automatically when user click the the options of Swing dialog box.it is so tedious because my application is going to integrate
    with online server?
    my swing java file is
    * FileExistsDialog.java
    package com.obs.ftw.util.alert;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.Rectangle2D;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.plaf.metal.MetalLookAndFeel;
    * FileExistsDialog: A JOptionPane-like dialog that displays the message
    * that a file exists.
    public class FileExistsDialog extends JDialog {
    * The component that gets the focus when the window is first opened
    private Component initialFocusOwner = null;
    * Command string for replace action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_REPLACE = "OK"/*NOI18N*/;
    * Command string for a cancel action (e.g., a button).
    * This string is never presented to the user and should
    * not be internationalized.
    private String CMD_CANCEL = "CANCEL"/*NOI18N*/;
    // Components we need to access after initialization
    private JButton replaceButton = null;
    private JButton cancelButton = null;
    public FileExistsDialog(){
         System.out.println("INSIDE THE FILE EXIST DIALOG");
         JFrame frame = new JFrame() {
         public Dimension getPreferredSize() {
         return new Dimension(200,100);
         frame.setTitle("Debugging frame");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
         frame.setVisible(false);
    FileExistsDialog dialog = new FileExistsDialog(frame, true);
         dialog.addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent event) {
         System.exit(0);
         public void windowClosed(WindowEvent event) {
         System.exit(0);
         dialog.pack();
         dialog.setVisible(true);
    * Creates a new FileExistsDialog
    * @param parent parent frame
    * @param modal modal flag
    public FileExistsDialog(Frame parent,boolean modal) {
    super(parent, modal);
         //initResources();
         System.out.println("INSIDE THE FILE EXIST DIALOG CONSTRUCTOR");
    initComponents();
    pack();
    * Determines the locale, loads resources
    /* public void initResources() {
         Locale locale = Locale.getDefault();
    resources = ResourceBundle.getBundle(
              "samples.resources.bundles.FileExistsDialogResources", locale);
    imagePath = resources.getString("images.path");
    }*/ // initResources()
    * Sets all of the buttons to be the same size. This is done
    * dynamically after the buttons are created, so that the layout
    * automatically adjusts to the locale-specific strings.
    private void equalizeButtonSizes() {
         System.out.println("INSIDE THE equalizeButtonSizes()");
    String[] labels = new String[] {
    replaceButton.getText(),
         cancelButton.getText()
         // Get the largest width and height
         Dimension maxSize= new Dimension(0,0);
         Rectangle2D textBounds = null;
         Dimension textSize = null;
    FontMetrics metrics =
              replaceButton.getFontMetrics(replaceButton.getFont());
         Graphics g = getGraphics();
         for (int i = 0; i < labels.length; ++i) {
         textBounds = metrics.getStringBounds(labels, g);
         maxSize.width =
         Math.max(maxSize.width, (int)textBounds.getWidth());
         maxSize.height =
         Math.max(maxSize.height, (int)textBounds.getHeight());
    Insets insets =
         replaceButton.getBorder().getBorderInsets(replaceButton);
    maxSize.width += insets.left + insets.right;
    maxSize.height += insets.top + insets.bottom;
    // reset preferred and maximum size since BoxLayout takes both
         // into account
    replaceButton.setPreferredSize((Dimension)maxSize.clone());
    cancelButton.setPreferredSize((Dimension)maxSize.clone());
    replaceButton.setMaximumSize((Dimension)maxSize.clone());
    cancelButton.setMaximumSize((Dimension)maxSize.clone());
    } // equalizeButtonSizes()
    * This method is called from within the constructor to
    * initialize the dialog.
    private void initComponents() {
         System.out.println("INSIDE THE initComponents()");
         // Configure the window, itself
    Container contents = getContentPane();
    contents.setLayout(new GridBagLayout ());
    GridBagConstraints constraints = null;
    setTitle("Waring");
         // accessibility - all applets, frames, and dialogs should
         // have descriptions
         this.getAccessibleContext().setAccessibleDescription("Descriptions");
         addWindowListener(new WindowAdapter() {
         public void windowOpened(WindowEvent event) {
              // For some reason the window opens with no focus owner,
              // so we need to force the issue
         if (initialFocusOwner != null) {
              initialFocusOwner.requestFocus();
              // Only do this the 1st time the window is opened
              initialFocusOwner = null;
         public void windowClosing(WindowEvent event) {
         System.out.println("INSIDE THE windowClosing");     
         // Treat it like a cancel
              windowAction(CMD_CANCEL);
         // image
    JLabel imageLabel = new JLabel();
    imageLabel.setIcon(
    new ImageIcon("/images/degraded_large.gif"));
    // accessibility - set name so that low vision users get a description
    imageLabel.getAccessibleContext().setAccessibleName("OK");
    constraints = new GridBagConstraints ();
    constraints.gridheight = 2;
    constraints.insets = new Insets(12, 33, 0, 0);
    constraints.anchor = GridBagConstraints.NORTHEAST;
    contents.add(imageLabel, constraints);
    // header
    JLabel headerLabel = new JLabel ();
    headerLabel.setText("SAMPLE");
    headerLabel.setForeground(
         new Color(MetalLookAndFeel.getBlack().getRGB()));
    constraints = new GridBagConstraints ();
    constraints.insets = new Insets(12, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(headerLabel, constraints);
         // Actual text of the message
         JTextArea contentTextArea = new JTextArea();
    contentTextArea.setEditable(false);
    contentTextArea.setText("SAMPLE");
    contentTextArea.setBackground(
              new Color(MetalLookAndFeel.getControl().getRGB()));
    // accessibility -- every component that can have the
         // keyboard focus must have a name. This text area has no
         // label, so the name must be set explicitly (if it had a
         // label, the name would be pulled from the label).
    contentTextArea.getAccessibleContext().setAccessibleName(
              "CONTENTNAME");
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.insets = new Insets(0, 12, 0, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(contentTextArea, constraints);
         // Buttons
         JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout (new BoxLayout(buttonPanel, 0));
         replaceButton = new JButton();
         replaceButton.setActionCommand(CMD_REPLACE);
    replaceButton.setText("OK");
    replaceButton.setToolTipText("TO OK");
         replaceButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(replaceButton);
    // spacing
    buttonPanel.add(Box.createRigidArea(new Dimension(5,0)));
         cancelButton = new JButton();
         cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.setText("CANCEL");
    cancelButton.setNextFocusableComponent(replaceButton);
         cancelButton.setToolTipText("TO CANCEL");
         cancelButton.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent event) {
         windowAction(event);
    buttonPanel.add(cancelButton);
    constraints = new GridBagConstraints ();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.insets = new Insets(12, 12, 11, 11);
    constraints.anchor = GridBagConstraints.WEST;
    contents.add(buttonPanel, constraints);
         // Equalize the sizes of all the buttons
         equalizeButtonSizes();
         // For some reason, the dialog appears with no input focus.
         // We added a window listener above to force the issue
         initialFocusOwner = replaceButton;
    } // initComponents()
    * The user has selected an option. Here we close and dispose the dialog.
    * If actionCommand is an ActionEvent, getCommandString() is called,
    * otherwise toString() is used to get the action command.
    * @param actionCommand may be null
    private void windowAction(Object actionCommand) {
         System.out.println("INSIDE THE WINDOW ACTION");
         String cmd = null;
    if (actionCommand != null) {
         if (actionCommand instanceof ActionEvent) {
         cmd = ((ActionEvent)actionCommand).getActionCommand();
         } else {
         cmd = actionCommand.toString();
         if (cmd == null) {
         // do nothing
         } else if (cmd.equals(CMD_REPLACE)) {
         System.out.println("your replace code here...");
         } else if (cmd.equals(CMD_CANCEL)) {
         System.out.println("your cancel code here...");
         setVisible(false);
         dispose();
    } // windowAction()
    * This main() is provided for debugging purposes, to display a
    * sample dialog.
    // main()
    } // class FileExistsDialog
    and calling java function is
    public String fileDialog(){
         return "Success";
    public void processFile(ActionEvent event){
         System.out.println("INSIDE THE FILE DIALOG");
         FileExistsDialog file     = new FileExistsDialog();
         System.out.println("SUCCESS");
    called from
         <h:commandButton action="#{userLogin.fileDialog}" actionListener="#{userLogin.processFile}"></h:commandButton>
    pls help me as soon
    advance thanks
    rgds
    oasisdeserts

    Swing is GUI library for use in desktop applications.
    JSF is a web application framework which runs on an application server and is accessed by clients via web browsers.
    To fully understand what you have done, try accessing your application from a different machine than the server.
    To answer your question, don't invoke System.exit() if you would like the process to continue. But that is the least of your problems.

  • Problem in using JScrollPane

    hiii i am creating an image editor in java...
    here is my code for using scrollpane
      contentpane = getContentPane();
                view  =  new JLabel(new ImageIcon(bufferedImage));
                scrollpane =  new JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(800,600));
                contentpane.add(scrollpane);The problem is that the content of viewport does not change...i.e if i apply any effect to an image....after that as soon as i use the scrollbar, the viewport displays the original image!!!
    What is the problem??
    could someone suggest a solution?

    Can you plzz help me with this??...it is very urgent...
    As i am creating an image editor, so the scrollpane must be updated as soon as i apply any effect to it .....
    along with that whenever a user selects a file from FileDialog...then also it must be updated!!!
    I have extended JFrame for my main class.
    //this is the code i have written when user selects a new file...
    contentpane = getContentPane();
    view =  new JLabel(new ImageIcon(bufferedImage));
    view.setVisible(true);
    crollpane =  new                   JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(200,200));
                contentpane.add(scrollpane);
    // This is the code for scollpane update
        iicon.setImage(bufferedImage);
          view.setIcon(iicon);
          scrollpane =  new                     JScrollPane(view,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
                scrollpane.setPreferredSize(new Dimension(200,200));
                contentpane.add(scrollpane);
               scrollpane.updateUI();Message was edited by:
    rav_ahj

  • Problem in Uploading a File by Applet

    Hi Members,
    * I have faced problem while uploading a file from client to server by ftp protocol using APPLET(No JSP) only
    * I am getting exception while running....
    * My source code is as follows,
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    public class UploadAndDownload extends Applet implements ActionListener {
         Button upload;
         Button browse;
         TextField filename;
         File source = null;
         Label name;
         StringBuffer sb;
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
         public void init() {
              setLayout(new FlowLayout());
              upload = new Button("Upload");
              browse = new Button("Browse");
              name = new Label("Filename");
              filename = new TextField("", 45);
              add(name);
              add(filename);
              add(upload);
              add(browse);
              upload.addActionListener(this);
              browse.addActionListener(this);
         public void actionPerformed(ActionEvent evt) {
              // Code for browsing a file
              String input_file_name = "";
              if (evt.getSource() == browse)
                   Frame parent = new Frame();
                   FileDialog fd = new FileDialog(parent, "Select a file", FileDialog.LOAD);
                   fd.setVisible(true);
                   input_file_name = fd.getFile();
                   filename.setText(input_file_name);
                   // Gets the file from the file dialog and assign it to the source
                   source = new File(input_file_name);
                   repaint();
              // Code for Uploading a file to the server
              if (evt.getSource() == upload) {
                   // Appending the server pathname in string buffer
                   sb = new StringBuffer("ftp://");
                   sb.append("2847");
                   sb.append(':');
                   sb.append("Websphere25");
                   sb.append("@");
                   sb.append("172.16.1.111");
                   sb.append('/');
                   sb.append(input_file_name);
                   sb.append(";type=i");
                   try {
                        URL url = new URL(sb.toString());
                        URLConnection urlc = url.openConnection();
                        bos = new BufferedOutputStream(urlc.getOutputStream());
                        bis = new BufferedInputStream(new FileInputStream(source));
                        int i;
                        // Read from the inputstream and write it to the outputstream
                        while ((i = bis.read()) != -1) {
                             bos.write(i);
                   } catch (MalformedURLException e) {
                        e.printStackTrace();
                   } catch (IOException e) {
                        e.printStackTrace();
                   } finally {
                        if (bis != null)
                             try {
                                  bis.close();
                             } catch (IOException ioe) {
                                  ioe.printStackTrace();
                        if (bos != null)
                             try {
                                  bos.close();
                             } catch (IOException ioe) {
                                  ioe.printStackTrace();
    MY EXCEPTION IS,
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.net.SocketPermission 172.16.1.111:80 connect,resolve)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.ftp.FtpURLConnection.getOutputStream(Unknown Source)
         at UploadAndDownload.actionPerformed(UploadAndDownload.java:68)
         at java.awt.Button.processActionEvent(Unknown Source)
         at java.awt.Button.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)* Please let me know what problem in my code....
    * Thanks in advance....

    * Thanks for your reply....
    * I have signed my policy file by giving AllPermission and mentioned in java.security file in bin folder....
    * My question is , by giving AllPermission , can we access and do all permissions like ( SecurityPermission, AWTPermission, SocketPermission, NetPermission, FilePermission, SecurityPermission etc )...
    * My policy file is looks like follow,
    /* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
    /* DO NOT EDIT */
    grant {
      permission java.security.AllPermission;
    };* If i signed the policy like above, and when i run the applet file in InternetExplorer now , it thorws the following exception on my console,
    java.net.ProtocolException: cannot write to a URLConnection if doOutput=false - call setDoOutput(true)
         at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
         at sun.net.www.protocol.ftp.FtpURLConnection.getOutputStream(Unknown Source)
         at UploadAndDownload.actionPerformed(UploadAndDownload.java:68)
         at java.awt.Button.processActionEvent(Unknown Source)
         at java.awt.Button.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)* Please let me know , how to solve this and give me your suggestion on the above process...
    * Thanks in advance...
    Regards,
    JavaImran

  • Opening a file with custom FileDialog. (VERY URGENT)

    hi everybody,
    I have a problem and stuck. I have developed a MDI application that provides all function like open saved files, create new, edit and lots of other. It only opens, save ,edit etc the graphical diagrams inside JInternalFrames. I have an icon on my desktop when clicked opens this Application. Just like Editplus, Word or some other application when you click on the icon it opens that. Same way I have created such functionality.
    Now instead of this I have created a custom FileDialogfrom which the user selects this application and is opened. Now I have small icon for this FileDialog on the desktop when opened gives the interface to select the files to be opened. My FileDialog just looks like the FileDialog but some more functionality and more components like JComboBox, Jlist, JtextField, JButtons etc. in it and have removed some of them. I am extending JDialog. But now my probelm is when you select a file and click open, it should open the selected file. How can I achive this functionality in my custom FileDialog as I am not extending FileDialog and as it is built in the FileDialog. How can I open the files with any extension in it's related application e.g .doc files to be opened in MicrosoftWord, .txt to be opened in notepad, .c or .cpp in Visual Studio C++ etc.
    How can I put this kind of functionality in my custom FileDialog. It's really important for me please any comments will help me alot. Thanks for the help

    Hello,
    I think you can write :
    Runtime.getRuntime().exec("start.exe " + MyFileDialog.getDirectory() + MyFileDialog.getFile());
    So, "start.exe" choose the application (not valid for NT machine), ".getDirectory()" return the PATH and ".getFile()" return the NAME.
    Best regards from France
    Thierry

  • Attachment Problem in JavaMail API

    Can anybody help me...
    when 'm trying to attach a file to a mailing aplication(sending attachment),
    an flurry of exceptions are occuring...
    'm using win98 and JDK1.4
    here is the code..can anybody provide a viable solution that works?
    thanks in advance
    * main1.java
    * Created on August 20, 2002, 2:55 PM
    * @author Shamik Ghosh
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.net.*;
    import java.io.*;
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class main1 extends javax.swing.JFrame implements ActionListener,ItemListener {
    JMenuBar mbar;
    JMenu file,other,help;
    JMenuItem open,save,read_mail;
    JFrame frame_f;
    FileReader fr;
    BufferedReader br;
    boolean check;
    String from_m,smtp_m,from_m1,smtp_m1,result,
    s1,s2,from_server,from_host,to_file,which_file,attach_text;
    File f;
    /** Creates new form main1 */
    public main1() {
    initComponents();
    setSize(550,500);
    setResizable(false);
    // ------------------------centering the display
    int width=550; // note that "width" & "height" are keywords and
    int height=500; // JAVA defined variables.
    Dimension screen=Toolkit.getDefaultToolkit().getScreenSize();
    int x=(screen.width-width)/2;
    int y=(screen.height-height)/2;
    setBounds(x,y,width,height);
    try{
    fr=new FileReader("address.txt");
    br=new BufferedReader(fr);
    String s;
    while((s=br.readLine()) !=null)
    {jComboBox1.addItem(s);}
    fr.close();
    }catch(Exception e){ System.out.println(e);}
    check_info();//calling the method to check the info
    //jTextField1.setText(from_m);
    //jTextField3.setText(smtp_m);
    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    private void initComponents() {//GEN-BEGIN:initComponents
    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jTextField2 = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    jTextField3 = new javax.swing.JTextField();
    jComboBox1 = new javax.swing.JComboBox();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jLabel4 = new javax.swing.JLabel();
    jRadioButton3 = new javax.swing.JRadioButton();
    jRadioButton4 = new javax.swing.JRadioButton();
    jButton4 = new javax.swing.JButton();
    jButton6 = new javax.swing.JButton();
    jButton5 = new javax.swing.JButton();
    jTextField4 = new javax.swing.JTextField();
    jLabel5 = new javax.swing.JLabel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jTextArea1 = new javax.swing.JTextArea();
    jScrollPane2 = new javax.swing.JScrollPane();
    jTextArea2 = new javax.swing.JTextArea();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    //actionlisteners
    jButton1.addActionListener(this);
    jButton2.addActionListener(this);
    jButton3.addActionListener(this);
    jButton4.addActionListener(this);
    jButton5.addActionListener(this);
    jButton6.addActionListener(this);
    mbar=new JMenuBar();
    setJMenuBar(mbar);
    file=new JMenu("File");
    other=new JMenu("Other");
    help=new JMenu("Help");
    mbar.add(file);
    mbar.add(other);
    mbar.add(help);
    getContentPane().setLayout(null);
    setTitle("MailMan :Designed and Programmed by Shamik Ghosh");
    //setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    addWindowListener(new java.awt.event.WindowAdapter() {
    public void windowClosing(java.awt.event.WindowEvent evt) {
    exitForm(evt);
    jLabel1.setText("From:");
    getContentPane().add(jLabel1);
    jLabel1.setBounds(30, 20, 32, 17);
    jLabel2.setText("To:");
    getContentPane().add(jLabel2);
    jLabel2.setBounds(30, 60, 17, 17);
    getContentPane().add(jTextField1);
    jTextField1.setBounds(110, 20, 240, 21);
    getContentPane().add(jTextField2);
    jTextField2.setBounds(110, 60, 240, 21);
    jLabel3.setText("Smtp Server:");
    getContentPane().add(jLabel3);
    jLabel3.setBounds(10, 100, 74, 17);
    getContentPane().add(jTextField3);
    jTextField3.setBounds(110, 100, 240, 21);
    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] {  }));
    jComboBox1.setToolTipText("Mail Addresses");
    jComboBox1.setAutoscrolls(true);
    jComboBox1.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    jComboBox1ActionPerformed(evt);
    getContentPane().add(jComboBox1);
    jComboBox1.setBounds(110, 150, 240, 20);
    jComboBox1.setFont(new java.awt.Font("Abadi MT Condensed Light", 1, 12));
    jButton1.setToolTipText("Send the message you have typed");
    jButton1.setMnemonic('m');
    jButton1.setFont(new java.awt.Font("Abadi MT Condensed Light", 1, 12));
    jButton1.setText("Send Mail");
    getContentPane().add(jButton1);
    jButton1.setBounds(370, 300, 160, 25);
    //jButton2.setFont(new java.awt.Font("Abadi MT Condensed Light", 0, 12));
    jButton2.setText("Save Info");
    jButton2.setToolTipText("Save Settings for more mails");
    jButton2.setMnemonic('I');
    getContentPane().add(jButton2);
    jButton2.setBounds(370, 340, 160, 25);
    jButton3.setText("Clear ");
    jButton3.setMnemonic('C');
    jButton3.setToolTipText("Clear all text");
    getContentPane().add(jButton3);
    jButton3.setBounds(370, 380, 160, 27);
    jLabel4.setText("Your Contact Addresses");
    jLabel4.setFont(new java.awt.Font("Arial Narrow", 0, 12));
    getContentPane().add(jLabel4);
    jLabel4.setBounds(110, 130, 200, 15);
    jRadioButton3.setText("Use Log File");
    jRadioButton3.setMnemonic('L');
    getContentPane().add(jRadioButton3);
    jRadioButton3.setBounds(260, 310, 90, 25);
    jRadioButton4.setText("No Log File");
    //jRadioButton4.setMnemonic('N');
    //getContentPane().add(jRadioButton4);
    //jRadioButton4.setBounds(260, 340, 86, 25);
    jButton4.setText("Undo Info");
    jButton4.setMnemonic('U');
    jButton4.setToolTipText("Undo settings");
    getContentPane().add(jButton4);
    jButton4.setBounds(260, 380, 87, 27);
    getContentPane().add(jTextField4);
    jTextField4.setBounds(20, 380, 210, 21);
    jLabel5.setText("Attachment");
    jLabel5.setFont(new java.awt.Font("Abadi MT Condensed Light", 1, 12));
    getContentPane().add(jLabel5);
    jLabel5.setBounds(70, 360, 70, 15);
    jButton5.setFont(new java.awt.Font("Abadi MT Condensed Light", 1, 12));
    jButton5.setText("Browse");
    jButton5.setMnemonic('B');
    jButton5.setToolTipText("Browse files for Attachment");
    getContentPane().add(jButton5);
    jButton5.setBounds(150, 350, 80, 25);
    jButton6.setText("Attach & Send");
    jButton6.setMnemonic('A');
    jButton6.setToolTipText("Attach File & Send Mail");
    getContentPane().add(jButton6);
    jButton6.setBounds(260, 340, 86, 25);
    jScrollPane1.setViewportView(jTextArea1);
    getContentPane().add(jScrollPane1);
    jScrollPane1.setBounds(370, 20, 160, 270);
    jLabel10.setText("Type your mail:");
    jLabel10.setFont(new java.awt.Font("Abadi MT Condensed Light", 1, 12));
    getContentPane().add(jLabel10);
    jLabel10.setBounds(370, 5, 125, 10);
    jScrollPane2.setViewportView(jTextArea2);
    getContentPane().add(jScrollPane2);
    jScrollPane2.setBounds(20, 200, 340, 90);
    jLabel6.setText("(your ISP smtp)");
    jLabel6.setFont(new java.awt.Font("Abadi MT Condensed Light", 0, 10));
    getContentPane().add(jLabel6);
    jLabel6.setBounds(10, 120, 70, 12);
    jLabel7.setText("porgrammed and designed by : Shamik Ghosh");
    jLabel7.setFont(new java.awt.Font("Abadi MT Condensed Light", 0, 10));
    getContentPane().add(jLabel7);
    jLabel7.setBounds(260, 410, 160, 12);
    jLabel8.setText("[email protected]");
    jLabel8.setFont(new java.awt.Font("Abadi MT Condensed Light", 0, 10));
    getContentPane().add(jLabel8);
    jLabel8.setBounds(420, 410, 80, 12);
    jLabel9.setText("Msg.for the Mail Sent:");
    jLabel9.setForeground(java.awt.Color.black);
    jLabel9.setFont(new java.awt.Font("Abadi MT Condensed Light", 0, 10));
    getContentPane().add(jLabel9);
    jLabel9.setBounds(20, 180, 80, 12);
    file.add(open=new JMenuItem("Open"));
    open.setAccelerator(KeyStroke.getKeyStroke('O',Event.CTRL_MASK,true));
    file.addSeparator();
    file.add(save=new JMenuItem("Save"));
    save.setAccelerator(KeyStroke.getKeyStroke('S',Event.CTRL_MASK,true));
    file.addSeparator();
    other.add(read_mail=new JMenuItem("Add Address"));
    read_mail.setAccelerator(KeyStroke.getKeyStroke('A',Event.CTRL_MASK,true));
    other.addSeparator();
    //adding actionListener to menuitems
    open.addActionListener(this);
    save.addActionListener(this);
    read_mail.addActionListener(this);
    jComboBox1.addItemListener(this);
    pack();
    }//GEN-END:initComponents
    public void itemStateChanged(ItemEvent ie)
    String add_list;
    add_list=String.valueOf(jComboBox1.getSelectedItem());
    jTextField2.setText(add_list);
    } // for item event source
    public void actionPerformed(ActionEvent ae)
    if(ae.getSource()==jButton1)
    if(ae.getSource()==jButton1) {
    SwingUtilities.invokeLater(new Runnable()
    {  public void run()
    sendMail();
    if(ae.getSource()==jButton2) //save info
    from_m =jTextField1.getText();
    smtp_m =jTextField3.getText();
    from_m1 =from_m+"\n";
    smtp_m1 =jTextField3.getText();
    result =from_m1+smtp_m1;
    try{
    byte buf[]=result.getBytes();
    OutputStream fo=new FileOutputStream("info.txt");
    for(int i=0;i<buf.length; i++ )
    fo.write(buf);
    fo.close();
    }catch(Exception e){ System.out.println(e);}
    jTextField1.setEditable(false);
    jTextField3.setEditable(false);
    if(ae.getSource()==jButton3) //clear
    jTextArea1.setText(" ");
    jTextArea2.setText(" ");
    if(ae.getSource()==jButton4)//undo info
    jTextField1.setEditable(true);
    jTextField3.setEditable(true);
    if(ae.getSource()==jButton5)//browse for attachment
    try {
    FileDialog file = new FileDialog (main1.this, "Load File", FileDialog.LOAD);
    file.setFile ("*.*"); // Set initial filename filter
    file.show(); // Blocks
    String curFile;
    if ((curFile = file.getFile()) != null) {
    String filename = file.getDirectory() + curFile;
    char[] data;
    setCursor (Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    f = new File (filename);
    try {
    System.out.println("INSIDE TRY");
    FileReader fin = new FileReader (f);
    int filesize = (int)f.length();
    data = new char[filesize];
    fin.read (data, 0, filesize);
    setCursor (Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    } catch (Exception exc) {}
    jTextField4.setText(filename);
    } catch(Exception e){}
    if(ae.getSource()==jButton6)//send attachment & Mail
    try{
    sendmail2();
    }catch(Exception e){}
    if(ae.getSource()==open)//menu open
    if(ae.getSource()==save)//menu save
    if(ae.getSource()==read_mail)//menu read_mail
    address_add();
    } //actionperformed
    public void sendmail2()
    try {
    //which_file,attach_text
    from_server=jTextField3.getText();
    from_host=jTextField1.getText();
    to_file=jTextField2.getText();
    which_file=jTextField4.getText();
    attach_text=jTextArea1.getText();
    //getting system property
    Properties props=System.getProperties();
    //setup mail server
    props.put("mail.smtp.host",from_server);
    //get session
    Session session=Session.getInstance(props,null);
    // Define message
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from_host));
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(to_file));
    message.setSubject("Hello JavaMail Attachment");
    //define message part
    BodyPart messageBodyPart=new MimeBodyPart();
    // Fill the message
    messageBodyPart.setText(attach_text);
    // Create a Multipart
    Multipart multipart = new MimeMultipart();
    // Add part one
    multipart.addBodyPart(messageBodyPart);
    //attaching**********************************secon Part Attachment
    //creating second body part
    messageBodyPart=new MimeBodyPart();
    DataSource source=new FileDataSource(which_file); //was filename
    //setting data handler to the attachment
    messageBodyPart.setDataHandler(new DataHandler(source));
    //setting the filename
    messageBodyPart.setFileName(which_file);
    //adding part two
    multipart.addBodyPart(messageBodyPart);
    //put parts in the message
    message.setContent(multipart);
    //Sending msg
    Transport.send(message);
    }catch(Exception e){}
    } //sendmail2
    public void address_add()
    addr=jTextField2.getText();
    str_addr=addr+"\n";
    //jComboBox1.addItem(" ");
    jComboBox1.addItem(addr);
    System.out.println("INSIDE WRITING METHOD");
    try{
    byte buf[]=str_addr.getBytes();
    OutputStream f0=new FileOutputStream("address.txt",true);
    for(int i=0;i<buf.length; i++ )
    f0.write(buf[i]);
    f0.close();
    }catch(Exception e){ System.out.println(e);}
    public void check_info()
    try{
    fr=new FileReader("info.txt");
    br=new BufferedReader(fr);
    while((s1=br.readLine()) !=null && (s2=br.readLine()) !=null)
    jTextField1.setText(s1);
    jTextField3.setText(s2);
    break;
    fr.close();
    }catch(Exception e){ System.out.println(e);}
    public void sendMail()
    {  try
    Socket s = new Socket(jTextField3.getText(), 25);
    out = new PrintWriter(s.getOutputStream());
    in = new BufferedReader(new
    InputStreamReader(s.getInputStream()));
    String hostName
    = InetAddress.getLocalHost().getHostName();
    send(null);
    send("Host " + hostName);
    send("Mail FROM: " + jTextField1.getText());
    send("Rcpt TO: " + jTextField2.getText());
    send("Data");
    out.println(jTextArea1.getText());
    send(".");
    s.close();
    catch (IOException exception)
    {  jTextArea2.append("Error: " + exception);
    String err="Message cannot be sent!"+"\n"
    +"Please verify the setting(s)."+
    "\n"+"Else there may be a NetWork Problem."+
    "\n"+"Please verify and Try Again.";
    JOptionPane.showMessageDialog(frame_f,err,"Message Transmission Failure",JOptionPane.ERROR_MESSAGE);
    public void send(String s) throws IOException
    {  if (s != null)
    {  jTextArea2.append(s + "\n");
    out.println(s);
    out.flush();
    String line;
    if ((line = in.readLine()) != null)
    jTextArea2.append(line + "\n");
    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
    // Add your handling code here:
    }//GEN-LAST:event_jComboBox1ActionPerformed
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
    System.exit(0);
    }//GEN-LAST:event_exitForm
    * @param args the command line arguments
    public static void main(String args[]) {
    new main1().show();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JRadioButton jRadioButton4;
    private javax.swing.JButton jButton4;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel10;
    private BufferedReader in;
    private PrintWriter out;
    private String addr,str_addr;
    // End of variables declaration//GEN-END:variables

    Hi I have this problem which I believe you can help me resolve:
    In my code, there are two lines:
    message.setContent(messageBody, "text/html"); // this sets body of message
    message.setContent(bodyPartObject); // this attaches a file
    but it turns out that the second "setContent" statement over-writes the first one, so that I get no message in the body of the mail.
    What can I do about it, shamik1? Thanks!

  • Problem with file dialog (root frame)

    Hi guys
    I�m having a problem with open up a filedialog.
    I have a rendered jlist and the are some items inside. The user, can right click any item and choose from a list some commands (print, save, update etc)
    Everything works fine but when he clicks the SAVE option (again, right click and choose save)
    FileDialog fd = new FileDialog(new JFrame(),"Save PAX list",FileDialog.SAVE);
    I cannot use new JFrame() (as I did above) because it might block the application.
    For this I�m trying to get the root by:
    Component c = SwingUtilities.getRoot((Component)e.getSource());
    JFrame myFrame = (JFrame)c;
    And than:
    FileDialog fd = new FileDialog myFrame,"Save PAX list",FileDialog.SAVE);
    This get me a null frame :- (
    Anyone?

    The following worked on a "normal" menu item. I didn't test it on a "popup" menu item:
    JMenuItem mi = (JMenuItem)e.getSource();
    JPopupMenu popup = (JPopupMenu)mi.getParent();
    Component c = SwingUtilities.windowForComponent(popup.getInvoker());
    System.out.println(c);

Maybe you are looking for

  • How can I turn on spellcheck as default?

    I was happily typing along and noticed both a typo and the fact that the typo was NOT underlined in red squiggles. Hmmmm, I thought. Fiddling around, I discovered an option on right-click that allowed Me to turn on spellcheck. Now, every time I type

  • Error in Recv SOAP message

    Hi, We have Proxy to SOAP Sync. scenario. This was working fine before the SOAP Receiver service that we were accessing change the port from 8080 to 9080. Now the below error is coming com.sap.engine.interfaces.messaging.api.exception.MessagingExcept

  • Colour management - AppleCinemaHD/Quar6.5/Acrobat7

    We are using Mac G5's and Apple Cinema Display. The software we are using is Adobe Acrobat 7 (Suite) and quark 6.5. At the moment all the applications seem to display colour differently so I'm unsure what is true to the real colour for print. Please

  • Diagnosing errors from Net Services trace files

    Hi, does anybody have a link to any documentation where it's explained how to interpret errors in Net Service trace files. For example, a snippet of a trace file looks like this: [30-JUN-2009 14:32:39:302] nttcni: trying to connect to socket 1836. [3

  • Maintain number range object for object J_1IINTNUM

    Dear, While doing GRN i am getting this error: Maintain number range object for object J_1IINTNUM, year 2009, excise group Maintain number range object for object J_1IRG23A1, year 2009, excise  group E1 Maintain number range object for object J_1IRG2