|
-
Apr 24th, 2005, 09:15 PM
#1
Thread Starter
Junior Member
applet problem
Hi!
I'm very new to applets and I made an applet directly from another project that I had. When I start the applet in JBuilder everything works fine but when I start it with internet explorer i can click on my button but nothing works... i hope someone can help me it may be some refresh thing or something like that.
My applet
Thanks for help
Last edited by lemenz70; Apr 28th, 2005 at 11:03 PM.
William
-
Apr 25th, 2005, 02:47 PM
#2
Frenzied Member
Re: applet problem
You'll need to change some of the architecture of the program. You might have to use a Thread instead of timer...That way, you could already have the component added to the container at runtime instead of only when the buttons clicked. Then, when the button is clicked, start the thread.
-
Apr 25th, 2005, 03:43 PM
#3
Thread Starter
Junior Member
Re: applet problem
thanks I'll try with a thread.
-
Apr 25th, 2005, 03:57 PM
#4
Frenzied Member
Re: applet problem (solved)
Did you see the one I made with a thread? It's in the same thread(forum thread!) as Andy's, but mine scrolls horizontal.
-
Apr 25th, 2005, 05:29 PM
#5
Frenzied Member
Re: applet problem (solved)
-
Apr 25th, 2005, 05:58 PM
#6
Thread Starter
Junior Member
Re: applet problem (solved)
here is your code
Code:
public void run()
{
/* we start a while loop, that will loop will it is true, and since
* nothing ever makes it false it never stops. So no matter how long the
* program is run, it will always be going.
*/
while (true)
{
/* Since we are working with threads, we must put our operations in a try
* catch clause so that we can trap errors that will possibly arise.
*/
try
{
/* get the old text, which is just the text on the JLabel at this
* moment. We will need this later.
*/
String oldText = adLabel.getText();
/* create a new String, that will perform some operations on the old text
* and then set the text of the JLabel to the new text. The first part of this
* (substring(0)), takes one parameter, this parameter is the starting index of the
* string, and then grabs everything else. Again, index's start at index 0, so this
* is cutting the string off by one. So, if the text is "text", then the first part
* cuts it down to "ext". Then you have the concatenating operater(+) that adds text
* to the preceding string. The third part, oldText.substring(0,1), has two parameters,
* the beginning index, and the ending index. We specify 0, and 1. This basicly means it
* grabs the first character of the old text. So, if we had "text", as the label, then it
* would get the "t" out of text since it is the first letter. Then that is added to the\
* first operation(where we got "ext"....This ends up putting the text as "extt", but of course
* if you had spaces after the message, it would be much clearer("ext t", then "xt te", then
* "t tex", and last " text", and it would loop from there.
*/
StringBuffer newText = StringBuffer.append(oldText.substring(1) + oldText.substring(0, 1));
//set the text of the label to the new text
adLabel.setText(newText);
/* The thread class has a method called sleep(). This method will pause the thread for a given
* amount of time in milliseconds. We specify 250, but this can be changed. You put the time
* in milliseconds as the parameter for the method.
*/
Thread.sleep(250);
}
/* If you use a thread, you must catch the interrupted exception. This exception
* will occur if the thread is interrputed in anyway, hence the name interrupted
* exception. If this exception occurs, we don't want to continue.
*/
catch (InterruptedException e)
{
/* Since we don't want to continue if this exception occurs, we make a call to
* the stop method. This wll stop the thread all together.
*/
stop();
}
}
I can't make it run in my applet because of this:
StringBuffer newText = StringBuffer.append(oldText.substring(1) + oldText.substring(0, 1));
for some reason it makes an error...
-
Apr 25th, 2005, 07:10 PM
#7
Frenzied Member
Re: applet problem (solved)
What was the error?
I did this on a label, so that could be your problem. You must have the text on a label, or else you'll have to change a few lines.
-
Apr 26th, 2005, 08:02 PM
#8
Thread Starter
Junior Member
Re: applet problem (solved)
I added a label called adLabel but the problem comes from the append on the substring... it can't be done this way and maybe when I try to modify it I change it's effect in the applet and nothing works.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|