Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
lamentable dustman
Apr 13, 2007

🏆🏆🏆

Flamadiddle posted:

My HTML isn't up to my Java, which isn't up to much. How would you even get an HTML form to submit to the server-side application? With an HTTP Get or something?

What kind of webserver are you running? Honestly it sounds like java is over kill if all you need is a interface to get data into the database. I would consider just a PHP or a CGI page in perl or something to handle it. Should be able to find a tutorial online for either of those very easily.

To use a HTML you will need a Java application server (Tomcat/Jetty/GlassFish etc) as far as I know. From there it would be easier to write a JSP page. There are other ways of course, HttpServletRequest allows you to read GET data via getParameter(String). It's not a bad idea to set up an app server if you plan to write some more web apps but a little overkill for this project. If you run Apache then setting it up to forward the correct stuff to Tomcat isn't that hard, with IIS it is a little more difficult but doable.

Again, I don't think Java is the correct tool for the job here. PHP or a CGI script can open up the database handle you need and keep everything on the server side.

Adbot
ADBOT LOVES YOU

lamentable dustman
Apr 13, 2007

🏆🏆🏆

icehewk posted:

I'm still getting a 'few' errors. I think I'm missing something from the beginning


drat dude, I usually like helping people do their homework but you got some serious issues. Lets start with the obvious stuff.

code:
System.out.print("Enter employee's name: "); 
    Input = In.readLine(); 
    name = input;   
Why did you change this? It was actually correct from last night. rjmccall was giving you reasons why you should do it another way because of memory issues.

With the current iteration why did you remove the BufferedReader? You need that to read the input. What is 'Input' suppose to be? You never declared it, nor did you declare 'input'. Java is case sensitive so it sees those as different variables. From the code last night do this.

code:
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); 

    System.out.print("Enter employee's name: "); 
    String name = in.readLine();
See? That was what rjmccall was getting at. You never needed the String 'input'. Repeat all the way down.

Later on I notice you are using the variable 'Hours' instead of 'hours'. The variable 'Rate' is also not declared (guess it should be 'payrate').

Next issue are this line:
code:
double taxfed = ( Double.parseDouble(fed) * Double.parseDouble(gross) ); 
Above that line 'gross' was declared to be of type double so you don't need to parse a double out of it.


The above should get it close to compiling I would guess. It is obvious you are new to programming here (CS101?) but you need some help. Does you your school offer CompSci tutoring? If not go spend a few hours in the professors office.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

What kind of file are you reading from?

Edit: realized I didn't read carefully enough.

lamentable dustman fucked around with this message at 18:52 on Sep 21, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

If you need to do a round rather then just round up all you have to do is the following.

1) Divide by 5
2) Subtract .5 (cast to double for all this of course)
3) Call the ceiling function.
4) Multiply that by 5.

ex) 24/5 = 4.8 - .5 = ceiling(4.3) = 5 * 5 = 25
ex) 22/5 = 4.4 - .5 = ceiling(3.9) = 4 * 5 = 20

lamentable dustman
Apr 13, 2007

🏆🏆🏆

pearofducks posted:

I'm goofing around making a network game (lets call it tictactoe for now), and one player has to wait for the other to take their turn. To do this I have the waiting player sit in an infinite loop checking the input buffer to see if it has data yet, even with low thread priority and a big wait time this still sucks CPU like mad and makes a laptop take off. Is there anything that will let me get away from this loop? Maybe something that pushes the data instead of needing it to be constantly polled?

Try thread wait(). Set it to poll every half second or so. Co-worker had to do something similar last week to read from a ESB. Think he used a Thread object and simply told it to poll every second inside a loop.

Edit: I'm sure there are better ways to do it, we were pulling a 24 hour day trying to get code up for a demo that was scheduled for 8 in the morning.

lamentable dustman fucked around with this message at 06:03 on Sep 24, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Anyone have experience in image processing?

I wrote a servlet that resizes the image on the server side and sends the client a thumbnail of the original picture. Works really well and all.

We ran into a issue with a good portion of our pictures are corrupt. We haven't figured out were in the process it is corrupting yet as part of the process is out of our control. Now my servelet has nothing to do with the corruption but they want to see if we can have some kind of checker on it anyways, just for future issues.

