Results 1 to 8 of 8
  1. #1
    mmkannan88 is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Applet - Text field issue

    Hello all,

    I have an issue in my applet containing text filed. In my applet, the SetText function of the textfiled will be executed continuously to update a particular status. The text filed used is read only.
    When i double click the text filed during the SetText function is being executed , the applet hangs.
    The text filed will be updated continuously using thread.

    May i know the reason why it gets hanged. Help me in this issue.

    Waiting for a positive reply.

  2. #2
    mmkannan88 is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Applet - Text field issue

    Hello all,

    I have an issue in my applet containing text filed. In my applet, the SetText function of the textfiled will be executed continuously to update a particular status. The text filed used is read only.
    When i double click the text filed during the SetText function is being executed , the applet hangs.
    The text filed will be updated continuously using thread.

    May i know the reason why it gets hanged. Help me in this issue.

    Waiting for a positive reply.

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Applet - Text field issue

    Can you make a small complete program that compiles, executes and shows the problem that we could use for testing to see what the code is doing?
    If you don't understand my response, don't ignore it, ask a question.

  4. #4
    mmkannan88 is offline Member
    Join Date
    Feb 2013
    Posts
    3
    Rep Power
    0

    Default Re: Applet - Text field issue

    here is my sample code. but in this code, the applet was running successfully.

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package javaapplication18;

    import javax.swing.UIManager;
    public class Test1 extends javax.swing.JApplet {

    /**
    * Initializes the applet Test1
    */
    @Override
    public void init() {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see How to Set the Look and Feel (The Java™ Tutorials > Creating a GUI With JFC/Swing > Modifying the Look and Feel)
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClass Name());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(Test1.class.get Name()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(Test1.class.get Name()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(Test1.class.get Name()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(Test1.class.get Name()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the applet */
    try {
    java.awt.EventQueue.invokeAndWait(new Runnable() {
    public void run() {
    try
    {
    UIManager.setLookAndFeel ("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel ");
    }
    catch (Exception ex)
    {
    System.out.println (ex);
    //ex.printStackTrace();
    }
    initComponents();
    TestThread objTestThread = new TestThread (jTextField1);
    }
    });
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

    /**
    * This method is called from within the init() method to initialize the
    * form. WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    jTextField1 = new javax.swing.JTextField();
    jTextField2 = new javax.swing.JTextField();

    jTextField1.setEditable(false);
    jTextField1.setText("jTextField1");

    jTextField2.setText("jTextField2");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(101, 101, 101)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.Component Placement.UNRELATED)
    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addContainerGap(171, Short.MAX_VALUE))
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGroup(layout.createSequentialGroup()
    .addGap(37, 37, 37)
    .addGroup(layout.createParallelGroup(javax.swing.G roupLayout.Alignment.BASELINE)
    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
    .addContainerGap(243, Short.MAX_VALUE))
    );
    }// </editor-fold>
    // Variables declaration - do not modify
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    // End of variables declaration
    }


    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package javaapplication18;

    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JTextField;
    public class TestThread implements Runnable{
    JTextField jtf;
    Thread objThread;
    int iVal = 0;
    TestThread (JTextField tx1){
    jtf = tx1;
    objThread = new Thread (this);
    objThread.start();


    }
    @Override
    public void run() {
    while (true){
    WaitThread (100);
    if (iVal ++ == 20)
    iVal = 0;
    jtf.setText (""+iVal);
    }
    }

    public synchronized void WaitThread (long lTimeOutVal)
    {
    try
    {
    wait (lTimeOutVal);
    }
    catch (InterruptedException ExceWait)
    { }
    }//End WaitTableThread

    }

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: Applet - Text field issue

    applet was running successfully.
    The code needs to show the problem.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my response, don't ignore it, ask a question.

  6. #6
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Applet - Textfiled Issue

    Moved from Java Software.

    If you can't judge from the title of a forum whether it's the right place to post, just go through a few threads. If you had done that you would have clearly seen that your question doesn't belong there.

    Go through this tutorial: Lesson: Concurrency in Swing (The Java™ Tutorials > Creating a GUI With JFC/Swing) . and if you're not using Swing, tell us what you are using, along with a SSCCE (Short, Self Contained, Correct (Compilable), Example) that demonstrates the problem.

    Oh, and Java doesn't have functions. Java has methods.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Applet - Text field issue

    Please go through the Forum Rules, particualrly the second paragraph. Also go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming

    I'm merging the two threads here.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  8. #8
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Applet - Text field issue

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Text Field Validation HELP
    By Richard5324 in forum New To Java
    Replies: 1
    Last Post: 11-17-2011, 05:29 PM
  2. Replies: 30
    Last Post: 08-26-2011, 09:05 PM
  3. Get value of JComboBox text field
    By nik_meback in forum AWT / Swing
    Replies: 0
    Last Post: 01-07-2011, 02:48 PM
  4. Regarding Text Field
    By adeeb in forum AWT / Swing
    Replies: 1
    Last Post: 06-05-2008, 11:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •