Please Find the error in this code

Hi ,  I am new to ajax.My problem is that i cannot insert a value in to a textfield which is fetched from a database(MySql).  I have two jsp pages.Definition1.jsp and definition.jsp. I am giving the code below.[b]But it does not work[/b]. I don't know where is the problem. I am using Mozilla Firefox..  [b]Definition1.jsp[/b]  <html>  <%@ page language="java"%>  <%@page contentType="text/html" %>   <script language="Javascript" type="text/javascript">   function createRequestObject() { var tmpXmlHttpObject;   if (window.XMLHttpRequest) {   tmpXmlHttpObject = new XMLHttpRequest();       } else if (window.ActiveXObject) {   tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP"); }  return tmpXmlHttpObject; }  //call the above function to create the XMLHttpRequest object var http = createRequestObject();  function makeGetRequest(wordId) { //make a connection to the server ... specifying that you intend to make a GET request  //to the server. Specifiy the page name and the URL parameters to send http.open('get','definition.jsp?id='+wordId);       //assign a handler for the response http.onreadystatechange = processResponse;       //actually send the request to the server http.send(null); }  function processResponse() { //check if the response has been received from the server if(http.readyState == 4){       //read and assign the response from the server           var result2 = http.responseText;  var result = http.responseXML.documentElement;                  //do additional parsing of the response, if needed            //in this case simply assign the response to the contents of the <div> on the page.  document.getElementById('description').innerHTML = result2;//[b]this works correctly[/b]           alert(result.getElementByTagName('p')[0].childNodes[0].nodeValue);//nothing happends here            document.getElementById('name').value=result.getElementsByTagName('p')[0].childNodes[0].nodeValue;           [u][b]//above code does not works and this is my problem[/b][/b[/u]] } }   </script> <body>  <form> <input type="text" id="name" size=10 value=" "></input>  </form> <h1>Have you heard these terms before?</h1>  Ceraunophobia More about Ceraunophobia<br> Astraphobia More about Astraphobia<br>   <div id="description">  </div>  </body>  </html>     [b]Definition.jsp[/b]    <%@ page language="java"%><%@ page import="java.sql.*,java.io.*,java.util.*,javax.servlet.*"%> <?xml version="1.0" encoding="UTF-8"?>  <% response.setContentType("text/xml"); response.setHeader("Cache-Control", "no-cache"); response.setHeader("pragma","no-cache"); Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con=DriverManager.getConnection("jdbc:mysql://itserver:3306/manzor?user=root&password="); Statement st= con.createStatement(); Statement st1= con.createStatement();  ResultSet rs,rs1; String id=request.getParameter("id");  rs=st.executeQuery("select * from user where USERTYPE='"+id+"'");  if(rs.next()){    %>  // p tag is here , can't display it //<p> <p> <%=rs.getString(1)%></p>  //<p>  <%  }  %>[code]  [/code]  please help
Message was edited by:
manu_am
Message was edited by:
manu_am

I'm not an AWT expert, but here's my best guess to the problem...
I'm not sure that the ActionListener is the correct event listener to use here.
I don't think the straight TextArea throws action events, I could be wrong here I mainly have experience with swing.
What event are you trying to react to here? Also is there any reason for not using Swing? Then you can use the JTextArea.
Hope I'm of some help :)

Similar Messages

  • Please help in finding the error in this code

    Dear Friends,
    I am trying to make the value of 'Shift' on the basis of  BLDAT CPUDT & CPUTM of MKPF but I am doing something wrong. Kindly have a look at the following code, especially the IF..ELSEIF section and help me in finding the error.
    Regards,
    Alok.
    SELECT MBLNR MJAHR BKTXT BUDAT BLDAT CPUDT CPUTM USNAM
    INTO CORRESPONDING FIELDS OF TABLE I_MKPF1
    FROM MKPF
    WHERE
    BUDAT EQ S_BUDAT AND
    TCODE2 EQ 'MFBF'.
    ********************************************************ALOK 01.02.07
    LOOP AT I_MKPF1.
           I_MKPF-MBLNR = I_MKPF1-MBLNR.
           I_MKPF-MJAHR = I_MKPF1-MJAHR.
           I_MKPF-BKTXT = I_MKPF1-BKTXT.
           I_MKPF-BUDAT = I_MKPF1-BUDAT.
           I_MKPF-BLDAT = I_MKPF1-BLDAT.
           I_MKPF-CPUDT = I_MKPF1-CPUDT.
           I_MKPF-CPUTM = I_MKPF1-CPUTM.
           I_MKPF-USNAM = I_MKPF1-USNAM.
    IF   ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
    AND   ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'A'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
       AND  ( I_MKPF1-BLDAT <>  I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
      AND  ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) ).
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    APPEND I_MKPF.
    CLEAR I_MKPF.
    ENDLOOP.

    Hi.
    IF (  I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM < '160000' )
           AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'A'.
    ELSEIF  ( I_MKPF1-CPUTM >= '090000' AND I_MKPF1-CPUTM <= '110000' )
    AND ( I_MKPF1-BLDAT <> I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'C'.
    ELSEIF ( I_MKPF1-CPUTM >= '160000' AND I_MKPF1-CPUTM < '000000' )
    AND ( I_MKPF1-BLDAT = I_MKPF1-CPUDT ) .
    I_MKPF-SHIFT = 'B'.
    ENDIF.
    Try the above code ..
    Regards
    Sudheer

  • Can't find the error on this small code :S

    Hi , i've just compiled this code and i can't find what is wrong! :(
    The compiler is ok, but the output print its not what i was expect.
    If u insert 121 (capicua) the answer is: This number its not a capicua :S
    what is wrong?
    thanks!!
    Note: Don't create another code plz.
    import java.io.*;
    public class Capicua {
         public static void main (String[] args) throws Exception {
              int digit, num;
              int inverted = 0;
                   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                   System.out.print(" Insert number: ");
                   num=Integer.parseInt(br.readLine().trim());
                   while(num > 0) {
                   digit = num % 10;
                   num = num /10;
                   inverted = inverted * 10 + digit;
                   if(num == inverted) {
                        // to be capicua the number inserted must
                        //be equals to the inverted
                        System.out.println("Its Capicua!");      
                   }else{
                        System.out.println("This number is not a Capicua!");
    }

    Please use code tags (see button above posting box) when posting code. It makes it much easier to read.
    So, it appears that capicua means palindrome--the number reads the same backwards and forwards. Is that correct?
    There are ways of doing this without converting the 121 to a number, but I won't explain that unless you want.
    I think your problem is this line:
    if (num == inverted)
    You have changed "num" within your while loop. Therefore, num is no longer the original input 121.
    Try adding println statements like this to watch what happens:
    while(num > 0) {
      digit = num % 10;
      num = num /10;
      inverted = inverted * 10 + digit;
      System.out.println("digit = " + digit);
      System.out.println("num = " + num);
      System.out.println("inverted = " + inverted);
    }

  • Where's the error in this code...

    the following snippet of code throws a SQLException with a 'Invalid Handle' message.
    What's does this 'Invalid Handle' mean? And, which line of code is causing the problem?
    try {
    //RETRIEVE CITYLIST FROM DB
    cityList = statement.executeQuery("SELECT CityCode, CityName FROM CityList");
    while (cityList.next()) {
    //ADD CODES AND NAMES OF CITIES TO ARRAYLISTS
    String code = cityList.getString(1);
    String name = cityList.getString(2);
    codes.add(code);
    names.add(name);
    cityList.close();
    } catch (SQLException sql) {
    System.out.println("2-checkForAvailability.jsp..err->" + sql);
    Any help will be appreciated..
    regards
    Ushanta

    Yes, you don't declare the ResultSet inside that try block, so I'll assume that it's a data member of your class. I'd suggest that you make the ResultSet a local variable in that method and not try to hang onto it. Same for the statement:
    Statement statement = null;
    ResultSet cityList = null;
    try
    statement = connection.createStatement();
    cityList = statement.executeQuery("SELECT CityCode, CityName FROM CityList");
    while (cityList.next())
        String code = cityList.getString(1);
        String name = cityList.getString(2);
        codes.add(code);
        names.add(name);
    } catch (SQLException sql)
        sql.printStackTrace();
        System.err.println("SQL state: " + sql.getSQLState());
         System.err.println("SQL error: " + sql.getErrorCode());
    finally
        try
            if (cityList != null)
                cityList.close();
            if (statement != null)
                statement.close();
        catch (SQLException ignoreException)

  • Please give the meaning of this code

    Hi anyone please give the meaning of the below mentioned modify command code
      READ TABLE XKOMV INTO L_XKOMV
                  WITH KEY
                  KSCHL = 'ZGBC'.
      IF sy-subrc = 0.
        XKOMV-KINAK = 'X'.
        <b>MODIFY XKOMV TRANSPORTING KINAK WHERE KSCHL = 'ZFIK'.</b>
      ENDIF.
    Point will be sure.
    vijai

    Hello Vijaya,
    Its reading the Conditiuon table and checking for the condition type ZGBC in the document condition table. If it exists then its makeing the Condition ZFIK as in active. So   During pricing, the system ignores conditions that are valid but not active in this case ZFIK.
    Regards,
    <b>Reward Points if Useful</b>
    Sake Sharma

  • What is the error with this code ??

    i'm trying to execute the following AS3 code:
    var itemsArr:Array = new Array ();
    var i:int; 
          var loaderAds:URLLoader = new URLLoader();
          loaderAds.load(new URLRequest("ads.txt"));   
          loaderAds.addEventListener(Event.COMPLETE, completeHandlerAds);
          function completeHandlerAds(eventAds:Event):void {
              var loaderAds:URLLoader = URLLoader(eventAds.target);
              var varsAds:URLVariables = new URLVariables(loaderAds.data);
                itemsArr = varsAds.names.split(";");
                        for (i = 0; i < (itemsArr.length); i++) { 
                                trace("itemsArr, Processing: " + itemsArr[i]);
           var loaderProps:URLLoader = new URLLoader();
          loaderProps.load(new URLRequest(itemsArr[i]+".txt"));   
          loaderProps.addEventListener(Event.COMPLETE, completeHandlerProps);
          trace("one: " + itemsArr[i]);
          function completeHandlerProps(eventProps:Event):void {
                  trace("two: " + itemsArr[i]);
          }// end of fn for props
                        }//end of "for" loop of ads names
            }//end of fn for ads names
    But i get the following output:
    adsNames Array: ad0,ad1
    adsNames, Processing: ad0
    ad0
    adsNames, Processing: ad1
    ad1
    null
    TypeError: Error #2007: Parameter name must be non-null.
         at flash.display::DisplayObject/set name()
         at MethodInfo-279()
         at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio  n()
         at flash.events::EventDispatcher/dispatchEvent()
         at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    null
    TypeError: Error #2007: Parameter name must be non-null.
         at flash.display::DisplayObject/set name()
         at MethodInfo-279()
         at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio  n()
         at flash.events::EventDispatcher/dispatchEvent()
         at flash.net::URLLoader/flash.net:URLLoader::onComplete()
    As you see, the "red text" is errors, Can you tell me the reason for it ?
    And also, tracing "itemsArr[i]" in the second time, always give "null", also in the first time, it give the correct value, Why ?

    the red text not appear after i posted the topic, but you can see the errors on the output
    and, you've to create to text files, first called "ads.txt" and put in it "names=ad0;ad1"
    second one called "ad0.txt" and put anything in it, and another called "ad1.txt" and put anything in it
    all these files should be in the same dir of flash file

  • What is the error in this code

    hi everone
    I write this code in push button
         declare
              x varchar2(222);
         begin
              x:=get_application_property(:system.mode);
              message(x);
              end;
    to know the system mode
    but the resullt was exeception ora-06502

    simple write
    x := :system.mode;
    or
    message(:system.mode);
    message(:system.mode);Best way to resolve the issue is always check Forms online help first

  • To find the error in java code if any

    i was learnig java.net package and this is the code i wrote to read the contents directly from a given url using openStream() method of URL class and got the message 'error' from
    java.io.IOException which i had given in the catch block. please tell me what is happening & how
    could i read the content from an url with url class method.
    import java.io.*;
    import java.net.*;
    public class url
    public static void main(String[] args)
    throws java.io.IOException,java.java.MalformedURLException
    try{
    URL yahoo = new URL("http://www.yahoo.com");
    BufferedReader read_io = new BufferedReader(new InputStreamReader(yahoo.openStream()));
    String line;
    while((line =read_io.readLine())!= null)
    System.out.println(line);
    line.close();}
    catch(MalformedURLException e)
    System.out.println("error");
    catch(IOException e)
    System.out.println("error"):
    after execution at the terminal
    bash-3.00#javac url.java
    bash-3.00#java url
    error

    Please use [code] tags when posting code.
    Are you sure String has a close method? I'm not sure your code compiles.
    Exceptions have a getMessage method, which can be useful (and a printStackTrace method that can be even more useful.)

  • What's the error in this code?

    I keep getting an error message at "line 1 column 97" which is the letter "i" in the second "if."
    begin if :P23_START_DATE is null or :P23_START_DATE = ' ' then :P23_START_DATE:= '01-JAN-2001';
    if :P23_END_DATE = is null or :P23_END_DATE = ' ' then
    :P23_END_DATE = '31-DEC-2099';
    select 'http://apexdevapp1.ci.raleigh.nc.us:7777',
    user_name, count(ID) total
    FROM eba_ver2_cust_activity
    where ACTIVITY_DATE <= to_char(to_date(:P23_END_DATE,'dd-mon-yyyy'),'dd-mon-yyyy')
    and ACTIVITY_DATE >= to_char(to_date(:P23_START_DATE,'dd-mon-yyyy'),'dd-mon-yyyy')
    group by
    user_name,
    'http://apexdevapp1.ci.raleigh.nc.us:7777'
    end;
    Honestly, I don't see where the problem is. Help me please.
    Steve "the n00b" in Raleigh NC

    ackness wrote:
    You could forgo the IF statements altogether by doing using NVL and TRIM this:
    begin
    select
    'http://apexdevapp1.ci.raleigh.nc.us:7777',
    user_name, count(ID) total
    FROM eba_ver2_cust_activity
    where ACTIVITY_DATE BETWEEN NVL(TRIM(:P23_START_DATE), '01-JAN-2001') AND NVL(TRIM(:P23_END_DATE), '31-DEC-2099');
    group by
    user_name,
    'http://apexdevapp1.ci.raleigh.nc.us:7777';
    end;
    also you can simplify the GROUP BY by
    begin
    select
    MAXX('http://apexdevapp1.ci.raleigh.nc.us:7777') URL,
    user_name, count(ID) total
    FROM eba_ver2_cust_activity
    where ACTIVITY_DATE BETWEEN NVL(TRIM((:P23_START_DATE), '01-JAN-2001') AND NVL(TRIM((:P23_END_DATE), '31-DEC-2099');
    group by
    user_name;
    end;Ackness, I tried your first suggestion, and got this when I applied the changes.
    1 error has occurred
    Failed to parse SQL query:
    BEGIN SELECT 'http://apexdevapp1.ci.raleigh.nc.us:7777', user_name, count(ID) total FROM eba_ver2_cust_activity where ACTIVITY_DATE BETWEEN NVL(TRIM(:P23_START_DATE), '01-JAN-2001') AND NVL(TRIM(:P23_END_DATE), '31-DEC-2099'); group by user_name, 'http://apexdevapp1.ci.raleigh.nc.us:7777'; end
    ORA-06550: line 5, column 115: PLS-00103: Encountered the symbol "" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
    Certain queries can only be executed when running your application, if your query appears syntactically correct, you can save your query without validation (see options below query source).
    I can't for the life of me figure out where the invalid character is after "begin." All I can see is a blank character. Thanks for your help.
    Steve "the n00b"

  • Could anyone tell me where is the error in this code

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
      <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.js"></script>
    <script src="js/AddRemRows.js" type="text/javascript"></script>
    <script type="text/javascript">
        function doAdd(ths)
        var x = $(this).closest('tr').find('input.x').val();
        var y = $(this).closest('tr').find('input.y').val();
        y=x;
    </script>
    <body>
    <table width="411" height="64" border="1" cellpadding="0" cellspacing="0" id="myTable">
        <tr>
            <td width="43%">Y</td>
            <td width="57%">X</td>
        </tr>
        <tr>
          <td width="43%"><select class="y" name="y" id="y" onchange="doAdd(this)">
              <option value="0">0 </option>
              <option value="1">1</option>
              <option value="2">2</option>
            </select></td>
            <td><input class="x" type="text" name="x" id="x" /></td>
        </tr>
    </table>
    <p>
      <input name="addrow" type="button" id="addrow" onclick="addRow('myTable')" value="add" />
    </p>
    </body>
    </html>

    If you format the source code properly you will be able to see what has gone wrong
    <!doctype html>
    <html>
    <head>
    <script>
    function addRow(tableID) {
        var table = document.getElementById(tableID);
        var rowCount = table.rows.length;
        var row = table.insertRow(rowCount);
        var colCount = table.rows[0].cells.length;
        for(var i=0; i<colCount; i++ ) {
            var newcell = row.insertCell(i);
            newcell.innerHTML = table.rows[1].cells[i].innerHTML;
            switch(newcell.childNodes[0].type) {
                case "text":
                    newcell.childNodes[0].value = "";
                    break;
                case "checkbox":
                    newcell.childNodes[0].checked = false;
                    break;
                case "select-one":
                    newcell.childNodes[0].selectedIndex = 0;
                    break;
    function deleteRow(tableID) {
        try {var table = document.getElementById(tableID);
            var rowCount = table.rows.length;
            for(var i=0; i<rowCount; i++) {
                var row = table.rows[i];
                var chkbox = row.cells[0].childNodes[0];
                if(null != chkbox && true == chkbox.checked) {
                    if(rowCount <= 2) {
                        alert("Cannot delete all the rows.");
                        break;
                    table.deleteRow(i);
                    rowCount--;
                    i--;
        catch(e) {
            alert(e);
    function kk(){
        var table = document.getElementById("datatable");
        var rowCount = table.rows.length;
        for(var i=0; i<rowCount; i++)
            var x =row.cells[i].childNodes[i];
            var s1 = document.getElementById("s1").value;
            var txt1 = document.getElementById("txt1").value;
            txt1[rowCount] = s1[rowCount];
    </script>
    </head>
    <body>
    <input type="button" value="Add Row" onClick="addRow('datatable')" />
    <input type="button" value="Delete Row" onClick="deleteRow('datatable')" />
    <table width="369" height="63" border="1" id="datatable">
        <tr>
            <td width="32"></td>
            <td width="119" align="center"><strong>Activity</strong></td>
            <td width="177" align="center"><strong>Cost</strong></td>
        </tr>
        <tr>
            <td><input type="checkbox" name="chk"/></td>
            <td><select name="s1" id="s1" onChange="kk();">
                    <option value="1">1</option>
                    <option value="2">2</option>
                    <option value="3">3</option>
                </select></td>
            <td><input type="text" name="txt1" id="txt1"></td>
        </tr>
    </table>
    </body>
    </html>
    In function kk(), the for loop does not have an opening and closing curly bracket.
    When I add two more rows, the resulting markup is as in
    <table id="datatable" border="1" height="63" width="369">
        <tbody>
            <tr>
                <td width="32"></td>
                <td align="center" width="119"><strong>Activity</strong></td>
                <td align="center" width="177"><strong>Cost</strong></td>
            </tr>
            <tr>
                <td><input name="chk" type="checkbox"></td>
                <td><select name="s1" id="s1" onchange="kk();">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select></td>
                <td><input name="txt1" id="txt1" type="text"></td>
            </tr>
            <tr>
                <td><input name="chk" type="checkbox"></td>
                <td><select name="s1" id="s1" onchange="kk();">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select></td>
                <td><input name="txt1" id="txt1" type="text"></td>
            </tr>
            <tr>
                <td><input name="chk" type="checkbox"></td>
                <td><select name="s1" id="s1" onchange="kk();">
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                    </select></td>
                <td><input name="txt1" id="txt1" type="text"></td>
            </tr>
        </tbody>
    </table>
    In the above you will notice that the values for name and id are repeated. This is not only illegal, but is very confusing for the kk() function as it does not know which value it is that you want.
    My advice is to change the addrow() and deleterow() functions to allow for unique names and id's. Once you have done that, it is easy to allocate the values for the textbox.

  • Can you find the problem in this code?

    I've searching some examples of the using of JTable on this forum.
    So I've used a code found here.
    But nothing happens, the JFrame doesn't appear on screen.
    I'm sure my database "CLIENTES" exists inside the db folder. And also there's data inside "CLIENTES" table.
    So, where is the problem then?
    Thanks.
    import java.io.*;
    import java.sql.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.table.*;
    public class TelaPrincipal extends JFrame {
       public TelaPrincipal() {
            Vector columnNames = new Vector();
            Vector data = new Vector();
            try {
               //  Connect to the Database
               String driver = "org.hsqldb.jdbcDriver";
               String url = "jdbc:hsqldb:file:./db/CLIENTES";
               String userId = "sa";
               String password = "";
               Class.forName(driver);
               Connection connection = DriverManager.getConnection(url, userId, password);
               //  Read data from a table
               String sql = "SELECT * FROM CLIENTES";
               Statement stmt = connection.createStatement();
               ResultSet rs = stmt.executeQuery(sql);
               ResultSetMetaData md = rs.getMetaData();
               int columns = md.getColumnCount();
               //  Get column names
               for (int i = 1; i <= columns; i++){
                  columnNames.addElement( md.getColumnName(i) );
               //  Get row data
               while (rs.next()) {
                  Vector row = new Vector(columns);
                  for (int i = 1; i <= columns; i++) {
                     row.addElement(rs.getObject(i));
                  data.addElement(row);
               rs.close();
               stmt.close();
            catch(ClassNotFoundException cnfe) {
               cnfe.printStackTrace();
            catch(SQLException sqle) {
              sqle.printStackTrace(); 
            //  Create table with database data
            JTable table = new JTable(data, columnNames);
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add(scrollPane);
        public static void main(String[] args) {
           TelaPrincipal tp = new TelaPrincipal();
           tp.setDefaultCloseOperation(EXIT_ON_CLOSE);
           tp.pack();
           tp.setVisible(true);
    }

    the jdbc driver is not on the classpath?

  • Kindly let me the error in this code

    FORM transaction_bdc .
      DATA :
      v_cnt(2) TYPE n,
      v_bst(2) TYPE n,
      v_bn TYPE i,
      v_bstpo(25),
      v_ebtyp(25),
      v_menge(25),
      v_eeind(25),
      v_xblnr(25),
      v_xblnr1(25),
      v_ebelp(2) TYPE n,
      v_ebelpt(2),
      v_menge1(11),
      v_ebt TYPE i,
      v_vebtyp LIKE ekes-ebtyp,
      v_eb(2) TYPE n,
      v_tcselflag(40),
      v_tem(2) TYPE n,
      v_correct TYPE i,
      v_file TYPE string.
      DATA: ls_outtab TYPE tb_struc.
      DATA: l_valid TYPE c,
            l_locked TYPE c.
      CALL METHOD g_grid->check_changed_data
        IMPORTING
          e_valid = l_valid.
      IF l_valid EQ 'X'.
        LOOP AT tb_output WHERE check EQ 'X' .
          MOVE-CORRESPONDING tb_output TO itab_output.
          APPEND itab_output.
          CLEAR itab_output.
        ENDLOOP.
        IF tb_output-check <> 'X'.
          MESSAGE e003 WITH text-004.
        ENDIF.
      ENDIF.
      IF itab_output[] IS NOT INITIAL.
        PERFORM open_group.
    ***looping at purchase order level.
        LOOP AT itab_output where ebelp is not initial .
    *read table itab_output with key ebelp = ekpo-ebelp.
          CLEAR v_bn.
          CLEAR v_ebt.
          PERFORM bdc_dynpro USING 'SAPMM06E' '0105'.
          PERFORM bdc_field USING 'BDC_CURSOR'
          'RM06E-BSTNR'.
          PERFORM bdc_field USING 'BDC_OKCODE'
          '/00'.
          PERFORM bdc_field USING 'RM06E-BSTNR'
          itab_output-ebeln.
    ***Changing alphanumeric fields and quantity fields to character type**
    *v_ebelp = tB_OUTPUT-ebelp.
    *clear v_ebelpt.
    *v_menge1 = tB_OUTPUT-menge.
    *v_ebelpt = v_ebelp.
    ***End Of Changing**
    *Checking for the exact number of the item**
          LOOP AT itab_output where ebeln = tb_output-ebeln.
            loop at tb_output.
            IF tb_output-ebelp = itab_output-ebelp.
              exit.
            ELSE.
              v_bn = v_bn + 1.
            ENDIF.
    endloop.
          ENDLOOP.
    v_bst = v_bn + 1.
    *End Of Checking**
    **Mapping items**
            v_bst = v_bst - 1.
            v_tem = v_bst.
            CONCATENATE 'RM06E-BSTPO(' v_bst ')' INTO v_bstpo.
            CONCATENATE 'RM06E-TCSELFLAG(' v_tem ')' INTO v_tcselflag.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_bstpo.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=DETA'.
            PERFORM bdc_field USING 'RM06E-EBELP'
            v_ebelpt.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0111'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            'EKPO-BSTAE'.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '/00'.
            PERFORM bdc_dynpro USING 'SAPMM06E' '0120'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_bstpo.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=BSTA'.
            PERFORM bdc_field USING 'RM06E-EBELP'
            v_ebelpt.
            PERFORM bdc_field USING v_tcselflag
            'X'.
    **Checking weather Confirmation category already exists**
            SELECT ebtyp FROM ekes INTO v_vebtyp WHERE ebelp =
            itab_output-ebelp AND ebeln = itab_output-ebeln.
            ENDSELECT.
            IF sy-dbcnt > 0.
              v_ebt = sy-dbcnt.
            ENDIF.
            v_eb = v_ebt + 1.
    **End Of Checking**
    **For Line items**
            CONCATENATE 'EKES-EBTYP(' v_eb ')' INTO v_ebtyp.
            CONCATENATE 'EKES-MENGE(' v_eb ')' INTO v_menge.
            CONCATENATE 'RM06E-EEIND(' v_eb ')' INTO v_eeind.
            CONCATENATE 'EKES-XBLNR(' v_eb ')' INTO v_xblnr.
    **End**
            PERFORM bdc_dynpro USING 'SAPLEINB' '0200'.
            PERFORM bdc_field USING 'BDC_CURSOR'
            v_xblnr.
            PERFORM bdc_field USING 'BDC_OKCODE'
            '=BU'.
            PERFORM bdc_field USING v_ebtyp
           itab_output-ebtyp.
            PERFORM bdc_field USING v_eeind
            itab_output-eindt.
            PERFORM bdc_field USING v_menge
            v_menge1.
            PERFORM bdc_field USING v_xblnr
            itab_output-xblnr.
    **End Of Mappings**
    loop at itab_output.
            MOVE-CORRESPONDING itab_output TO ekes.
            modify ekes.
           MOVE-CORRESPONDING itab_output TO eket.
           MODIFY eket.
           MOVE-CORRESPONDING tb_output TO ekpo.
           MODIFY ekpo.
          ENDLOOP.
           CALL TRANSACTION 'ME22N'
           USING itbdc
           MODE   'E'.
    *perform bdc_transaction using 'ME22N'.
    endloop.
         endif.
    **End Of Purchase Order Loop**
        PERFORM close_group.

    Hi Asha ,
      Is the BDC called for the second record , what happens when the second record is used , what i mean is that you have entered the 2nd record details in the internal table , as u can see in mode 'A' it goes step by step , once the fileds for first line is filled , then the 2nd line must be porcessed , what happnens at that time .Is there any attempt to populate the field in the screen or not.
    Regards
    Arun

  • Not able to find the Error in code !

    please help me to find the error in my code. When I Added x1~kondm its not giving anything i.e
    *join t178t as x1
    *on   p1kondm = x1kondm
    in the SQL part !
    REPORT YINTERACTIVEPROGRAM01.
    TABLES:VBAP,
           VBPA,
           VBRP,
           VBRK,
           KNA1,
           ADRC,
           TPAR,
           TVKGG,
           TVM1T,
           TVM2T,
           TVM3T,
           TVM4T,
           VBKD,
           SZA1_D0100,
           T178T.
    TYPES:BEGIN OF TY_TAB,
             VBELN LIKE VBAK-VBELN,
             VKORG LIKE VBAK-VKORG,
             ERDAT LIKE VBAK-ERDAT,
             AUGRU LIKE VBAK-AUGRU,
             BSTDK LIKE VBKD-BSTDK,
             BSTDK_E LIKE VBKD-BSTDK_E,
             spart like vbap-spart,
             kondm like vbap-kondm,
             waerk like vbap-waerk,
             netwr like vbap-netwr,
             kwmeng like vbap-kwmeng,
             vkaus like vbap-vkaus,
             land1 like vbpa-land1,
             nrart like tpar-nrart,
           vtext like tpar-vtext,
             parvw like tpar-parvw,
             name1 like adrc-name1,
             name2 like adrc-name2,
             name3 like adrc-name3,
             name4 like adrc-name4,
             ort01 like kna1-ort01,
             pstlz like kna1-pstlz,
             vtext like t178t-vtext,
          END  OF TY_TAB.
    DATA: ITAB TYPE STANDARD TABLE OF TY_TAB WITH HEADER LINE.
    parameters:salesno like itab-vbeln.
    select s1~vbeln
           s1~vkorg
           s1~erdat
           s1~augru
           k1~BSTDK
           k1~BSTDK_E
           p1~spart
           p1~kondm
           p1~waerk
           p1~netwr
           p1~kwmeng
           p1~vkaus
           r1~land1
           t1~nrart
          t1~vtext
           t1~parvw
           n1~name1
           n1~name2
           n1~name3
           n1~name4
           c1~ort01
           c1~pstlz
           x1~vtext
    into corresponding fields of table itab
    from  vbak as s1
    join  VBKD as k1
    on   s1vbeln = k1VBELN
    join vbap as p1
    on   k1vbeln = p1vbeln
    *join t178t as x1
    *on   p1kondm = x1kondm
    join vbpa as r1
    on   p1vbeln = r1vbeln
    join tpar as t1
    on   r1parvw = t1parvw
    join ADRC as n1
    on   r1adrnr = n1addrnumber
    join kna1 as c1
    on   r1land1 = c1land1
    where k1vbeln = salesno and  s1vbeln = salesno and p1~vbeln = salesno
    and  r1~vbeln = salesno.
    loop AT ITAB.
      WRITE : /(30)'VBELN: ',  ITAB-VBELN,
              /(30)'VKORG: ',  ITAB-VKORG,
              /(30)'ERDAT: ',  ITAB-ERDAT,
              /(30)'AUGRU: ',  ITAB-AUGRU,
              /(30)'BSTDK: ',  ITAB-BSTDK,
              /(30)'BSTDK_E:', ITAB-BSTDK_E,
              /(30)'SPART: ',  itab-spart,
              /(30)'KONDM: ',  itab-kondm,
              /(30)'WAERK: ',  itab-waerk,
              /(18)'NETWR: ' , itab-netwr,
              /(18)'KWMENG: ', itab-kwmeng,
              /(10)'VKAUS:',   itab-vkaus,
              /(30)'LAND1:',   itab-land1,
              /(30)'NRART:',   itab-nrart,
              /(30)'PARVW:',   itab-parvw,
              /(30)'ADDR1:',   itab-name1,
              /(30)'ADDR2:',   itab-name2,
              /(30)'ADDR3:',   itab-name3,
              /(30)'ADDR4:',   itab-name4,
              /(30)'PSTLZ:',   itab-pstlz,
              /(30)'ORT01:',   itab-ort01,
              /(30)'Compiler desc:',   itab-vtext.
               uline.
    ENDLOOP.
                if sy-subrc <> 0.
                write : / 'No data found'.
                endif.

    hi,
      u failed to check relationship between tables and as well as mandatory fields need to be checked, i noticed following
    from vbak as s1
    join VBKD as k1
    on s1vbeln = k1VBELN
    join vbap as p1
    on k1vbeln = p1vbeln and k1posnr = p1posnr
    *join t178t as x1
    *on p1kondm = x1kondm
    join vbpa as r1
    on p1vbeln = r1vbeln   <b>and p1posnt = r1posnr </b> join tpar as t1
    on r1parvw = t1parvw
    join ADRC as n1
    on r1adrnr = n1addrnumber     <b> * No relation between these two tables/b]     
    join kna1 as c1
    on r1land1 = c1land1 <b>and r1kunnr = c1kunnr</b> <i>'here u need to check mandatory fields also</i>
    where k1vbeln = salesno and s1vbeln = salesno and p1~vbeln = salesno
    and r1~vbeln = salesno.
    anyway, in performance point of view, writeing code with this much joins is not acceptable.
    comeback if you need any further help
    regards,
    pavan
    Message was edited by:
            pavan kumar pisipati

  • Can anybody tell me the problem with this code when compiled in jdk1.4

    Can anybody help me find out the error in this code.
    Try to drag a file from your desktop and drop it on the first textpane on my GUI. Then try to drag another file. This time the dragdrop event handler throws a null pointer exception. This happened when I compiled the code with jdk1.4. With jdk1.3 it is working fine. Actually, I need jdk1.4 to get the systemicons for the files I drop on my desktop.
    /* Client.java*/
    import java.util.Vector;
    import java.util.Enumeration;
    import java.util.Arrays;
    import java.awt.*;
    import java.awt.event.*;
    import java.rmi.*;
    import java.rmi.server.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.filechooser.*;
    import java.io.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.util.Iterator;
    import javax.swing.plaf.*;
    import javax.swing.plaf.basic.*;
    import java.util.Hashtable;
    import javax.swing.text.*;
    import javax.swing.event.*;
    public class Client extends JFrame{
    static String newline = System.getProperty("line.separator");
    static Client client;
         //ServerInterface server;
         //ClientProperties clp;
         Vector v1=new Vector();
         ByteArrayOutputStream out;
         Runtime r1;
         //file objects,together with array of bytes
         Hashtable files=new Hashtable(); //files sent
         Hashtable rfiles=new Hashtable(); //files received
         //file objects,together with button handlers
         Hashtable hfiles=new Hashtable(); //files sent,files received
         JButton button1=new JButton();
         JButton button2=new JButton();
         JButton button3=new JButton();
         JLabel label1=new JLabel();
         JLabel label2=new JLabel();
         JLabel label3=new JLabel();
         JLabel label4=new JLabel();
         JLabel label5=new JLabel();
         JLabel label6=new JLabel();
         JLabel label7=new JLabel();
         JLabel label8=new JLabel();
         JOptionPane dialog=new JOptionPane();
         JFileChooser chooser = new JFileChooser();
         JPanel panel1;
         JPanel panel2;
         DropTarget dtarget;
         DragSource dsource;
         JTextPane textArea1=new JTextPane();
         TextArea textArea2=new TextArea();
         JTextPane textpanel=new JTextPane();
         Style defstyle,style;
         StyledDocument doc,doc1;
         JPopupMenu popup;
         JTree tree;
         JScrollPane jsppane;
         JScrollPane jsp,jsp2;
         DefaultMutableTreeNode top;
         Container cp;
         private String toalias;
         private String togroup;
    private String fromalias;
         private String fromgroup;     
         private boolean CONNECT;
         public Client()
         cp=getContentPane();
         cp.setLayout(null);
              setForeground(java.awt.Color.red);
              setFont(new Font("Dialog", Font.PLAIN, 14));
              setVisible(false);
              label1.setText(" CHAT APPLICATION");
              cp.add(label1);
              label1.setFont(new Font("Dialog", Font.BOLD, 16));
              label1.setBounds(72,20,319,30);
              label2.setText("List of Users Connected.");
              cp.add(label2);
              label2.setForeground(java.awt.Color.blue);
              label2.setFont(new Font("Dialog", Font.BOLD, 12));
              label2.setBounds(24,60,192,26);
              label8.setBounds(280,60,100,26);
              cp.add(label8);
              cp.add(textArea2);
              textArea2.setBounds(204,120,268,90);
              jsppane=new JScrollPane(textArea1);
              doc1=textArea1.getStyledDocument();
              jsppane.setBounds(12,264,456,109);
              cp.add(jsppane);
              label3.setText("TO::");
              cp.add(label3);
              label3.setFont(new Font("Dialog", Font.BOLD, 12));
              label3.setBounds(12,228,36,20);
              cp.add(label4);
              label4.setBackground(java.awt.Color.lightGray);
              label4.setBounds(60,228,172,19);
              label5.setText("SERVER RESPONSE");
              cp.add(label5);
              label5.setFont(new Font("Dialog", Font.BOLD, 12));
              label5.setBounds(204,96,204,21);
              label7.setText("MESSAGE FOR YOU.");
              cp.add(label7);
              label7.setFont(new Font("Dialog", Font.BOLD, 14));
         label7.setBounds(12,371,288,25);
         jsp2=new JScrollPane(textpanel);
         setTextPaneStyle();
    jsp2.setBounds(12,401,456,109);
    cp.add(jsp2);
    button1.setLabel("Send");
              button1.setEnabled(false);
              cp.add(button1);
              button1.setBackground(java.awt.Color.lightGray);
              button1.setForeground(java.awt.Color.black);
              button1.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
              button1.setBounds(60,520,78,36);
              button2.setLabel("Attach");
              //button2.setEnabled(false);
              cp.add(button2);
              button2.setBackground(java.awt.Color.lightGray);
              button2.setForeground(java.awt.Color.black);
              button2.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
              button2.setBounds(180,520,72,36);
              button3.setLabel("Connect");
              cp.add(button3);
              button3.setBackground(java.awt.Color.lightGray);
              button3.setForeground(java.awt.Color.black);
              button3.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
              button3.setBounds(288,520,72,33);
              setSize(500,620);
         show();
         addWindowListener(new WindowEventHandler());
         button1.addActionListener(new ButtonHandler());     
         button2.addActionListener(new ButtonHandler());     
         button3.addActionListener(new ButtonHandler());
         textArea1.addContainerListener(new ComponentHandler());     
         dtarget=new DropTarget(textArea1,new DragDropHandler());
         textArea2.setEnabled(false);
         textpanel.setEnabled(false);
         r1=Runtime.getRuntime();
         r1.addShutdownHook(new onshutdown());
         addMenu();
         cp.repaint();
         //adds attachments to the textArea1     
         synchronized private void addAttach(java.util.List fileList)
         Iterator iterator=fileList.iterator();
         JButton bw;
         while(iterator.hasNext())
              File file=(File)iterator.next();
              Icon icon=chooser.getIcon(file);
              bw=new JButton(icon);
              bw.setBackground(java.awt.Color.gray);
              bw.setToolTipText(file.getAbsolutePath());
              bw.addMouseListener(new AttachmentHandler());
              Dimension d1=new Dimension(icon.getIconWidth(),icon.getIconHeight());
              bw.setMaximumSize(d1);
              hfiles.put(bw,file);          
              textArea1.insertComponent(bw);
              textArea1.setCaretPosition(doc1.getLength());
              bw.setSize(icon.getIconWidth(),icon.getIconHeight());
              //only one file at a time
              break;
         cp.repaint();
    public void setAudioStream(ByteArrayOutputStream out)
    this.out=out;               
    private void addMenu()
         JMenuBar mbar=new JMenuBar();
         mbar.setVisible(true);
         mbar.setBounds(0,0,500,20);
         mbar.setBackground(java.awt.Color.gray);
         //first menu
         JMenu m1=new JMenu("Connection");
         m1.setBounds(0,0,80,20);
         m1.setBackground(java.awt.Color.gray);
         JMenuItem mitem1=new JMenuItem("Connect");
         JMenuItem mitem2=new JMenuItem("Disconnect");
         m1.add(mitem1);
         m1.add(mitem2);
         mitem1.addActionListener(new ButtonHandler());
         mitem2.addActionListener(new ButtonHandler());
         mbar.add(m1);
         //second menu
         JMenu m2=new JMenu("Send...");
         m2.setBounds(90,0,80,20);
         m2.setBackground(java.awt.Color.gray);
         JMenuItem mitem3=new JMenuItem("Send");
         JMenuItem mitem4=new JMenuItem("Send with Audio...");
         mitem3.addActionListener(new ButtonHandler());
         mitem4.addActionListener(new ButtonHandler());
         m2.add(mitem3);
         m2.add(mitem4);
         mbar.add(m2);
         cp.add(mbar);
    private void setTextPaneStyle()
    StyleContext stylecontext =StyleContext.getDefaultStyleContext();
    defstyle=stylecontext.getStyle(StyleContext.DEFAULT_STYLE);
    doc= textpanel.getStyledDocument();
    //style 1
    style= textpanel.addStyle("bold",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.blue);
    StyleConstants.setItalic(style, false);
    StyleConstants.setBold(style, true);
    StyleConstants.setFontSize(style,16);
    //style 2
    style= textpanel.addStyle("normal",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.black);
    StyleConstants.setItalic(style, false);
    StyleConstants.setBold(style, false);
    StyleConstants.setFontSize(style,14);      
    //style3
    style= textpanel.addStyle("attach",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.red);
    StyleConstants.setItalic(style, true);
    StyleConstants.setBold(style, false);
    StyleConstants.setFontSize(style,12);      
    //remote method called by server
    public void addClient(String alias,String group,JTree tree)
         //if old client remove old tree
         if(!alias.equals(""))
         cp.remove(this.jsp);
         //add new tree
         this.tree=tree;
         setTreeModel();
         getSound(2);
         if(!alias.equals(""))
         textArea2.append("\nNew Client:" + alias + "has joined");
         else
         textArea2.append("\nYou have been connected to the Server.");
         jsp=new JScrollPane(this.tree);
    jsp.setBounds(12,96,168,120);
         jsp.setBackground(java.awt.Color.lightGray);
    cp.add(jsp);
    this.tree.addMouseListener(new MouseHandler());
    //remote method called by server
    public void sendMessage(String str,Hashtable rfiles,String alias,String group) throws RemoteException
              receiveMessage(str,rfiles,alias,group);
    //remote method called by server
    public void removeClient(JTree tree,String alias,String group) throws RemoteException
    cp.remove(this.jsp);
    this.tree=tree;
    setTreeModel();
    getSound(3);
    jsp=new JScrollPane(this.tree);
    jsp.setBounds(12,96,168,120);
         jsp.setBackground(java.awt.Color.lightGray);
    cp.add(jsp);
    this.tree.addMouseListener(new MouseHandler());
    textArea2.append("\nClient:" + alias + "has disconnected");                          
    private void receiveMessage(String str,Hashtable rfiles,String alias,String group)
              boolean flag=true;
              UIManager.put("JFrame.activeTitleBackground", new Color(64,128,255));
    UIManager.put("JFrame.activeTitleForeground", Color.white);
    UIManager.put("JFrame.inactiveTitleBackground", new Color(128,128,128));
    UIManager.put("JFrame.inactiveTitleForeground", Color.black);
    SwingUtilities.updateComponentTreeUI(this);
              try{
              if(alias.equals(""))
         doc.insertString(doc.getLength(),"CHATMASTER>>",textpanel.getStyle("bold"));
              doc.insertString(doc.getLength(),str+ newline,textpanel.getStyle("normal"));
              else
              doc.insertString(doc.getLength(),alias + "@" + group + ">>",textpanel.getStyle("bold"));
              doc.insertString(doc.getLength(),str,textpanel.getStyle("normal"));
              //add files to textpanel
              if(rfiles!=null && rfiles.size()>0)
              doc.insertString(doc.getLength(),newline+"Attachments>>",textpanel.getStyle("attach"));
              showattach(rfiles);
              addtoList(rfiles);     
    doc.insertString(doc.getLength(),newline,textpanel.getStyle("normal"));
    catch(Exception e)
              e.printStackTrace();
              dialog.showMessageDialog(client,e.toString(),"Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
         cp.repaint();               
    protected boolean ContactServer(String alias,String servername,String group)
         try{
              //UnicastRemoteObject.exportObject(this);
              //server=(ServerInterface)Naming.lookup("//gpt02d05:5500/" + servername);
         //     server.notifyMe(this,alias,group);
              //change the settings of buttons
              button1.setEnabled(true);
              button2.setEnabled(true);
              button3.setLabel("Disconnect");
              label8.setVisible(true);
              label8.setText(" Welcome::" + alias);
              //putting values of alias and group for sending messages
              fromalias=alias;
              fromgroup=group;
              CONNECT=true;
              return true;
         catch(UnsupportedOperationException e)
         dialog.showMessageDialog(client,"Client with the Same Alias in " + group + " already exists","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);                                   
         try{
              //     UnicastRemoteObject.unexportObject(client,true);
              catch(Exception ev){System.out.println(ev.toString());}     
         catch(Exception e)
              dialog.showMessageDialog(client,"Unable to connect to Server","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
              try{
              //     UnicastRemoteObject.unexportObject(client,true);
              catch(Exception ev){System.out.println(ev.toString());}     
         return false;      
    public static void main(String args[]) throws RemoteException{
         client=new Client();          
    }//main ends
    public void getSound(int count)
         Toolkit t1=getToolkit();
              for(int i=0;i<count;i++)
              t1.beep();
              try{
                   Thread.sleep(500);
              catch(Exception e){}
    public void setTreeModel()
    ImageIcon i1=new ImageIcon("Lock.gif","No Users");
    ImageIcon i2=new ImageIcon("Connec.gif","Users in Group");
    ImageIcon i3=new ImageIcon("authorbn.gif","An User");
    DefaultTreeCellRenderer dr1= new DefaultTreeCellRenderer();
    dr1.setClosedIcon(i1);
    dr1.setOpenIcon(i2);
    dr1.setLeafIcon(i3);
    dr1.setTextSelectionColor(java.awt.Color.red);
    tree.setCellRenderer(dr1);
    //add received files to the list
    private void addtoList(Hashtable rfiles)
    Enumeration filelist=rfiles.keys();          
    while(filelist.hasMoreElements())          
    File file=(File)filelist.nextElement();
    this.rfiles.put(file,rfiles.get(file));               
    //show the attachments received               
    private void showattach(Hashtable rfiles)
    Enumeration filelist=rfiles.keys();
    dsource=DragSource.getDefaultDragSource();
    JButton b1=null;
    while(filelist.hasMoreElements())
         File file=(File)filelist.nextElement();
         Icon icon=chooser.getIcon(file);
         b1=new JButton(icon);
         b1.setBackground(java.awt.Color.gray);
    b1.setToolTipText(file.getName());
    b1.addMouseListener(new AttachmentHandler());
    Dimension d1=new Dimension(icon.getIconWidth(),icon.getIconHeight());
    b1.setMaximumSize(d1);
    hfiles.put(b1,file);
    textpanel.setCaretPosition(doc.getLength());
    textpanel.insertComponent(b1);
    b1.setSize(icon.getIconWidth(),icon.getIconHeight());
    dsource.createDefaultDragGestureRecognizer(b1, DnDConstants.ACTION_COPY_OR_MOVE,new DragGestureHandler());           
    cp.repaint();
    private void savefile(File file,Object parent)
    //ExtensionFileFilter filter = new ExtensionFileFilter(false);
    //filter.addExtension("txt",true);
    //chooser.setFileFilter(filter);
    int returnVal = chooser.showSaveDialog(client);
    if(returnVal ==JFileChooser.APPROVE_OPTION)
         try{
         FileOutputStream fstream=new FileOutputStream(chooser.getSelectedFile());
         //decide whether the file received or sent is to be saved
         if(((Container)parent).equals(textArea1))
         fstream.write((byte[])files.get(file));
         else
         fstream.write((byte[])rfiles.get(file));
         fstream.close();
         System.out.println(file.getName());          
         catch(Exception e)
         {System.out.println(e.toString()); }
    private void openfile(File file,Object parent)
         File tempfile=null;
         try{
         String fname=file.getName();     
         tempfile=File.createTempFile("temp",fname.substring(fname.lastIndexOf(".")));     
         FileOutputStream fstream=new FileOutputStream(tempfile);
         System.out.println(tempfile.getAbsolutePath());
         //decide whether the file received or sent is to be saved
         if(((Container)parent).equals(textArea1))
         fstream.write((byte[])files.get(file));
         else
         fstream.write((byte[])rfiles.get(file));          
         fstream.close();
    catch(Exception e){System.out.println(e.toString());}
    try{
         Process p1=r1.exec("cmd /c start " + tempfile.getAbsolutePath());
         p1.waitFor();
    catch(Exception e){System.out.println(e.toString());}     
    //inner classes
    class ComponentHandler implements ContainerListener{
    public void componentRemoved(ContainerEvent ev)     
              Container cont=(Container)ev.getChild();
              if(cont.getComponentCount()>0)
              JButton but=(JButton)cont.getComponent(0);
              files.remove((File)hfiles.get(but));
              hfiles.remove(but);
    public void componentAdded(ContainerEvent ev){}
    class AttachmentHandler extends MouseAdapter{
         public void mouseClicked(MouseEvent ev){
         if(ev.getModifiers()==4)
         Component comp=(Component)ev.getSource();
         File file=(File)hfiles.get(comp);
         popup=new JPopupMenu();
         JMenuItem popopen=new JMenuItem("Open");
         JMenuItem popsave=new JMenuItem("Save As..");
         popup.add(popopen);
         System.out.println(comp.getParent().getParent().getClass().toString());
         popopen.addActionListener(new ButtonHandler(file,comp.getParent().getParent()));
         popup.add(popsave);
         popsave.addActionListener(new ButtonHandler(file,comp.getParent().getParent()));
         popup.show(comp,12,12);
    class DragGestureHandler extends Vector implements DragGestureListener,DragSourceListener,Transferable{
    final static int FILE = 0;
    final static int STRING = 1;
    final static int PLAIN = 2;
    DataFlavor flavors[] = {DataFlavor.javaFileListFlavor,DataFlavor.stringFlavor,DataFlavor.plainTextFlavor};
    public void dragDropEnd(DragSourceDropEvent ev){}
    public void dragEnter(DragSourceDragEvent ev){}
    public void dragExit(DragSourceEvent ev){}
    public void dragOver(DragSourceDragEvent ev){}
    public void dropActionChanged(DragSourceDragEvent ev){}
    public void dragGestureRecognized(DragGestureEvent ev)     
              System.out.println("recognized");
              File file=(File)hfiles.get(ev.getComponent());
    addElement(file);
    ev.startDrag(DragSource.DefaultCopyDrop,this,this);
    /* Returns the array of flavors in which it can provide the data. */
    public synchronized DataFlavor[] getTransferDataFlavors() {
         return flavors;
    /* Returns whether the requested flavor is supported by this object. */
    public boolean isDataFlavorSupported(DataFlavor flavor) {
    boolean b = false;
    b |=flavor.equals(flavors[FILE]);
    b |= flavor.equals(flavors[STRING]);
    b |= flavor.equals(flavors[PLAIN]);
         return (b);
    public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,IOException
    if(flavor.equals(flavors[FILE])){return this;}
    else if (flavor.equals(flavors[PLAIN])) {
         return new StringReader(((File)elementAt(0)).getAbsolutePath());
         } else if (flavor.equals(flavors[STRING])) {
         return((File)elementAt(0)).getAbsolutePath();
         } else {
         throw new UnsupportedFlavorException(flavor);
    //inner class for draging in the files on java frame     
    class DragDropHandler implements DropTargetListener{
    public void dragEnter(DropTargetDragEvent ev){     
    public void dragExit(DropTargetEvent ev){
    public void dragOver(DropTargetDragEvent ev){
    public void drop(DropTargetDropEvent ev){
         Transferable tf1=ev.getTransferable();
         DataFlavor fl[]=ev.getCurrentDataFlavors();
         if(ev.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
         ev.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
         try{
         java.util.List fileList = (java.util.List)tf1.getTransferData(DataFlavor.javaFileListFlavor);
    Iterator iterator = fileList.iterator();
    while (iterator.hasNext())
    File file = (File)iterator.next();
    if(file.isFile())
    Icon icon=chooser.getIcon(file);
    FileInputStream fstream=new FileInputStream(file);
    int filedata=(new Double(file.length())).intValue();
    byte bytes[]=new byte[filedata];
    fstream.read(bytes);
    files.put(file,bytes);
    ev.getDropTargetContext().dropComplete(true);
    addAttach(fileList);
    catch(Exception e)
    {System.out.println(e.toString() + "here");}
    public void dropActionChanged(DropTargetDragEvent ev){
    class MouseHandler extends MouseAdapter{
    public void mouseClicked(MouseEvent me)
    TreePath tp=tree.getPathForLocation(me.getX(),me.getY());
    if(tp!=null)
         if(tp.getPathCount()==3)
              toalias=tp.getPathComponent(2).toString();
              togroup=tp.getPathComponent(1).toString();
              System.out.println(toalias);
              if (!(toalias.equals(fromalias) && togroup.equals(fromgroup)))
              System.out.println("hh " + toalias);
              label4.setText(tp.getPathComponent(2).toString() + "_@" + tp.getPathComponent(1).toString());           
    class ButtonHandler implements ActionListener{
         private File file;
         private Object parent;
         //constructors
         public ButtonHandler()
         public ButtonHandler(File file,Object parent)
              this.file=file;
              this.parent=parent;
         //other functions      
         public void actionPerformed(ActionEvent ev){
              String s=ev.getActionCommand();
         System.out.println(s);
              if(s.equals("Send with Audio..."))
              //Audio audio=new Audio(client,false,"CAPTURE");          
              if(s.equals("Disconnect"))
              try{
              // server.disconnect(client);
              client.getSound(3);
              cp.remove(jsp);
              label6.setVisible(false);
              //UnicastRemoteObject.unexportObject(client,true);
              button3.setLabel("Connect");
              textArea2.append("\nYou have been disconnected to Server");
              client.repaint();     
              catch(Exception e)
              System.out.println(e.toString());
              if(s.equals("Connect"))
         //     clp=new ClientProperties(client,false);
         if(s.equals("Save As.."))
         savefile(file,parent);     
         if(s.equals("Open"))
         openfile(file,parent);
              if(s.equals("Attach"))
              //ExtensionFileFilter filter = new ExtensionFileFilter(false);
              //filter.addExtension(".txt",true);
              //filter.setDescription("Text Files(.txt)");
              // chooser.setFileFilter(filter);
              chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
              //chooser.setMultiSelectionEnabled(true);
              int returnVal = chooser.showOpenDialog(client);
              if(returnVal ==JFileChooser.APPROVE_OPTION)
              //File fp[]=chooser.getSelectedFiles();
              File fp[]=new File[1];
              fp[0]=chooser.getSelectedFile();
              int i=0;
              while(i<fp.length)
              try{
              File file=fp;
              Icon icon=chooser.getIcon(file);
    FileInputStream fstream=new FileInputStream(file);
    int filedata=(new Double(file.length())).intValue();
    byte bytes[]=new byte[filedata];
    fstream.read(bytes);
    files.put(file,bytes);
    catch(Exception e){dialog.showMessageDialog(client,e.toString(),"Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    return; }
    i++;
              java.util.List fileList=Arrays.asList(fp);
              addAttach(fileList);
              if(s.equals("Send"))
              try{
                   if(toalias==null)
                   dialog.showMessageDialog(client,"Select the Recepient First!!","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
                   return;
                   if(toalias!=null && togroup!=null && (!toalias.equals(fromalias)))
                   // server.sendMessage(textArea1.getText(),files,toalias,togroup,fromalias,fromgroup);
                   textArea1.setText("");
              catch(Exception e)
         e.printStackTrace();
    }//if ends
    class WindowEventHandler extends WindowAdapter{
         public void windowClosing(WindowEvent ev){
              try{
              //server.disconnect(client);
              client.getSound(3);
         //     UnicastRemoteObject.unexportObject(client,true);
              catch(Exception e){System.out.println(e.toString());}
              dispose();
    private class onshutdown extends Thread{
    public void run(){
         try{
              //server.disconnect(client);
              //UnicastRemoteObject.unexportObject(client,true);
              catch(Exception e){}      
    }//run ends          

    Here is the working code :
    There was an error line 724
    File file=fp; -> File file=fp[0];
    Several method were deprecated and try to replace the deprecated static field : DataFlavor.plainTextFlavor which was deprecated since 1.4.
    /* Client.java*/
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.rmi.*;
    import java.rmi.server.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.filechooser.*;
    import java.io.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import javax.swing.plaf.*;
    import javax.swing.plaf.basic.*;
    import javax.swing.text.*;
    import javax.swing.event.*;
    public class Client extends JFrame{
    static String newline = System.getProperty("line.separator");
    static Client client;
    //ServerInterface server;
    //ClientProperties clp;
    Vector v1=new Vector();
    ByteArrayOutputStream out;
    Runtime r1;
    //file objects,together with array of bytes
    Hashtable files=new Hashtable(); //files sent
    Hashtable rfiles=new Hashtable(); //files received
    //file objects,together with button handlers
    Hashtable hfiles=new Hashtable(); //files sent,files received
    JButton button1=new JButton();
    JButton button2=new JButton();
    JButton button3=new JButton();
    JLabel label1=new JLabel();
    JLabel label2=new JLabel();
    JLabel label3=new JLabel();
    JLabel label4=new JLabel();
    JLabel label5=new JLabel();
    JLabel label6=new JLabel();
    JLabel label7=new JLabel();
    JLabel label8=new JLabel();
    JOptionPane dialog=new JOptionPane();
    JFileChooser chooser = new JFileChooser();
    JPanel panel1;
    JPanel panel2;
    DropTarget dtarget;
    DragSource dsource;
    JTextPane textArea1=new JTextPane();
    TextArea textArea2=new TextArea();
    JTextPane textpanel=new JTextPane();
    Style defstyle,style;
    StyledDocument doc,doc1;
    JPopupMenu popup;
    JTree tree;
    JScrollPane jsppane;
    JScrollPane jsp,jsp2;
    DefaultMutableTreeNode top;
    Container cp;
    private String toalias;
    private String togroup;
    private String fromalias;
    private String fromgroup;
    private boolean CONNECT;
    public Client()
    cp=getContentPane();
    cp.setLayout(null);
    setForeground(java.awt.Color.red);
    setFont(new Font("Dialog", Font.PLAIN, 14));
    setVisible(false);
    label1.setText(" CHAT APPLICATION");
    cp.add(label1);
    label1.setFont(new Font("Dialog", Font.BOLD, 16));
    label1.setBounds(72,20,319,30);
    label2.setText("List of Users Connected.");
    cp.add(label2);
    label2.setForeground(java.awt.Color.blue);
    label2.setFont(new Font("Dialog", Font.BOLD, 12));
    label2.setBounds(24,60,192,26);
    label8.setBounds(280,60,100,26);
    cp.add(label8);
    cp.add(textArea2);
    textArea2.setBounds(204,120,268,90);
    jsppane=new JScrollPane(textArea1);
    doc1=textArea1.getStyledDocument();
    jsppane.setBounds(12,264,456,109);
    cp.add(jsppane);
    label3.setText("TO::");
    cp.add(label3);
    label3.setFont(new Font("Dialog", Font.BOLD, 12));
    label3.setBounds(12,228,36,20);
    cp.add(label4);
    label4.setBackground(java.awt.Color.lightGray);
    label4.setBounds(60,228,172,19);
    label5.setText("SERVER RESPONSE");
    cp.add(label5);
    label5.setFont(new Font("Dialog", Font.BOLD, 12));
    label5.setBounds(204,96,204,21);
    label7.setText("MESSAGE FOR YOU.");
    cp.add(label7);
    label7.setFont(new Font("Dialog", Font.BOLD, 14));
    label7.setBounds(12,371,288,25);
    jsp2=new JScrollPane(textpanel);
    setTextPaneStyle();
    jsp2.setBounds(12,401,456,109);
    cp.add(jsp2);
    button1.setText("Send");
    button1.setEnabled(false);
    cp.add(button1);
    button1.setBackground(java.awt.Color.lightGray);
    button1.setForeground(java.awt.Color.black);
    button1.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
    button1.setBounds(60,520,78,36);
    button2.setText("Attach");
    //button2.setEnabled(false);
    cp.add(button2);
    button2.setBackground(java.awt.Color.lightGray);
    button2.setForeground(java.awt.Color.black);
    button2.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
    button2.setBounds(180,520,72,36);
    button3.setText("Connect");
    cp.add(button3);
    button3.setBackground(java.awt.Color.lightGray);
    button3.setForeground(java.awt.Color.black);
    button3.setFont(new Font("Dialog", Font.BOLD|Font.ITALIC, 10));
    button3.setBounds(288,520,72,33);
    setSize(500,620);
    show();
    addWindowListener(new WindowEventHandler());
    button1.addActionListener(new ButtonHandler());
    button2.addActionListener(new ButtonHandler());
    button3.addActionListener(new ButtonHandler());
    textArea1.addContainerListener(new ComponentHandler());
    dtarget=new DropTarget(textArea1,new DragDropHandler());
    textArea2.setEnabled(false);
    textpanel.setEnabled(false);
    r1=Runtime.getRuntime();
    r1.addShutdownHook(new onshutdown());
    addMenu();
    cp.repaint();
    //adds attachments to the textArea1
    synchronized private void addAttach(java.util.List fileList)
    Iterator iterator=fileList.iterator();
    JButton bw;
    while(iterator.hasNext())
    File file=(File)iterator.next();
    Icon icon=chooser.getIcon(file);
    bw=new JButton(icon);
    bw.setBackground(java.awt.Color.gray);
    bw.setToolTipText(file.getAbsolutePath());
    bw.addMouseListener(new AttachmentHandler());
    Dimension d1=new Dimension(icon.getIconWidth(),icon.getIconHeight());
    bw.setMaximumSize(d1);
    hfiles.put(bw,file);
    textArea1.insertComponent(bw);
    textArea1.setCaretPosition(doc1.getLength());
    bw.setSize(icon.getIconWidth(),icon.getIconHeight());
    //only one file at a time
    break;
    cp.repaint();
    public void setAudioStream(ByteArrayOutputStream out)
    this.out=out;
    private void addMenu()
    JMenuBar mbar=new JMenuBar();
    mbar.setVisible(true);
    mbar.setBounds(0,0,500,20);
    mbar.setBackground(java.awt.Color.gray);
    //first menu
    JMenu m1=new JMenu("Connection");
    m1.setBounds(0,0,80,20);
    m1.setBackground(java.awt.Color.gray);
    JMenuItem mitem1=new JMenuItem("Connect");
    JMenuItem mitem2=new JMenuItem("Disconnect");
    m1.add(mitem1);
    m1.add(mitem2);
    mitem1.addActionListener(new ButtonHandler());
    mitem2.addActionListener(new ButtonHandler());
    mbar.add(m1);
    //second menu
    JMenu m2=new JMenu("Send...");
    m2.setBounds(90,0,80,20);
    m2.setBackground(java.awt.Color.gray);
    JMenuItem mitem3=new JMenuItem("Send");
    JMenuItem mitem4=new JMenuItem("Send with Audio...");
    mitem3.addActionListener(new ButtonHandler());
    mitem4.addActionListener(new ButtonHandler());
    m2.add(mitem3);
    m2.add(mitem4);
    mbar.add(m2);
    cp.add(mbar);
    private void setTextPaneStyle()
    StyleContext stylecontext =StyleContext.getDefaultStyleContext();
    defstyle=stylecontext.getStyle(StyleContext.DEFAULT_STYLE);
    doc= textpanel.getStyledDocument();
    //style 1
    style= textpanel.addStyle("bold",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.blue);
    StyleConstants.setItalic(style, false);
    StyleConstants.setBold(style, true);
    StyleConstants.setFontSize(style,16);
    //style 2
    style= textpanel.addStyle("normal",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.black);
    StyleConstants.setItalic(style, false);
    StyleConstants.setBold(style, false);
    StyleConstants.setFontSize(style,14);
    //style3
    style= textpanel.addStyle("attach",defstyle);
    StyleConstants.setBackground(style,Color.white);
    StyleConstants.setForeground(style,Color.red);
    StyleConstants.setItalic(style, true);
    StyleConstants.setBold(style, false);
    StyleConstants.setFontSize(style,12);
    //remote method called by server
    public void addClient(String alias,String group,JTree tree)
    //if old client remove old tree
    if(!alias.equals(""))
    cp.remove(this.jsp);
    //add new tree
    this.tree=tree;
    setTreeModel();
    getSound(2);
    if(!alias.equals(""))
    textArea2.append("\nNew Client:" + alias + "has joined");
    else
    textArea2.append("\nYou have been connected to the Server.");
    jsp=new JScrollPane(this.tree);
    jsp.setBounds(12,96,168,120);
    jsp.setBackground(java.awt.Color.lightGray);
    cp.add(jsp);
    this.tree.addMouseListener(new MouseHandler());
    //remote method called by server
    public void sendMessage(String str,Hashtable rfiles,String alias,String group) throws RemoteException
    receiveMessage(str,rfiles,alias,group);
    //remote method called by server
    public void removeClient(JTree tree,String alias,String group) throws RemoteException
    cp.remove(this.jsp);
    this.tree=tree;
    setTreeModel();
    getSound(3);
    jsp=new JScrollPane(this.tree);
    jsp.setBounds(12,96,168,120);
    jsp.setBackground(java.awt.Color.lightGray);
    cp.add(jsp);
    this.tree.addMouseListener(new MouseHandler());
    textArea2.append("\nClient:" + alias + "has disconnected");
    private void receiveMessage(String str,Hashtable rfiles,String alias,String group)
    boolean flag=true;
    UIManager.put("JFrame.activeTitleBackground", new Color(64,128,255));
    UIManager.put("JFrame.activeTitleForeground", Color.white);
    UIManager.put("JFrame.inactiveTitleBackground", new Color(128,128,128));
    UIManager.put("JFrame.inactiveTitleForeground", Color.black);
    SwingUtilities.updateComponentTreeUI(this);
    try{
    if(alias.equals(""))
    doc.insertString(doc.getLength(),"CHATMASTER>>",textpanel.getStyle("bold"));
    doc.insertString(doc.getLength(),str+ newline,textpanel.getStyle("normal"));
    else
    doc.insertString(doc.getLength(),alias + "@" + group + ">>",textpanel.getStyle("bold"));
    doc.insertString(doc.getLength(),str,textpanel.getStyle("normal"));
    //add files to textpanel
    if(rfiles!=null && rfiles.size()>0)
    doc.insertString(doc.getLength(),newline+"Attachments>>",textpanel.getStyle("attach"));
    showattach(rfiles);
    addtoList(rfiles);
    doc.insertString(doc.getLength(),newline,textpanel.getStyle("normal"));
    catch(Exception e)
    e.printStackTrace();
    dialog.showMessageDialog(client,e.toString(),"Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    cp.repaint();
    protected boolean ContactServer(String alias,String servername,String group)
    try{
    //UnicastRemoteObject.exportObject(this);
    //server=(ServerInterface)Naming.lookup("//gpt02d05:5500/" + servername);
    // server.notifyMe(this,alias,group);
    //change the settings of buttons
    button1.setEnabled(true);
    button2.setEnabled(true);
    button3.setText("Disconnect");
    label8.setVisible(true);
    label8.setText(" Welcome::" + alias);
    //putting values of alias and group for sending messages
    fromalias=alias;
    fromgroup=group;
    CONNECT=true;
    return true;
    catch(UnsupportedOperationException e)
    dialog.showMessageDialog(client,"Client with the Same Alias in " + group + " already exists","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    try{
    // UnicastRemoteObject.unexportObject(client,true);
    catch(Exception ev){System.out.println(ev.toString());}
    catch(Exception e)
    dialog.showMessageDialog(client,"Unable to connect to Server","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    try{
    // UnicastRemoteObject.unexportObject(client,true);
    catch(Exception ev){System.out.println(ev.toString());}
    return false;
    public static void main(String args[]) throws RemoteException{
    client=new Client();
    }//main ends
    public void getSound(int count)
    Toolkit t1=getToolkit();
    for(int i=0;i<count;i++)
    t1.beep();
    try{
    Thread.sleep(500);
    catch(Exception e){}
    public void setTreeModel()
    ImageIcon i1=new ImageIcon("Lock.gif","No Users");
    ImageIcon i2=new ImageIcon("Connec.gif","Users in Group");
    ImageIcon i3=new ImageIcon("authorbn.gif","An User");
    DefaultTreeCellRenderer dr1= new DefaultTreeCellRenderer();
    dr1.setClosedIcon(i1);
    dr1.setOpenIcon(i2);
    dr1.setLeafIcon(i3);
    dr1.setTextSelectionColor(java.awt.Color.red);
    tree.setCellRenderer(dr1);
    //add received files to the list
    private void addtoList(Hashtable rfiles)
    Enumeration filelist=rfiles.keys();
    while(filelist.hasMoreElements())
    File file=(File)filelist.nextElement();
    this.rfiles.put(file,rfiles.get(file));
    //show the attachments received
    private void showattach(Hashtable rfiles)
    Enumeration filelist=rfiles.keys();
    dsource=DragSource.getDefaultDragSource();
    JButton b1=null;
    while(filelist.hasMoreElements())
    File file=(File)filelist.nextElement();
    Icon icon=chooser.getIcon(file);
    b1=new JButton(icon);
    b1.setBackground(java.awt.Color.gray);
    b1.setToolTipText(file.getName());
    b1.addMouseListener(new AttachmentHandler());
    Dimension d1=new Dimension(icon.getIconWidth(),icon.getIconHeight());
    b1.setMaximumSize(d1);
    hfiles.put(b1,file);
    textpanel.setCaretPosition(doc.getLength());
    textpanel.insertComponent(b1);
    b1.setSize(icon.getIconWidth(),icon.getIconHeight());
    dsource.createDefaultDragGestureRecognizer(b1, DnDConstants.ACTION_COPY_OR_MOVE,new DragGestureHandler());
    cp.repaint();
    private void savefile(File file,Object parent)
    //ExtensionFileFilter filter = new ExtensionFileFilter(false);
    //filter.addExtension("txt",true);
    //chooser.setFileFilter(filter);
    int returnVal = chooser.showSaveDialog(client);
    if(returnVal ==JFileChooser.APPROVE_OPTION)
    try{
    FileOutputStream fstream=new FileOutputStream(chooser.getSelectedFile());
    //decide whether the file received or sent is to be saved
    if(((Container)parent).equals(textArea1))
    fstream.write((byte[])files.get(file));
    else
    fstream.write((byte[])rfiles.get(file));
    fstream.close();
    System.out.println(file.getName());
    catch(Exception e)
    {System.out.println(e.toString()); }
    private void openfile(File file,Object parent)
    File tempfile=null;
    try{
    String fname=file.getName();
    tempfile=File.createTempFile("temp",fname.substring(fname.lastIndexOf(".")));
    FileOutputStream fstream=new FileOutputStream(tempfile);
    System.out.println(tempfile.getAbsolutePath());
    //decide whether the file received or sent is to be saved
    if(((Container)parent).equals(textArea1))
    fstream.write((byte[])files.get(file));
    else
    fstream.write((byte[])rfiles.get(file));
    fstream.close();
    catch(Exception e){System.out.println(e.toString());}
    try{
    Process p1=r1.exec("cmd /c start " + tempfile.getAbsolutePath());
    p1.waitFor();
    catch(Exception e){System.out.println(e.toString());}
    //inner classes
    class ComponentHandler implements ContainerListener{
    public void componentRemoved(ContainerEvent ev)
    Container cont=(Container)ev.getChild();
    if(cont.getComponentCount()>0)
    JButton but=(JButton)cont.getComponent(0);
    files.remove((File)hfiles.get(but));
    hfiles.remove(but);
    public void componentAdded(ContainerEvent ev){}
    class AttachmentHandler extends MouseAdapter{
    public void mouseClicked(MouseEvent ev){
    if(ev.getModifiers()==4)
    Component comp=(Component)ev.getSource();
    File file=(File)hfiles.get(comp);
    popup=new JPopupMenu();
    JMenuItem popopen=new JMenuItem("Open");
    JMenuItem popsave=new JMenuItem("Save As..");
    popup.add(popopen);
    System.out.println(comp.getParent().getParent().getClass().toString());
    popopen.addActionListener(new ButtonHandler(file,comp.getParent().getParent()));
    popup.add(popsave);
    popsave.addActionListener(new ButtonHandler(file,comp.getParent().getParent()));
    popup.show(comp,12,12);
    class DragGestureHandler extends Vector implements DragGestureListener,DragSourceListener,Transferable{
    final static int FILE = 0;
    final static int STRING = 1;
    final static int PLAIN = 2;
    DataFlavor flavors[] = {DataFlavor.javaFileListFlavor,DataFlavor.stringFlavor,DataFlavor.plainTextFlavor};
    public void dragDropEnd(DragSourceDropEvent ev){}
    public void dragEnter(DragSourceDragEvent ev){}
    public void dragExit(DragSourceEvent ev){}
    public void dragOver(DragSourceDragEvent ev){}
    public void dropActionChanged(DragSourceDragEvent ev){}
    public void dragGestureRecognized(DragGestureEvent ev)
    System.out.println("recognized");
    File file=(File)hfiles.get(ev.getComponent());
    addElement(file);
    ev.startDrag(DragSource.DefaultCopyDrop,this,this);
    /* Returns the array of flavors in which it can provide the data. */
    public synchronized DataFlavor[] getTransferDataFlavors() {
    return flavors;
    /* Returns whether the requested flavor is supported by this object. */
    public boolean isDataFlavorSupported(DataFlavor flavor) {
    boolean b = false;
    b |=flavor.equals(flavors[FILE]);
    b |= flavor.equals(flavors[STRING]);
    b |= flavor.equals(flavors[PLAIN]);
    return (b);
    public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException,IOException
    if(flavor.equals(flavors[FILE])){return this;}
    else if (flavor.equals(flavors[PLAIN])) {
    return new StringReader(((File)elementAt(0)).getAbsolutePath());
    } else if (flavor.equals(flavors[STRING])) {
    return((File)elementAt(0)).getAbsolutePath();
    } else {
    throw new UnsupportedFlavorException(flavor);
    //inner class for draging in the files on java frame
    class DragDropHandler implements DropTargetListener{
    public void dragEnter(DropTargetDragEvent ev){
    public void dragExit(DropTargetEvent ev){
    public void dragOver(DropTargetDragEvent ev){
    public void drop(DropTargetDropEvent ev){
    Transferable tf1=ev.getTransferable();
    DataFlavor fl[]=ev.getCurrentDataFlavors();
    if(ev.isDataFlavorSupported(DataFlavor.javaFileListFlavor))
    ev.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
    try{
    java.util.List fileList = (java.util.List)tf1.getTransferData(DataFlavor.javaFileListFlavor);
    Iterator iterator = fileList.iterator();
    while (iterator.hasNext())
    File file = (File)iterator.next();
    if(file.isFile())
    Icon icon=chooser.getIcon(file);
    FileInputStream fstream=new FileInputStream(file);
    int filedata=(new Double(file.length())).intValue();
    byte bytes[]=new byte[filedata];
    fstream.read(bytes);
    files.put(file,bytes);
    ev.getDropTargetContext().dropComplete(true);
    addAttach(fileList);
    catch(Exception e)
    {System.out.println(e.toString() + "here");}
    public void dropActionChanged(DropTargetDragEvent ev){
    class MouseHandler extends MouseAdapter{
    public void mouseClicked(MouseEvent me)
    TreePath tp=tree.getPathForLocation(me.getX(),me.getY());
    if(tp!=null)
    if(tp.getPathCount()==3)
    toalias=tp.getPathComponent(2).toString();
    togroup=tp.getPathComponent(1).toString();
    System.out.println(toalias);
    if (!(toalias.equals(fromalias) && togroup.equals(fromgroup)))
    System.out.println("hh " + toalias);
    label4.setText(tp.getPathComponent(2).toString() + "_@" + tp.getPathComponent(1).toString());
    class ButtonHandler implements ActionListener{
    private File file;
    private Object parent;
    //constructors
    public ButtonHandler()
    public ButtonHandler(File file,Object parent)
    this.file=file;
    this.parent=parent;
    //other functions
    public void actionPerformed(ActionEvent ev){
    String s=ev.getActionCommand();
    System.out.println(s);
    if(s.equals("Send with Audio..."))
    //Audio audio=new Audio(client,false,"CAPTURE");
    if(s.equals("Disconnect"))
    try{
    // server.disconnect(client);
    client.getSound(3);
    cp.remove(jsp);
    label6.setVisible(false);
    //UnicastRemoteObject.unexportObject(client,true);
    button3.setText("Connect");
    textArea2.append("\nYou have been disconnected to Server");
    client.repaint();
    catch(Exception e)
    System.out.println(e.toString());
    if(s.equals("Connect"))
    // clp=new ClientProperties(client,false);
    if(s.equals("Save As.."))
    savefile(file,parent);
    if(s.equals("Open"))
    openfile(file,parent);
    if(s.equals("Attach"))
    //ExtensionFileFilter filter = new ExtensionFileFilter(false);
    //filter.addExtension(".txt",true);
    //filter.setDescription("Text Files(.txt)");
    // chooser.setFileFilter(filter);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    //chooser.setMultiSelectionEnabled(true);
    int returnVal = chooser.showOpenDialog(client);
    if(returnVal ==JFileChooser.APPROVE_OPTION)
    //File fp[]=chooser.getSelectedFiles();
    File fp[]=new File[1];
    fp[0]=chooser.getSelectedFile();
    int i=0;
    while(i<fp.length)
    try{
    File file=fp[0];
    Icon icon=chooser.getIcon(file);
    FileInputStream fstream=new FileInputStream(file);
    int filedata=(new Double(file.length())).intValue();
    byte bytes[]=new byte[filedata];
    fstream.read(bytes);
    files.put(file,bytes);
    catch(Exception e){dialog.showMessageDialog(client,e.toString(),"Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    return; }
    i++;
    java.util.List fileList=Arrays.asList(fp);
    addAttach(fileList);
    if(s.equals("Send"))
    try{
    if(toalias==null)
    dialog.showMessageDialog(client,"Select the Recepient First!!","Error:ChatApplication",JOptionPane.ERROR_MESSAGE);
    return;
    if(toalias!=null && togroup!=null && (!toalias.equals(fromalias)))
    // server.sendMessage(textArea1.getText(),files,toalias,togroup,fromalias,fromgroup);
    textArea1.setText("");
    catch(Exception e)
    e.printStackTrace();
    }//if ends
    class WindowEventHandler extends WindowAdapter{
    public void windowClosing(WindowEvent ev){
    try{
    //server.disconnect(client);
    client.getSound(3);
    // UnicastRemoteObject.unexportObject(client,true);
    catch(Exception e){System.out.println(e.toString());}
    dispose();
    private class onshutdown extends Thread{
    public void run(){
    try{
    //server.disconnect(client);
    //UnicastRemoteObject.unexportObject(client,true);
    catch(Exception e){}
    }//run ends
    I hope this helps,
    Denis

  • I, work on dell laptop latitudes version 7, win 7 64 bit, ssd disk, 16 gb ram. i receive the error 12 This device cannot find enough free resources that it can use. please help

    I, work on dell laptop latitudes version 7, win 7 64 bit, ssd disk, 16 gb ram.
    i receive the error 12 This device cannot find enough free resources that it can use. please help

    1. You have placed problem in wrong forum, or use different Windows operating system
    2. Double check your resources, namely in Disk manager. What is free space on HDD?
    Regards
    Milos

Maybe you are looking for