Doing some googling right now and not seeing much. I'm also pretty sure it isn't possible without a hash to compare against but figured it is worth asking. Looking at files in a HEX editor dosen't show anything I might be about to compare against either.

The images are in jpeg format and I am turning them into a BufferedImage for processing.


EDIT: I was able to figure it out. The curropt images throws exceptions when you look at the metadata. Ran the code from the guy bellow and was getting "Bogus marker length" from javax.imageio.IIOException. Dude has a good blog, I've learned a lot of Perl tricks from him.

http://johnbokma.com/java/obtaining-image-metadata.html

lamentable dustman fucked around with this message at 16:10 on Sep 25, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Is there a way to iterate through every file in a directory? I've been looking at the File class and not seeing a way to do it. This has to do with my question yesterday, I want to clear out all the corrupt images that we are receiving.

They are stored on a Linux server, so Perl might be better suited for the task, it's just that I got a method to check for bad images already written in Java. Don't really want to try and reimplement it. That and Perl is yukky and I try to stay away from it when possible.


EDIT:

I'm an idiot. I missed the method listFiles(filter) in the File class. Something about posting a question here lets me figure out the answer in 5 minutes.

lamentable dustman fucked around with this message at 16:59 on Sep 26, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Boz0r posted:

I've been learning to write code in BlueJ, but it's poo poo. What IDE should I get instead?

Didn't know that was still out, used that back when I took my first programming class in college (used C++ during HS, Clemson taught Java).

Eclipse and Netbeans are the two best free ones. Lot of people like IntelliJ IDEA, never used it but you have to pay for it. Fore the most part I develop with Eclipse but have been playing around with Netbeans 6.5 Beta because of the improved webservices and groovy support.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

sonic bed head posted:

You need to use this.name and this.salary to change those variables in your increase/decrease methods.

Thought that at first, but it actually is a problem with integer math. He is passing a into into the increase/decrease functions then dividing by 100.

Sarah Sherman: in the declartion, change it from "int percent" to "double percent" to fix it. In any language that supports types you get to have fun with integer math. You think (Percent/100) will return .1 or whatever because you are taking decimal points for granted. Because Percent is declared as an integer Java will treat the product of the division function as a integer as well and that means chomping off the decimal point. So .5 becomes 0, 1.9 becomes 1, ect. Either make percent floating point or cast it to double by placing (double) in front of it.

code:
 public double decreaseSalaryByPercent(double percent){
                salary = salary - ((percent/100) * salary);
                return salary;
 }

or

public double decreaseSalaryByPercent(int percent){
                salary = salary - ((double)(percent/100) * salary);
                return salary;
 }
There other issues with your code but I doubt you have gotten to the idea of 'private' variables and such.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Sarah Sherman posted:

^^Ah, this seemed to have fixed it. Thanks!

I'm sorry, but I don't understand exactly what you mean :(

should I change the code to look like this?:

When i tried this, I was still having the same problem. Sorry for not understanding, I'm just learning java and OOP and still having some difficulties with some of its concepts.



The keyword 'this' tells java you mean to change the object's global variable. If you use the same variable name in a method Java assumes the the method variable is not the same as the global. For example from some code I am looking at:

code:
public class BinaryFileMessage {
	private String binaryBase64Object;

        public void setBinaryBase64Object(String binaryBase64Object) {
		this.binaryBase64Object = binaryBase64Object;
	}
}
The line __this.binaryBase64Object = binaryBase64Object;__ tells Java to set the methods instance of 'binaryBase64Object' to the global instance.

For more detail:

http://java.sun.com/docs/books/tutorial/java/javaOO/thiskey.html

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Edit: Dumb poo poo, should pay attention what I'm doing. You were doing it right.


Also what Incoherence said, that is why you are only getting 4 elements back I think.

lamentable dustman fucked around with this message at 19:55 on Oct 1, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Anyone know any good mapping library out there for java? For a project at work I'm going to feed some longitude/latitude/height data along with other data for that point, say air temperature. Going to want graph the data out as a topography, both 2D and 3D. Think something that looks like a dobbler radar.


Really doubt there is anything out there, just thought I would give it a shot.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

sonic bed head posted:

"".equals( str ) is NullPointer proof though, isn't it?

Yea because "" isn't technically null, it's just empty.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Trying to generate some images in Java. To visualize what the grid would look like:

code:
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
100 100 100 200 200 200 300 300 300 300 
The numbers are the z-axis and will be represented by different colors. I need to draw this and save to a png or jpeg file. Not sure how to go about it, I'm playing around with the AWT which I've never used before, any tips?

I would eventually like to make it 3D for an isometric view but that isn't required and down the road.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Yea, that looks like more what I need to do. Didn't occur to me that I could do that. I've only used BufferedImages to modify existing images, never to create one from scratch.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Mill Town posted:

Yeah, it's quite easy to create a new BufferedImage and just loop through all the pixels, filling them in with what you want. Something like this:

code:
BufferedImage im = new BufferedImage( IMAGE_WIDTH, IMAGE_HEIGHT, BufferedImage.TYPE_INT_RGB );
for(int i=0; i < IMAGE_WIDTH; i++){
    for(int j=0; j < IMAGE_HEIGHT; j++){
        int r, g, b;
        //Do your calculations here that fills in the RGB values in r, g, and b
        im.setRGB(i, j, r<<16 + g<<8 + b );
    }
}
I'm actually doing this in one of my servlets, it generates images from data programmatically and serves them up at a URL, it never even saves them anywhere.

Sweet, thanks man, looks like that is exactly what I needed to see. It looks like the line:

code:
im.setRGB(i, j, r<<16 + g<<8 + b ); 
should be:


code:
im.setRGB(i, j, r<<16 | g<<8 | b ); 
encase anyone is trying to run the code. Also tack on the end to write to a file:

code:
try {
			ImageIO.write(im, "jpeg", new File("c:/imageTest.jpg"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

lamentable dustman
Apr 13, 2007

🏆🏆🏆

He was saying to do that so you can figure out the global variable names better. Once you add the jar to the classpath of your project it should show up in the left pane. You should be able to explore the classes inside it. Once you import one of those classes to a new class you can use the code completion feature to get more meaningful global variable names. You obviously won't get the local names though.


Just out of curiosity, how do they expect you to fix the bug without the original source code? Doesn't make sense.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Kinda sorta. It's in between a scripting language and a full compile I guess.

Java is compile down to byte code. This does make decompiling easier but not 100% accurate. Comments are striped of course and I'm sure other optimizations are performed on the code. Variable names are changed to become more machine friendly. The decompiler makes due with these by assigning the variables the same name as the class name.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Actually, I might be wrong about the decompiler, looked at some of my code compiled code with DJ and it mostly matches the java code. So I dunno, when I've used it before it's always given me code that looks like "Object object1 = new Object()"

As for the applet, it runs in a browser right? What does the HTML code call? Should look something like this:

code:
<APPLET ARCHIVE= "demo.jar,
	CODE="demo.applet.Applet1" width=640 height=260
	ALT="You should see an applet, not this text.">
</APPLET>
What ever CODE is pointing to is the main class, IIRC.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Decompile all the code, add it to an Eclipse project, right click on 'com.appname' and choose 'run as applet'.

Not sure how much help it'll be without the original source code.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Fruit Smoothies posted:

I now get "applet not initialised"

ugh, lots of things cause that. Usually has to do with the classpath isn't matching up. Also you try passing the parameter you have to it. Right click on the class and choose run configurations. There is a tab for parameters.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Eclipse makes that file when it runs an Applet automatically. Generates the HTML to embed in a page or something, I always ignore it. No idea why it can't be read though. Is it even getting written? Permissions problem?

lamentable dustman
Apr 13, 2007

🏆🏆🏆

dancavallaro posted:

When I'm done with a project in Eclipse, is there an easy/automated way to deploy the project as an executable JAR file? Or I guess I'm just asking, what's the best way to deploy an Eclipse project as an executable application?

Right click on the project, choose export, expand Java. You'll have the option for JAR and executable JAR.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Google says to use a stream instead of File.

code:
BufferedImage img = ImageIO.read(getClass().getResourceAsStream("image.bmp"));
or something, didn't try it. Google "java read files inside jar" for some examples.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

RGB is already hex. FF = 255 F0 = 240

If it is really important extend the class or something and make a function to take a string or hex number, parse to separate the color pairs, make them ints, and pass to the real setColor (or whatever it is).

lamentable dustman
Apr 13, 2007

🏆🏆🏆

So I've been working on this applet/servlet combo for a while now. The applet communicates with a servlet that collects data and sends it back to the applet via HttpsURLConnection. I'm using an unsigned cert for now as everything is on my dev machine.

Everything was running good till I updated the Java version today and the applet started throwing "java.security.AccessControlException: access denied (java.net.SocketPermission localhost:8443 connect,resolve)

So far I've tried editing my java.policies file, disabling my firewall (though everything is local). I don't think it has to do with my cert as I can reach https://localhost:8443/, everything is encrypted. Also, when I first started using SSL with the applet I was getting different, more descriptive errors till I fixed it.


The code where it gets thrown is basically this:

code:
URL url = new URL("https://localhost:8443/WARFile/servletName");

HttpsURLConnection = (HttpsURLConnection) url.openConnection();
   conn.setDoOutput(true);
   conn.setDoInput(true);

OutputStream out = conn.getOutputStream();

ObjectOutputStream oos = new ObjectOutputStream(out);
The error gets thrown where 'out' is declared

edit: does the applet have to be signed or something? I'm not modifying anytihng on the client's system but I am connecting to something out of it's domain I guess. Like I said, it worked fine with 1.5 so I guess security is tighter in 1.6

lamentable dustman fucked around with this message at 23:03 on Dec 29, 2008

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Ensign Expendable posted:

You're missing a variable name. Shouldn't it be
code:
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
   conn.setDoOutput(true);
   conn.setDoInput(true);

whoops, it is there in the real code. The code is on a secure system that can't reach the internet so I couldn't c/p it.

Eclipse would of caught that pretty fast anyways.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

I figured it out, it was an issue with java versions. I've been using the Eclipse plugin 'Web Tools Platform' which had a section called 'facets' that needed the compiler level changed in. I was getting an error from it apparently but didn't notice, it looked like it was compiling anyways.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

GregNorc posted:

words....

They have a weird way of indenting but the GameHelper class should be it's own file (or keep it inside SimpleDotCom and move that import statement). You can only have an import at the head of a file. You'll have to fix the bracketing of the main class.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

GregNorc posted:

Ok... yeah that's what I hate... the book is GREAT at making OO concepts understandable but it has the bad habit of putting a bunch of classes in one java file, then sometimes it wants you to keep a class by itself in it's own little file, and doesn't really distinguish between the two.

I'll try putting in it's own file. Thanks.

if you are still having problems this is how it should be. You had some other problems with spelling and stuff too
code:

public class SimpleDotCom {
	int[] locationCells;
	int numOfHits = 0;
	
	

	public void setLocationCells(int[] locs) {
		locationCells = locs;
	}

	public String checkYourself(String stringGuess) {
		int guess = Integer.parseInt(stringGuess);
		String result = "miss";
		for (int cell : locationCells) {
			if (guess == cell) {
				result = "hit";
				numOfHits++;
				break;
			}
		}
		if (numOfHits == locationCells.length) {
			result = "kill";
		}
		System.out.println(result);
		return result;
	}

	public static void main(String[] args) {
		int numOfGuesses = 0;

		SimpleDotCom theDotCom = new SimpleDotCom();
		GameHelper helper = new GameHelper();

		int randomNum = (int) (Math.random() * 5);

		int[] locations = { randomNum, randomNum + 1, randomNum + 2 };
		theDotCom.setLocationCells(locations);
		boolean isAlive = true;

		while (isAlive == true) {
			String guess = helper.getUserInput("enter a number");
			String result = theDotCom.checkYourself(guess);
			numOfGuesses++;
			if (result.equals("kill")) {
				isAlive = false;
				System.out.println("You took " + numOfGuesses + " guesses");
			}
		}
	}

}

code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GameHelper {
		public String getUserInput(String prompt) {
			String inputLine = null;
			System.out.print(prompt + " ");
			try {
				BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
				inputLine = is.readLine();
				if (inputLine.length() == 0)
					return null;
			} catch (IOException e) {
				System.out.println("IOException: " + e);
			}
			return inputLine;
		}
	}

lamentable dustman
Apr 13, 2007

🏆🏆🏆

what application server are you running?

anything in the logs?

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Dunno but it easy to test. Increase java's default heap and max heap space. You can also increase the tomcat heap space in the config somewhere.

Where should also be 5 or 6 log files with different things in it.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Jmcrofts posted:

I'm really new to Java, and am learning it for a CS class. I installed the Java SDK on my home computer, and whenever I try to run my compiled code through the command prompt I get an error message that says
"Exception in thread "main" java.lang.NoClassDefFoundError"

I looked this up and tried some solutions about editing my CLASSPATH in system settings, but I still haven't been able to get it work. Any help would be much appreciated!

Going to need more info like what command are you running to compile? javac MyClass.java ? Are you using packages or any external libraries?

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Citanu541 posted:

Well, this is really embarassing but I can not find any logical answer to my problem in my textbook, nor google. I don't think I so much have a problem with

....

You have several problems with the code. The method call getContentPane() is in JApplet not Applet so instead of "extends Applet" it should be "extends JApplet"

JApplet is part of Swing, Applet is part of awt.


Next you have "JLabel greeting = new Label("Who are you?");" Notice that your types are mismatched. Either make them both JLable or Lable.

Last issue is that your constructor for the Font object is wrong. Look here for the correct constructors http://java.sun.com/javase/6/docs/api/java/awt/Font.html


About the main class problem, you don't need one when making an applet or JFrame or whatever. I don't use netbeans so I'm not sure how it is there but in Eclipse they give you the option of "Run as applet" instead of "Run as application."

Bellow is probally what you wanted your code to look like

code:
import java.applet.Applet;
import javax.swing.*;
import java.awt.*;


public class HelloTest extends JApplet {

    Container Con = getContentPane();
    JLabel greeting = new JLabel("Who are you?");
    Font headlineFont = new Font ("Helvetica",Font.BOLD,10);
    JTextField answer = new JTextField(10);
    JButton pressMe = new JButton("Press Me");
 
   public void init() {
    
       
        greeting.setFont(headlineFont);
        Con.add(greeting);
        Con.add(answer);
        Con.add(pressMe);
        Con.setLayout(new FlowLayout());
         
    }
}
It is also bad form to start the objects that you create with a capital letter so the object Con should be con.

lamentable dustman fucked around with this message at 23:00 on Jan 23, 2009

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Citanu541 posted:

Ah, thank you. I started debugging the obvious, but still ran into the no main class problem. I didn't realize all my syntax errors before posting that, but as I said, I didn't think the code was the problem. When every inch of the code is underlined in red, you start to feel the problem is else where.

I appreciate you going over my code, however, plugging it into my current project, it STILL errors out with the class error. I hate this crap, I don't know what I'm not picking up, this is my second attempt at Java, but this is the exact same problem that plagued and stopped me last time.

I launched NetBeans and had a look. When you create a project in NetBeans it makes a 'Main.java' class. You should probably just delete that. In the right click on the java file in the left pane (or hit shift+F6) you have the option to run the code. It launches just fine in the applet viewer.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

I'm having an issue with having javascript communicating with a java applet I'm writing. The poo poo was working fine 3 weeks ago and apparently I've changed some things to break. I got the code cut down to bellow to test.

code:
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextArea;


public class WaterTempGrid extends JApplet implements ActionListener{
	private static final long serialVersionUID = -6921859578015711379L;

	private JPanel map;
	private JPanel bottom;
	private JTextArea awaitingDataMessage;
	private ArrayList<Double> newCoords;
	private String message;
	private JButton but;
	private JButton test;
	
	public void init(){
		map = new JPanel();
		map.setLayout(new BorderLayout());
		
		bottom = new JPanel();
		bottom.setLayout(new BorderLayout());
		
		map.add(bottom, "South");
		but = new JButton("Update Coords");
		test = new JButton("Get Data");
		but.addActionListener(this);
		test.addActionListener(this);
		bottom.add(but,"West");
		bottom.add(test,"East");
		
		awaitingDataMessage = new JTextArea("waiting on data");
		map.add(awaitingDataMessage);
		
		message = "stop initlizing gently caress YOU";
		
		add(map);
	}
	
	public void newCoordinates(String lllat, String lllon, String urlat, String urlon){
		System.out.println( lllat + " " +  lllon + " | " + urlat + " " + urlon);
		
		newCoords = new ArrayList<Double>();
		newCoords.add(Double.parseDouble(lllat));
		newCoords.add(Double.parseDouble(lllon));
		newCoords.add(Double.parseDouble(urlat));
		newCoords.add(Double.parseDouble(urlon));
		

		message = newCoords.get(0) + " " +  newCoords.get(1) + " " +
		"| " + newCoords.get(2) + " " + newCoords.get(3);

		awaitingDataMessage.setText(message);
	}
	

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == but){
			awaitingDataMessage.setText("**************************");

		}else if(e.getSource() == test){
			System.out.println(message);
		}
	}
}
and the HTML

code:
<html>
	<head>
		<title>applet test</title>
		
		<script type="text/javascript">
			function updateCoords(){
				document.applet.newCoordinates(
					document.getElementById('lllat').value,
					document.getElementById('lllat').value,
					document.getElementById('lllat').value,
					document.getElementById('lllat').value
				);
			}
		</script>
	</head>
	<body>
		<form>
			<table>
				<tr><td></td><td></td>
					<td>
						<input type="text" id="trlat"/>
					</td>
					<td>
						<input type="text" id="trlon"/>
					</td>
				</tr>
					<td>
						<input type="text" id="lllat"/>
					</td>
					<td>
						<input type="text" id="lllon"/>
					</td>
					<td></td><td></td>
				</tr>
			</table>
		<input type="submit" value="test" onClick="updateCoords();"/>
		<br/>
		<applet
			name="applet"
			code="WaterTempGrid.class"
			width="600" height="600"
			archive="test.jar"
		>applet here i hope
		</applet>
	</body>
</html>
The Update Coords JButton just changes the JTextArea to just a bunch of ****************. The Get Data button is just to sysout what the string message is currently set to. The problem is with the javascript call to put the content of the text boxes into the applet. When I hit the button the whole applet reinitialize. I see the content of the JTextArea flash the correct content for a spit seconds before reverting to the initial value of "Waiting for data." If I hit the Get Data button the string message is "stop initlizing gently caress YOU" again.

In the full applet this updates a map which flashes for a split second before going back to the initial state like this example is showing.

Any ideas why this is happening? It was working fine before.

lamentable dustman
Apr 13, 2007

🏆🏆🏆

gently caress, just realized it is because I'm using a form tag and that is causing the whole page to reload. Took it out and it worked properly.....



I had to remake the page after my workstation was reloaded and I forgot to back up that part....




that loving poo poo cost me over 6 hours of time....

lamentable dustman
Apr 13, 2007

🏆🏆🏆

rjmccall posted:

Right, and "hop" before "hot", and "hot" before "hottentot". Something worth noting: compareTo's algorithm is based purely on the numeric values of characters, and the capital (English) letters happen to all be numerically less than the lowercase letters, so it will also put "Hot" before "abracadabra" but chances are good that your professor will be overjoyed if you can manage the if statements and certainly will not quibble over case-sensitivity.

compareToIgnoreCase() exists for that reason :)

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Sour Fish posted:

I have a null pointer exception and can't for the life of me figure out what is wrong, could someone please help?

Exception in thread "main" java.lang.NullPointerException
at quiz.answers(quiz.java:77)
at quiz.main(quiz.java:20)

http://pastebin.com/m23bd1221

Sysout the string 'line' or something. It is probally null or ""

Adbot
ADBOT LOVES YOU

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Logostomp posted:

I've got the input working. Here's the question.

Write a program to read a list of exam scores given as integer percentages in the range 0 to 100. Display the total number of grades and the number of grades in each letter-grade category as follows: 90 to 100 is an A, 80 to 89 is an B, 70 to 79 is an C, 60 to 69 is an D, 0 to 59 is an F. Use a negative score as a sentinel value to indicate the end of the input. (The negative value is only used to end the loop, so do not use it in the calculations.). For example, if the input is

98, 87, 86, 85, 78, 73, 72, 72, 70, 66, 63, 50, -1

the output would be:

Total number of grades = 14
Number of A's = 1
Number of B's = 4
Number of C's = 6
Number of D's = 2
Number of F's = 1

Not really seeing a question (or why this is even hard) here but make 5 stacks or something. Push the input into the correct stack when read in. Count the data structure for the output.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply