Internet Accesses Freeze Java Application

I have been programming a Java application, which is actually an instant text messaging system, that obviously makes internet accesses.
The thing is, I have got this JFrame, with JScrollPanes, JTextAreas for messaging, and whenever the user presses the magical 'send' button; till the reply comes, the window freezes; you know it turns into grey.
The way I send the messages is just to call the method that makes the connections and writes the data.
How should I modify my code that my application should not freeze while waiting response? Is there a way to decrease the priority of a method or something?
Thanks in advance..

To clarify a bit.
When you press the button an event is generated and put into the
event handling queue (which handles all awt/swing events such as redraws/resizes etc). The Queue is processed by the event processing
thread which pulls the button pressed event from the queue, finds
the associated eventHandlers and calls them. What this means is that
any code inside your event handler is run in the Event handling thread
which causes it to not be able to handle any more events until the
code in your handler is finished. Therefore all refreshes/button presses
/resizes etc. (everything to do with the GUI and some other bits too)
stop responding until your handler returns. Creating network connections
can take a fair bit of time which means your handler takes a fair amount
of time which means that the GUI locks up for a fair amount of time.
Right, that there is the reason your GUI stalls.
now, as pkwooster said, the way around this is to create a seperate
thread that handles your connections to the internet. At the simplest
level this thread can be created inside your "button pressed" event handler
. For more complex solutions you will need to find someway of notifying
a running thread that you have more work for it.
pkwooster also said that there is a lot of code in this forum on topics
related to the task you are attempting. You might wish to take his
advice and look for it.
matfud

Similar Messages

  • Internet Explorer in Java Application

    Hello,
    I would like to embed MS Internet Explorer in java application.
    What I am trying to do is to add voice-interface where user can access menu items, toolbar buttons etc by using speech, instead of clicking by mouse or keyboard. I need to have Internet Explorer with all of its menus' etc but I would like to have a control to modify them and add my own functionality such as speech recognition commands.
    Any Help will be greatly appreciated.
    Regards,
    Asaf

    Get njawin package at
    http://www.simtel.net/product.php?id=60701&sekid=0&SiteID=simtel.net
    There you will find an example for MS WebBrowser (WebBrowserExample.jar). The example sources are packed in JAR.

  • How java application can access other java application

    Hi everyone,
    Please help me, I need to know how I can make my java program,
    specifically a servlet, access other java application continuously running a single instance in java virtual machine, and vice-versa.
    thanks in advance

    A java application is just a bunch of classes with one designated as a main class. You can simply ensure the classes are available to the server's jvm and then load and run the "external" program as part of the servlet process.
    If you have full access, and which external program is to be run, you can simply import it in your source.
    If your don't have the details at run time use the java.reflect.* stuff to load and run the class dynamically.

  • Access database/ java application/ jdbc odbc

    i am building an access database with a java application and get the following error message when i try to run the application. the log in window that i have does not have a password text field, only a field for the odbc name.
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Not a valid password.
    at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6106)
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:6263)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.java:2488)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOdbcConnection.java:317)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDriver.java:160)

    User/password are usually necessary to set up the ODBC source. So you may need find out who set up your ODBC source. Or you need find the correct user/password and reset the ODBC source.
    PC

  • Temporary Internet Files in Java Application

    Hello,
    I would like to know how to use "Temporary Internet Files" in a Java application.
    When I make a Java Applet that fetch some internet files and launch it from internet browsers,
    the fetched files are cached in "C:\Documents and Settings\***\Application Data\Sun\Java\Deployment\cache\6.0"
    as "Temporary Internet Files". However when I launch it from Applet Viewer in eclipse or use the
    fetching code from a Java application, no files are cached in the directory.
    Is it possible to enabling cache with a Java application?
    Here is the test code I used.
    final String USER_AGENT = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)" ;
    String urlString = "http://www.abysse.co.jp/japan/pref/images/hokkaido4.jpg";
    URL url = new URL( urlString );
    URLConnection conn = url.openConnection();
    conn.setDoOutput( true );
    conn.setRequestProperty( "User-Agent", USER_AGENT );
    DataInputStream in = new DataInputStream(conn.getInputStream());
    byte[] jpgBytes = new byte[conn.getContentLength()];
    in.readFully(jpgBytes);
    FileOutputStream fos = new FileOutputStream("C:\\httpoutap.jpg");
    fos.write(jpgBytes);
    fos.flush();
    fos.close();
    fos = null;Edited by: mirror_j on Jan 28, 2009 12:22 AM

    mirror_j wrote:
    I would like to know what the caching feature is build in.As I said "You cannot enable it as it is not a built in feature."
    This is not strictly correct. You can use LinkedHashMap for a simple cache, but its not a persisted cache so wouldn't be very useful for you.
    I suggest you look at using ehcache. It free and widely used.

  • JavaCard applications on SIM accessing personal Java applications

    Are personal java applications also applets just like Java Card Applets.
    Also i am programming the SIM of the mobile phone which is a Java Card.
    How can a Personal java application on the phone communicate with a JavaCard application on the card or vice versa. Please Note that for the user they are similar.i.e. they exist side-by-side on the same menu of the phone with the user having no clue that the application resides on the phone ( a personal java application) or on the card( a javacard application).
    Can anyone tell me of some way for one personal java application to access a JavaCard application?
    Thanks
    SKhan

    At the moment there exist no way to access the Java Card / smartcard in a J2ME/personal Java device. Currently we are working in JSR177 on the problem.

  • Internet Access in Java

    Hello
    I wish to get stock details for my Stock Tracker application in Java. Can anyone help me with the name of a website from which I can access these details through the program.

    Hi, that's not a java related question, and how will
    we be able to tell you a site if we don't know which
    stocks you own?
    KajI meant entering stock symbol and retrieving the stock details. I am copying portion of the program and the bold underlined line for the required URL.
    import java.util.*;
    import java.io.*;
    import java.net;
    public class StockQuoteRetriever
    protected String m_strSymbol = new String();
    protected String m_strCompanyName = new String();
    protected String m_strLastSale = new String();
    protected String m_strHigh = new String();
    protected String m_strLow = new String();
    protected String m_strVolume = new String();
    protected String m_strOpen = new String();
    protected String m_strClose = new String();
    protected String m_str52WeekHigh = new String();
    protected String m_str52WeekLow = new String();
    InternetManager m_internetManager = new InternetManager();
    HTMLParser m_htmlParser = new HTMLParser();
    public StockQuoteRetriever()
    public StockQuoteRetriever( String strSymbol )
    setSymbol( strSymbol );
    public void setSymbol( String strSymbol )
    m_strSymbol = strSymbol;
    public String getSymbol()
    return m_strSymbol;
    public String getCompanyName()
    return m_strCompanyName;
    public Float getLastSale()
    return makeFloat( m_strLastSale );
    public Float getHigh()
    return makeFloat( m_strHigh );
    public Float getLow()
    return makeFloat( m_strLow );
    public Float getVolume()
    return makeFloat( m_strVolume );
    public Float getOpen()
    return makeFloat( m_strOpen );
    public Float getClose()
    return makeFloat( m_strClose );
    public Float get52WeekHigh()
    return makeFloat( m_str52WeekHigh );
    public Float get52WeekLow()
    return makeFloat( m_str52WeekLow );
    public Boolean update()
    if( m_strSymbol.length() == 0 )
    return new Boolean( false );
    String strURL = new String
    "http://? ?" + m_strSymbol );
    String strHTML = new String();
    try
    strHTML = m_internetManager.getHTMLPage( strURL );
    catch( MalformedURLException e )
    System.out.println( "URL Error: " +
    e.toString() );
    return new Boolean( false );
    catch( IOException e )
    System.out.println( "IO Error: " +
    e.toString() );
    return new Boolean( false );
    if( m_htmlParser.parsePage( strHTML ).booleanValue() == false )
    return new Boolean( false );
    }

  • Accessing Non Java Applications thru Java Program

    Hye guys,
    I need help regarding this :
    Suppose I have a application which is non Java and application have several windows. Can I through a Java Program get the information abt the most active topmost window of the application?
    I think that only windows Task Manager knows abt the application and the child process(which is a different windows in this case ) and thus my Java Program have to do the low level system programming to
    get info from the task Manager, but that will be make my program platform dependent.
    Can we have a generalised program for this problem?
    Help in this regard will be highly appreciated..
    Thanks a lot

    Hm, a platform-independent way to get information about OS-specific processes? Not likely.

  • R/3 access to external application

    I am a newbie in SAP. I have an existing system developed by JAVA.
    How can I do if R/3 completed any transaction(SO, PO), it will send the transaction data to the JAVA application?
    I search on the Internet and found the JCO component that allow R/3 access a JAVA application.
    Or, if it is possible to use BAPI to achieve this?
    Thank you very much~~~~~

    Hi,
    You can't pass data to your java application directly from SAP R/3 but you can execute any window application from sap program.
    Meanwhile you can call sap transaction from you java application using jco connector. there is also alternate many way to transfer data from SAP to Non SAP application.
    Write a program in sap to store data in flat file and read data from file in java application.
    Edited by: Ravishankar Lanjewar on May 19, 2010 3:51 PM

  • How can I install a jre on client machines with no Internet Access

    Hi
    I have a lot of client machines located throughout the country which are connected to a central network (Oracle) application server. The client machines do not have internet access. The application now uses an applet which is accessible from the network. I would like to use the <jsp:plugin> tag to automatically download and install a jre on the client browsers that don't have a jre installed, when they access the jsp page. Unfortunately, even using iepluginurl="http://server-address/jinstall-1_4_2-windows-i586.cab, the client machines still need to access the internet to install the JRE as the cab file needs to access files at the Sun site.
    Is there any online jre installer, that can be used on a network where the client machines do not have internet access? Or do I need to install the JRE manually on each machine? The browsers are all Microsoft Internet Explorer.
    Thanks
    David

    Thanks for your reply ChuckBing.
    Unfortunately I had already copied the instructions I found in the Sun documentaion to the letter and it still needed access to the internet. In the end I solved the problem by pointing the iepluginurl to a non existent file and putting a URL, pointing to an offline JRE executable on the server, as the message that appears when the applet cannot be loaded. The clients then have the choice of downloading the JRE or installing it online by clicking on the URL.
    Thanks anyway.
    David

  • Flash as GUI for Java application or C++ executable

    I will need to create a flash frontend for a standalone application, preferrably written in java or c++. The application is needed to access some custom hardware and flash is desired for visual appeal.
    I've been searching the web about displaying flash in java or c++, but I couldn't find anything more than unanswered questions or projects that have apparently died (like swt.flash)
    As a last resort, we could do it as a servlet on localhost, that would be accessed via http by flash running in a projector.. Or even worse, a php script accessing a java application being accessed by flash from a projector.. but that seems like a wery wide workaround.. An application hosting a swf, communicating both ways directly would be much better.
    So.. does anyone have any idea if this is still possible and if so, how?
    Thanks.

    Hi, try to read
    Note 314568 - SAP GUI for HTML functionality / Limitations / Sp. Behaviour
    and all other information directly
    SAP GUI Family
    Regards.

  • Java and internet access

    Hello all,
    I have been trying to upload a URL in my java application but I am always getting URL not reachable error message generating from a thrown exception. I know this may be easy but I am not able to find any solution for this is there a way to set java access to the internet other than modifying the plugin with the proper proxy setting ?

    Try searching with Google and find an answer in seconds.
    http://www.javaworld.com/javaworld/javatips/jw-javatip42.html
    http://www.rgagnon.com/javadetails/java-0085.html

  • Nokia 2730classic java applications cannot access ...

    I have nokia2730classic and when i access java applications through internet it doesnot work.but it works with default opera browser.moreover, i am not able to upgrade my browser.
    Please help

    You better contact your Service Provider. It's strange that it is only Java that causes the problem.
    ‡Thank you for hitting the Blue/Green Star button‡
    N8-00 RM 596 V:111.030.0609; E71-1(05) RM 346 V: 500.21.009

  • Access denied error for Java application on 2630

    Hello!
    I have bought a 2630 recently. Now I have installed a small Java application that tries to store some data in the phones memory. However, each time the application tries to do so, I get a "java.lang.SecurityException Access denied" message and the application states that it could no save its data. I have set the security settings for that particular application so that the phone should ask before each access to the file system. In fact, before I get the error message, the phone asks whether the application may write data to the file system. But still answering that question with "yes" I get the Access denied error message. Now I am puzzled. By the way, the application uses JSR-75 which the 2630 should support.
    Anybody any ideas?
    Regards,
    Volker

    RESOLVED!
    I was able to create file from java application on Nokia 2630. Here is how:
    1. root C:/ is mapped to folder "Downloads"
    2. The folders does not show with their names
    3. there are 2 folders in C:/ predefgallery and predefjava
    4. in predefgallery there are several predefined folders e.g. predefrecordings is one of them
    5. I am able to create file inside predefrecordings, creating file in upper folders is denied
    6. user created folders aro NOT shown at all
    7. I had to manualy confirm reading of data many times and writing data once.
    I hope this can help to other Nokia users since I did not find this anywhere.
    Luke

  • How to access(connect) BI Data in webdynpro for java applications

    Hi ,
    is there any way to access and display the BI data in portal using webdynpro for java applications like we did in Visual composer.
    if not how to integrate the BI data in webdynpro applications ?
    Regards,
    Govindu

    Hi,
    Yes there are ways to do it. But may your scenario and the scenario for which I have done may differ.
    You can use openhub to get the data in a flat file and then read it into weddynpro through a java service OR
    You can use DBlink(which i have done).
    Please refer the link below:
    [Link|Data from BW to Oracle.;
    This I have done in NW04s. Not sure whether a better solution is available in the newer release.
    Hope it helps.
    Regards,
    Manoj

Maybe you are looking for

  • Help needed in Radio buttons (ABAP web dynpro)

    Hi all, I need to implement 2 stand alone Radio buttons (not groupbykey or groupbyindex). I could add the same in my view layout, but I am not sure how to use the KeyToSelect and SelectedKey options. How do I control when the button is selected/desel

  • How can I add geolocation to a picture in the new Photos?

    In iPhotos it was really simple to add the location. In Photos Version 1.0 (209.52.0) I have not been able to do it.

  • No text in characteristic

    I made a mistake marking the the previous topic with the same name as solved!!! Problem still not solved! Hello, I have the following problem. Charasteristic has text.Data to infocube was uploaded later than text and master data for charasteristic. M

  • Powerline adapter connection to switch

    Hi, I have had BT Infinity installed last week and quickly found out that my speeds are much better wired than wireless. After a little research, I am planning to buy the following two products: TP-Link PA411KIT AV500 500 Mbps Powerline Adapter - Twi

  • Conditional Display of Interactive Report Based On Different SQL Query

    Hello, I have two drop down list on top of my page and below that I have a interactive report. Based on user selection of values from drop down, interactive report should change based on different SQL queries. Is it possible to have different SQL que