• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Applet working in appletviewer but no browser

 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i have been writeing the applets to use on y web page but it doesn't want to work in the browser, here is my code
note I think it's to do with the swing componet
/*
* ScrollingText.java
* Created on August 12, 2001, 10:28 PM
*/
import java.awt.*;
import java.util.StringTokenizer;
/**
* @author Hennie Louw
* @version 0.1 beta
*/
public class ScrollingText extends java.applet.Applet implements Runnable {
String displayText;
String text;
String textColor;
String backgroundColor;
Thread runner = null;
Color bgColor;
Color tColor;
char[] textArray;
int tR, tB, tG;
int bR, bB, bG;
int x;
boolean count = true;

/** Initializes the applet ScrollingText */
public void init () {

text = getParameter("TEXT");
textColor = getParameter("TEXTCOLOR");
backgroundColor = getParameter("BACKGROUNDCOLOR");
if (text == null) {
text = ("please enter the text you want to display in the applet in the html with <param name= text> tag ");
}
if (textColor == null) {
textColor = "255,255,255";
}
if (backgroundColor == null) {
backgroundColor = "0,0,0";
}
initComponents ();
initData();
}
/**
* This method is called from within the init() method to
* initialize the char[] with the correct data from
* the passed parrameter in the html page called "TEXT"
* the tag will look something like this
*<param name="text" value="It's a 20-hour Lan Party." >
*/
private void initData() {
textArray = text.toCharArray();
String tempString;
StringTokenizer stringTokenText = new StringTokenizer(textColor, ",");
x = 0;
while (stringTokenText.hasMoreTokens()) {
tempString = stringTokenText.nextToken();
if (x == 0) {
tR = Integer.parseInt(tempString);
}
if ( x == 1) {
tG = Integer.parseInt(tempString);
}
if (x == 2 ) {
tB = Integer.parseInt(tempString);
}
x++;
}
StringTokenizer stringTokenBack = new StringTokenizer(backgroundColor,",");
x = 0;
while (stringTokenBack.hasMoreTokens()) {
tempString = stringTokenBack.nextToken();
if (x == 0) {
bR = Integer.parseInt(tempString);
}
if ( x == 1) {
bG = Integer.parseInt(tempString);
}
if (x == 2 ) {
bB = Integer.parseInt(tempString);
}
x++;
}
tColor = new Color(tR,tG,tB);
bgColor = new Color(bR,bG,bB);
textArea.setBackground(bgColor);
textArea.setSelectedTextColor(tColor);
}

/** 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 FormEditor.
*/


private void initComponents () {//GEN-BEGIN:initComponents
textPanel = new java.awt.Panel ();
textArea = new javax.swing.JTextArea ();
setLayout (new javax.swing.BoxLayout (this, 1));
setBackground (java.awt.Color.black);
setName ("mainPanel");
setForeground (java.awt.Color.black);
textPanel.setLayout (new java.awt.GridLayout (1, 1));
textPanel.setFont (new java.awt.Font ("Dialog", 0, 11));
textPanel.setName ("panel3");
textPanel.setBackground (java.awt.Color.black);
textPanel.setForeground (java.awt.Color.white);
textArea.setWrapStyleWord (true);
textArea.setLineWrap (true);
textArea.setEditable (false);
textArea.setSelectedTextColor (java.awt.Color.orange);
textArea.setFont (new java.awt.Font ("Lucida Bright", 0, 12));
textArea.setBackground (java.awt.Color.red);

textPanel.add (textArea);

add (textPanel);

public void start() {
runner = new Thread(this);
runner.start();
}

public void run() {
while (count) {
textArea.setText(" ");
for (int x = 1; x < textArray.length; x++) {
try {
displayText = new String(textArray,0,x);
textArea.setText(displayText);
Thread.sleep(150);
} catch (InterruptedException e) {}
}
}
}
private java.awt.Panel textPanel;
private javax.swing.JTextArea textArea;
}
and i can't use awt other wise it doen't wrap itself in the size of the TextArea
please help
thanks
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17989
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java implementations in the two most popular browsers - Netscape and IE - are too old to support Swing. I don't know what Netscape's problem is, but Microsoft doesn't consider Java to be "innovative" enough.
You'll either have to find a way that works under AWT or use the Sun Java Plug-In - which means convincing users not to cancel when it pops up and wants to download over 5MB worth of Java.
 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Tim Holloway:
The java implementations in the two most popular browsers - Netscape and IE - are too old to support Swing. I don't know what Netscape's problem is, but Microsoft doesn't consider Java to be "innovative" enough.
You'll either have to find a way that works under AWT or use the Sun Java Plug-In - which means convincing users not to cancel when it pops up and wants to download over 5MB worth of Java.

thanks for thhe info if anyone can help me to find a way for it to work it will be a big help
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hennie,
Your last comment gave you your answer. If you can't use AWT then you will require every user to download the Java 2 plug-in.
Regards,
Manfred.
 
hennie louw
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Manfred Leonhardt:
Hi Hennie,
Your last comment gave you your answer. If you can't use AWT then you will require every user to download the Java 2 plug-in.
Regards,
Manfred.

I meant I don't know of a way to do it in awt, If someone knows of a way to make a awt TextArea do text warping please let me know
Regards
Hennie
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hennie,

Here's a really basic way of doing it... I basically made a custom component to do it... it does text wrap, but not word wrap( I'm kinda busy at work, so I didn't have time to implement word wrap! )... you could get it to do it, though, by checking for spaces to get a word, checking if the word will exceed the line, if it does, increment currentLine, drawString( theWord ), then add to currentRow...

Hope this helps you out...



-Nate
 
Januszs
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should consider using Suns webstart as opposed to using Applet technnology. Applets are a difficult technology to use and are likely to be supreseeded by webstart. Take a look at www.spidertop.com as well.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic