This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Spark in Action and have Jean-Georges Perrin on-line!
See this thread for details.
Win a copy of Spark in Action this week in the Open Source Projects forum!

Mike Hebear

Greenhorn
+ Follow
since Mar 19, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Hebear

Yes I am a student, and thanks for the help. I'll look into the JSP and servlets.
16 years ago
Thanks for the help. I am writing this for my high school which runs on a 7 day cycle. I created a text file with all the school days (weekends and holidays are excluded) and want to simply display what cycle day (1-7) coresponds with each date. This is the java program i have written that reads from the text file and returns what cycle day it is, the only problem is that in the constructor it needs to be sent the current date when a user visits the site:

import chn.util.*;

public class cycleDay
{
private int myMonth, myDay, myYear;

public cycleDay(int month, int day, int year)
{
myMonth=month;
myDay=day;
myYear=year;
}

public int getCycleDay()
{
FileInput inFile = new FileInput("noWeekEnds.txt");
int x=0, day=0, month=0, year=0;
while (!(day==myDay && month==myMonth && year==myYear))
{
month=inFile.readInt();
day=inFile.readInt();
year=inFile.readInt();
x++;
}
x%=7;
if (x==0)
x=7;
return x;
}
}

I know it reads all the dates in correctly and it returns the correct cycle day... I just dont know the easiest way to diplay it on a website, and the easiest way to send the program the current date. Sorry this post was so long, and thanks for the help! (www.hinghamschools.com)
16 years ago
I made a Java program that needs to be sents 3 integer values, and will return 1 integer value which will be printed w/ javascript. It needs to be accesessed through a website, so I was going to use a segment of javascript to do this. How can I send javascript "var" value to a java "int" value? If that isn't possible, how would I go about doing this? Thanks for the help.
16 years ago
Thanks for the help! You said it depends on my requirements and what Im trying to do... I work on my high school webpage, and we run on a 7 day cycle. Im just trying to make the webpage display what day it is... but I have to enter valid school days, account for weekends and vacations, snowdays, etc... So Im trying to keep a list of all valid school days and compare it to the current date to see if it's a valid school day, and then assign it 1-7 depending on what day of the cycle it is. Thanks for your previous help, and anything more specific would be appreciated!
16 years ago
Is there any way to store variables, integers etc, on the server for a web page? These variables are not specific to each person who logs on (so i only need to store a few variables total), but i dont want to re-do the calculation every time someone logs on, i want to store them on the server. Would you use servlets, applets, databases, textfiles, I just dont know. Any advice would be greatly appreciated.
16 years ago
I am making a scroller applet for my high school website. Right now, we have an unregistered scroller on the page, and my jon is to make one that looks just like it (source code wasn't included). I have everyhting working except the links. If you know a way to make links like the scrollbar on the site, plz tell me.. or source code to similar scrollers. Thanks in advance! (the site is http://www.hinghamschools.com)
16 years ago
Thanks for the advice about the components. Unfortunately, I'm not very familiar with how components work. Does anyone know any good tutorials etc. about components so that I can learn how to use them and add MouseListener to them? Thanks in advance.
16 years ago
How do you make the MouseListener follow a specific string in a scrollbar applet? I want some of the lines to be links when clicked on. Example code or any advice would be appreciated. Thanks in advance!
16 years ago
good example, thank you very much. I cant beleive i didnt find that!
16 years ago
Thanks for the help about the links. I did already know about that showDocument line, so my question is mainly regarding the mouseListener and how to have it follow a single line down the scrollbar. Thanks in advance.
16 years ago
I am making a scrollbar in Java for my High School Website, and i works fine... except for the fact that I need the lines to be read from a text file instead of through parameters for ease in updating the info in the scrollbar for less computer-inclined people. Below is the code for my scrollbar so far (its kinda long so you may not wanna read all of it, any example of reading code from a text file and putting it in a string array would be appreciated). Please Help!!! Thanks in Advance.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class scrollerOriginal extends Applet
implements Runnable { // Threaded application
int maxLines=100, // Added by a user
direction=0, // 0=up, 1=down
delay=100, // delay, controls scroll speed
spacing=12, // spacing, between lines
XPos=5, // XPos, indent
maxLine=0, // maxLine, # of Lines being sent
current, // current, initial position
height; // height, of the applet
String[] Line = new String[maxLines];// Lines, to be displayed, 12 max
Image offImage, bg; // Double buffering to eliminate
Graphics offGrfx; // frame flicker
Font outFont; // Output font (if passed)
boolean customFont = false; // Flag, is there a custom outFont?
Color background, fontColor;
Thread runner;
public void init() {
/**** Get attributes, if available ****/
String bgRed$ = getParameter("BGRED");
String bgGreen$ = getParameter("BGGREEN");
String bgBlue$ = getParameter("BGBLUE");
String fgRed$ = getParameter("FGRED");
String fgGreen$ = getParameter("FGGREEN");
String fgBlue$ = getParameter("FGBLUE");
String spacing$ = getParameter("SPACING");
String delay$ = getParameter("DELAY");
String XPos$ = getParameter("XPOS");
String maxLine$ = getParameter("MAXLINE");
String background$ = getParameter("BACKGROUND");
String fontName$ = getParameter("FONTNAME");
String fontSize$ = getParameter("FONTSIZE");
String direction$ = getParameter("DIRECTION");
/**** Data lines ****/
for (int x=0; x<maxLines; x++) {
Line[x] = getParameter("LINE" + Integer.toString(x+1));
}
/**** Setting Font ****/
if ((fontSize$ != null) && (fontName$ != null)) {
int size = Integer.parseInt(fontSize$);
outFont = new Font(fontName$, Font.PLAIN, size);
customFont = true;
}
/**** Find maxline ****/
for (int x=0; x<maxLines; x++) {
if (Line[x] == null) break;
maxLine++;
}
/**** Convert color values ****/
int Red=255;
if (bgRed$ != null)
Red = Integer.parseInt(bgRed$);
int Green=255;
if (bgGreen$ != null)
Green = Integer.parseInt(bgGreen$);
int Blue=255;
if (bgBlue$ != null)
Blue = Integer.parseInt(bgBlue$);
int fRed=0;
if (fgRed$ != null)
fRed = Integer.parseInt(fgRed$);
int fGreen=0;
if (fgGreen$ != null)
fGreen = Integer.parseInt(fgGreen$);
int fBlue=0;
if (fgBlue$ != null)
fBlue = Integer.parseInt(fgBlue$);
/**** Convert attribute values ****/
if (spacing$ != null)
spacing = Integer.parseInt(spacing$);
if (delay$ != null)
delay = Integer.parseInt(delay$);
if (XPos$ != null)
XPos = Integer.parseInt(XPos$);
height = size().height;
if (direction$ != null)
direction = Integer.parseInt(direction$);
if (background$ !=null)
bg = getImage(getDocumentBase(), background$);
/**** Set init index ****/
if (direction == 0) {
current = height;
}
else {
current = -(maxLine * spacing);
}
/**** Set foreground color ****/
fontColor = new Color(fRed, fGreen, fBlue);
/**** Set background color ****/
background = new Color(Red, Green, Blue);
setBackground(background);

/**** Init buffer ****/
offImage = createImage(size().width, size().height);
offGrfx = offImage.getGraphics();
}
public void paint(Graphics screen) {
/**** Clear prev image ****/
offGrfx.setColor(background);
offGrfx.fillRect(0,0,size().width, size().height);
/**** Draw background ****/
if (bg != null)
offGrfx.drawImage(bg, 0, current - height, null);
/**** Set custom font ****/
offGrfx.setColor(fontColor);
try { offGrfx.setFont(outFont); }
catch (NullPointerException e) {}
/**** Draw lines ****/
if (direction == 0) {
for (int i=0; i<maxLine; i++)
offGrfx.drawString(Line[i], XPos, current + (i * spacing));
}
else {
for (int i=0; i<maxLine; i++)
offGrfx.drawString(Line[i], XPos, current + ( (maxLine-i) * spacing));
}
/**** Flip buffer to screen ****/
screen.drawImage(offImage, 0, 0, this);
}
public void update(Graphics screen) {
/**** Override update ****/
paint(screen);
}
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void run() {
while (true) {
repaint();
if (direction == 0) {
current--;
if ((current + (maxLine * spacing)) < 0)
current = height + spacing;
}
else {
current++;
if (current > height)
current = -(maxLine * spacing);
}
try { Thread.sleep(delay); }
catch (InterruptedException e) { }
}
}
public void stop() {
if (runner != null) {
runner.stop();
runner = null;
}
}
}
16 years ago
I am making a scrollbar in Java for my High School Website, and i works fine... except for the fact that I need some of the lines to be links. I was wondering if anyone had a basic example of how to make links in an applet, especially on a movie string like the one I have. Below is the source code that runs the scrollbar without links (it's kinda long, if you dont want to read it all, any example of basic links in java applets would be appreciatated), If you could help me make some of the lines links, that would be great. Thanks in Advance!
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class scrollerOriginal extends Applet
implements Runnable { // Threaded application
int maxLines=100, // Added by a user
direction=0, // 0=up, 1=down
delay=100, // delay, controls scroll speed
spacing=12, // spacing, between lines
XPos=5, // XPos, indent
maxLine=0, // maxLine, # of Lines being sent
current, // current, initial position
height; // height, of the applet
String[] Line = new String[maxLines];// Lines, to be displayed, 12 max
Image offImage, bg; // Double buffering to eliminate
Graphics offGrfx; // frame flicker
Font outFont; // Output font (if passed)
boolean customFont = false; // Flag, is there a custom outFont?
Color background, fontColor;
Thread runner;
public void init() {
/**** Get attributes, if available ****/
String bgRed$ = getParameter("BGRED");
String bgGreen$ = getParameter("BGGREEN");
String bgBlue$ = getParameter("BGBLUE");
String fgRed$ = getParameter("FGRED");
String fgGreen$ = getParameter("FGGREEN");
String fgBlue$ = getParameter("FGBLUE");
String spacing$ = getParameter("SPACING");
String delay$ = getParameter("DELAY");
String XPos$ = getParameter("XPOS");
String maxLine$ = getParameter("MAXLINE");
String background$ = getParameter("BACKGROUND");
String fontName$ = getParameter("FONTNAME");
String fontSize$ = getParameter("FONTSIZE");
String direction$ = getParameter("DIRECTION");
/**** Data lines ****/
for (int x=0; x<maxLines; x++) {
Line[x] = getParameter("LINE" + Integer.toString(x+1));
}
/**** Setting Font ****/
if ((fontSize$ != null) && (fontName$ != null)) {
int size = Integer.parseInt(fontSize$);
outFont = new Font(fontName$, Font.PLAIN, size);
customFont = true;
}
/**** Find maxline ****/
for (int x=0; x<maxLines; x++) {
if (Line[x] == null) break;
maxLine++;
}
/**** Convert color values ****/
int Red=255;
if (bgRed$ != null)
Red = Integer.parseInt(bgRed$);
int Green=255;
if (bgGreen$ != null)
Green = Integer.parseInt(bgGreen$);
int Blue=255;
if (bgBlue$ != null)
Blue = Integer.parseInt(bgBlue$);
int fRed=0;
if (fgRed$ != null)
fRed = Integer.parseInt(fgRed$);
int fGreen=0;
if (fgGreen$ != null)
fGreen = Integer.parseInt(fgGreen$);
int fBlue=0;
if (fgBlue$ != null)
fBlue = Integer.parseInt(fgBlue$);
/**** Convert attribute values ****/
if (spacing$ != null)
spacing = Integer.parseInt(spacing$);
if (delay$ != null)
delay = Integer.parseInt(delay$);
if (XPos$ != null)
XPos = Integer.parseInt(XPos$);
height = size().height;
if (direction$ != null)
direction = Integer.parseInt(direction$);
if (background$ !=null)
bg = getImage(getDocumentBase(), background$);
/**** Set init index ****/
if (direction == 0) {
current = height;
}
else {
current = -(maxLine * spacing);
}
/**** Set foreground color ****/
fontColor = new Color(fRed, fGreen, fBlue);
/**** Set background color ****/
background = new Color(Red, Green, Blue);
setBackground(background);

/**** Init buffer ****/
offImage = createImage(size().width, size().height);
offGrfx = offImage.getGraphics();
}
public void paint(Graphics screen) {
/**** Clear prev image ****/
offGrfx.setColor(background);
offGrfx.fillRect(0,0,size().width, size().height);
/**** Draw background ****/
if (bg != null)
offGrfx.drawImage(bg, 0, current - height, null);
/**** Set custom font ****/
offGrfx.setColor(fontColor);
try { offGrfx.setFont(outFont); }
catch (NullPointerException e) {}
/**** Draw lines ****/
if (direction == 0) {
for (int i=0; i<maxLine; i++)
offGrfx.drawString(Line[i], XPos, current + (i * spacing));
}
else {
for (int i=0; i<maxLine; i++)
offGrfx.drawString(Line[i], XPos, current + ( (maxLine-i) * spacing));
}
/**** Flip buffer to screen ****/
screen.drawImage(offImage, 0, 0, this);
}
public void update(Graphics screen) {
/**** Override update ****/
paint(screen);
}
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void run() {
while (true) {
repaint();
if (direction == 0) {
current--;
if ((current + (maxLine * spacing)) < 0)
current = height + spacing;
}
else {
current++;
if (current > height)
current = -(maxLine * spacing);
}
try { Thread.sleep(delay); }
catch (InterruptedException e) { }
}
}
public void stop() {
if (runner != null) {
runner.stop();
runner = null;
}
}
}
16 years ago
I am making a java applet that scrolls words up. I have that part working fine when i input the Strings to be shown through parameters. However, when i try to input from a text file into and array of Strings, it always gives me errors or says "Applet not Initialized", Also, i am having trouble with making some of the Lines as links. Any help would be appreciated, especially any example code. I did not paste my program on here because it is fairly lengthy, but if somone is willing to help, i can send them the code. Thanks in advance.
16 years ago
I am making a java applet that scrolls words up. I have that part working fine when i input the Strings to be shown through parameters. However, when i try to input from a text file into and array of Strings, it always gives me errors or says "Applet not Initialized", Also, i am having trouble with making some of the Lines as links. Any help would be appreciated, especially any example code. I did not paste my program on here because it is fairly lengthy, but if somone is willing to help, i can send them the code. Thanks in advance.
16 years ago
I am making a java applet that scrolls words up. I have that part working fine when i input the Strings to be shown through parameters. However, when i try to input from a text file into and array of Strings, it always gives me errors or says "Applet not Initialized", Also, i am having trouble with making some of the Lines as links. Any help would be appreciated, especially any example code. I did not paste my program on here because it is fairly lengthy, but if somone is willing to help, i can send them the code. Thanks in advance.
16 years ago