Results 1 to 8 of 8
Thread: Applet - Text field issue
- 02-07-2013, 12:54 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
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.
- 02-07-2013, 12:55 PM #2
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
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.
- 02-07-2013, 01:04 PM #3
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.
- 02-07-2013, 01:26 PM #4
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
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
}
- 02-07-2013, 01:58 PM #5
Re: Applet - Text field issue
The code needs to show the problem.applet was running successfully.
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.
- 02-07-2013, 02:41 PM #6
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-07-2013, 02:42 PM #7
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 02-07-2013, 02:45 PM #8
Re: Applet - Text field issue
Cross posted
Java applet - Textfield issue - Stack Overflow
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Text Field Validation HELP
By Richard5324 in forum New To JavaReplies: 1Last Post: 11-17-2011, 05:29 PM -
Java Applet starts then the applet field goes light blue
By oki in forum Java AppletsReplies: 30Last Post: 08-26-2011, 09:05 PM -
Get value of JComboBox text field
By nik_meback in forum AWT / SwingReplies: 0Last Post: 01-07-2011, 02:48 PM -
Regarding Text Field
By adeeb in forum AWT / SwingReplies: 1Last Post: 06-05-2008, 11:01 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks