server_crash 64 Postaholic

First of all, that wont work..Plus the array would be indexed out of bounds if it did. What are you trying to do with the chars? If I knew, I could give you some better code:

JButton[] myButtons = new JButton[10];
char mine = '*';

for (int i=0; i<myButtons.length; i++)
{
       myButtons[i] = new JButton(" ");
       myButtons[i].addActionListener(this);
}

public void actionPerformed(ActionEvent ae)
{ 
              //choose three buttons you want as bombs
              if (ae.getSource() == myButtons[0])
             {
                     myButtons[0].setText(mine + "");
             }
             else if (ae.getSource() == myButtons[1])
             {
                      myButtons[1].setText(mine + "");
             }
              else if (ae.getSource() == myButtons[2])
              {
                      myButtons[2].setText(mine + "");
              }
}

I guess that's something like what your wanting...If it's not, give me some more information, and I can help some more.

server_crash 64 Postaholic

You can make executable JAR files, but I've always had trouble.

server_crash 64 Postaholic

This is zooming in...On my computer you can notice the refresh, but it's not bad. On other computers, it's EXTREMELY slow.

server_crash 64 Postaholic

This is the regular:

server_crash 64 Postaholic

I have an application that has a fractal already drawn, but I have three JSliders that allow the user to zoom in out, shift the x axis, and shift the y axis. I think it's plotting around 160,000 points, and the refresh is quit noticible. I was wondering if there was a way to make this faster....And if so, how?

I'll post a few pictures seperate.

server_crash 64 Postaholic

Yes, the URL Object should make that work.

Knight, is this JAR file an executable JAR file? If it is, could you show me how you did it? I tried once and never could get mine to work, even though everything was correct.

server_crash 64 Postaholic

If you can learn all you need to know to do that in three weeks, I will be impressed.

server_crash 64 Postaholic

I think the guy on the 2$ bill is the same as the guy on the 20$ bill(Thomas Jefferson)..

I bought my router and network card at best buy because they had a huge sign that said 20$ off ALL routers. Actually, it was only offered on a small variety of brands, but was never advertised it that way. After a long argument, we got the money off because they finally realized they were falsely advertising products.

server_crash 64 Postaholic

I would use if else statements since you only have a couple of tests to perform.
Using if else, you could also cut down on the code for testing uCase and lowercase characters:

if (letter.equals("T") || letter.equals("t"))
{
   //calculations and stuff
}
server_crash 64 Postaholic

This guy either has a crappy lawyer, or the judge was a victim of his spamming, because this is a long setence for something of this sort.

server_crash 64 Postaholic

Scanner.nextLine() is a String, NOT a char.

server_crash 64 Postaholic

I thought the Vector data structure was old, but I could be wrong. If there is a solution that could be done in ArrayList or Vector form, I would probably choose ArrayList.

server_crash 64 Postaholic

It's a good book though maybe a bit too advanced if you are just starting out.

Yeah, that's what I thought. I think I'll try it and stick around here to get some extra help if I run into anything difficult. It will be a while before I can start because I won the state championship in programming java for my high school, and now I'm having to prepare for the national championship. So, it will be a little bit!

server_crash 64 Postaholic

I just realized that it's a study guide for the Component developer exam. Maybe that will be a good thing, instead of bad.

server_crash 64 Postaholic

Thanks for the reply. I've got a new book now; it's called "Head first servlets and JSP"...it's by O'Reily and written in a different format than most books, and I'm curious as to how that will go. I've downloaded Tomcat, and the J2EE app server, but I wont be able to do anything until next week. Once, I get started, I'll probably have a bunch of questions...So stick around, and if you could tell me a good reference site to use.

Thank you for all your help.

server_crash 64 Postaholic

Why don't you take the number of characters the textfield is long, and how many characters the input is long, and formulate a center point out of that...Of course I would rather use setHorizontalAlignment();

server_crash 64 Postaholic

You can do it, but this is a Java forum...Not a JavaScript forum. If you were to do it in Java and show a little work, I would help you.

server_crash 64 Postaholic

You can download DOS versions such as Koffee I think it's called, but I don't see a point in that, and I doubt it would change much accessibility.

server_crash 64 Postaholic

That and some classes are protected by some device that won't let you decompile...Althought I think there is a way around them.

server_crash 64 Postaholic

The first part that DMR posted would probably be very sufficent security, and as long as you specify the number of connections and the allowed mac address', I would say that would be sufficent. I mean, I would do whateven DMR says in the second half of his security tutorial though.

server_crash 64 Postaholic

Decompile it. I believe you can download some decompilers but I can't recommend any, because I've never done this..

server_crash 64 Postaholic

Glad I could help and glad you got a solution.

server_crash 64 Postaholic

I think you would have to create a PixelGrabber which returns an array of ints made from the image. Once you have that, I think you could use this method to convert the ints to binary:

Integer.toBinaryString(int);

Here is an example of a Pixel Grabber that creates a screen shot and throws it into an array of ints.

private int[] capture() throws InterruptedException {
        dim = Toolkit.getDefaultToolkit().getScreenSize();
        Image tmp = robot.createScreenCapture(new Rectangle(dim.width,dim.height)).getScaledInstance(800,600,BufferedImage.SCALE_SMOOTH);
        int pix[] = new int[IMG_WIDTH*IMG_HEIGHT];
        PixelGrabber pg = new PixelGrabber(tmp,0,0,IMG_WIDTH,IMG_HEIGHT,pix,0,IMG_WIDTH);
        pg.grabPixels();
        return pix;
    }
server_crash 64 Postaholic

I was more thinking along these lines : (Quick kludge on the lastFactor > 0 test but ok) :

import java.io.*;
import java.util.*;
public class Factorizer
{
 public static void main(String[] args) throws Exception
 {
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  System.out.print("Number to factor --> ");
  int limit = Integer.parseInt(br.readLine());
  System.out.println("\n\n<-- Factors --> ");
//  ArrayList firstOperand = new ArrayList();
//  ArrayList secondOperand = new ArrayList();
  int lastFactor = -1;
  
  for (int i=1; i<=limit; i++)
  {
   if ((lastFactor > 0) && (i >= lastFactor)) {
	break;
   }
   {
   }
   for (int j=limit; j>=1; j--)
   {
	if (j *i == limit)
	{
	 lastFactor = j;
	 System.out.println(i+ " * " + j);
	 break;
	}
   }
  }
 }
}

That's pretty sweet, thanks for the good work and help.

server_crash 64 Postaholic

well neways i didnt get in cuz my math grades suck ass, i dont know i guess just becuz i didnt get all a's in b in preclac and geometry (which are skills i will really need in a high school comp sci course*sarcastic) that i can get into the course. The thing is i know a lot more about java and comps then ppl who got in and i could prob learn all the stuff on my own just that colleges want you to take a course. I am still gonna try and get in, i am gonna see if my teacher from last year will give me a reccommendation.

Yeah but thanks neways guys, i understand most of that code.

You should be able to get an override form that your parents sign for you to get in. I think it's crap you can't right now, because this class isn't hard.

server_crash 64 Postaholic

Or, you could simply check if the character is upper case.

public static void main()
	{
		String s = "This has Three Upper case characters";
		int caps = 0;
		
		for (int i=0; i<s.length(); i++)
		{
			if (Character.isUpperCase(s.charAt(i)))
				caps++;
		}
		
		System.out.println(caps);
		
	}

Even better, good job!

server_crash 64 Postaholic

Yes, you can use the DecimalFormat class to format it to however you want. like this:

double d = .099439823042348209482

DecimalFormat dec = new DecimalFormat(###.##); //two decimal places

System.out.println("d = " + dec.format(d));
server_crash 64 Postaholic

ok i want to make a program to show a teacher at my school so i can get into computer Ap which teaches you java(but they say u have to know stuff to get in it makes no sense i am in highschool).

I would learn it over the summer if your taking it next year. You SHOULD NOT have to know the stuff to get it there, because they teach it from ground up. Although, you will struggle if you don't. I'm in AP comp sci right now, and I learned java over the summer and actually know it better than my teacher(hope it doesn't sound like im bragging), but there is a few kids who didn't know anything about programming when starting out, and they are really struggling. If you learn the junk, it becomes a lay out class for you.

server_crash 64 Postaholic

yep, its the solution... :)

I agree, much better ;)

server_crash 64 Postaholic

First make sure that variable "things" is a double, and then with the .0092 value, you might have to procede it with a d, or f....ex: .0092d or .0092f, try both of those. If that doesn't work, then create an instance variable that is a double value containing .0092 like this: double value = .0092 and then substitute value in where you have .0092, and that should work. If any of that doesn't work post a little more code, and I will see what I can do.

server_crash 64 Postaholic

Also, how would you do this? would it be something like this:

for (int i=0; i<text.length(); i++)
{
   int charPoint = (char)text.charAt(i);
  if (charPoint >= 65 && charPoint <= 90)
  {
     //its ucase
  }
}

After writing that it doesn't seem like a bad solution at all.

server_crash 64 Postaholic

well your code is a bit slower, because in every character your program compare with the whole alphabet, but mine only with two number,
so in a string with 5 character,
yours, 5*26 comparison,
mine, only 5*2

accually when string is very long, both algorithm's time gets closer... both algorithm's speed is O(n) where n is the length of the string.

I compare only with uppercase character just as you do. Not meaning to be rude here, but how do you get 5 *2? I mean, don't you have to compare each character with all the ASCII codes pertaining to u case char's?

server_crash 64 Postaholic

}
}

The problem is that it won't allow me to use the data type "char" for a switch statement

switch( letter ) {
case A:
newText = newText + letter;
break;
case B:
... and so on

And one last question, is there a better way to check the character than using the long switch statement?

Thanks in advance!
EvilObsidian :twisted:

switch statement does check char data types. You MUST denote them with single quotes. ex: case 'A' or case 'B'

Also, there really is no point in using the switch statement because you can simply use a loop for all of it.

you can loop through using char's just like you can loop through using ints

for (int i=0; i<text.length(); i++)
 {
   for(char c='A'; c<'Z'; c++)
  {
     if (text.charAt(i) == c)
    {
       //it's uppercase
    }
  }
 }

that should help out a little, but the best thing is do what jwenting said and read some of the methods in the API.

Sorry if my english was bad or not understandable, but I just woke up.

;)

server_crash 64 Postaholic

Also, maybe check that the 1000 is a double. Although I don't think that would matter because precision goes up not down.

server_crash 64 Postaholic

Please post some code, if you are using doubles it should show up as a double. Other than that, you can use the DecimalFormat class to format decimals to a specific decimal place.

server_crash 64 Postaholic

you can look at the values of the character, (for ASCII code table)
for example value of 'A' is 65 and value of 'Z' is 90
so you can check every character in your string, then check if characters are between 65 and 90, if true then increase counter, if false do nothing.

Exactly what I did, except I made it much easier.

server_crash 64 Postaholic

I'd expect a regular expression that extracts all uppercase letters into a new String, followed by simply taking the length of that String, to be the shortest code.
The regular expression could get messy though, and not being an expert at them I'm not going to try writing one :)

You could use the same thing I gave and still be able to easily extract them and put the UCase characters in a new string.

server_crash 64 Postaholic

What you would need to do (from the top of my head) is to see if the lefthand factor (i in your example) matches the previous righthand factor (j in your ex.).

As soon as i matches the j, we are finding the mirrors of the previously found factors and can stop.

You could use a break from the loops when j == i. (Not print this result as it is already a duplicate).

Have fun.

I tried that but I was having problems. Here is what I came up with: I stored the numbers in an ArrayList since I wouldn't know the exact size at runtime, and when printing them out, I only printed out the first half of the numbers. It works, but it's a HUGE waste.

import java.io.*;
import java.util.*;

public class Factorizer
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("Number to factor --> ");
		int limit = Integer.parseInt(br.readLine());
		System.out.println("");
		System.out.print("Factors --> ");
		ArrayList firstOperands = new ArrayList();
		ArrayList secondOperands = new ArrayList();

		for (int i=1; i<=limit; i++)
		{
			for (int j=limit; j>=1; j--)
			{
				if (j *i == limit)
				{
					firstOperands.add(i);
					secondOperands.add(j);
				}
			}
		}
		int stop = firstOperands.size()/2;

		for (int i=0; i<stop; i++)
		{
			System.out.println("\n" + firstOperands.get(i) + " * " + secondOperands.get(i));
		}
	}
}
server_crash 64 Postaholic

Here's a real example of it:

class UCase
{
  public static void main(String[] args)
  {
	String s = "This has Three Upper case characters";
	int upperCaseCount = 0;

	for (int i=0; i<s.length(); i++)
	{
    		 for(char c='A'; c<='Z'; c++)
    		{
        		   if (s.charAt(i) == c)
          		   {
                    		upperCaseCount++;
          		   }		
     		}
	}
	System.out.println(upperCaseCount + "");
  }
}
server_crash 64 Postaholic

Maybe something like this would work, but I'm not sure:

String text = textArea.getText();
int upperCaseCount = 0;

for (int i=0; i<text.length(); i++)
{
     for(char c='A'; c<='Z'; c++)
    {
           if (text.charAt(i) == c)
          {
                    upperCaseCount++;
          }
     }
}
server_crash 64 Postaholic

I would like to know if there is an IDE like Visual Studio.NET, where it would allow drag and drop components instead of doing it programatically.

server_crash 64 Postaholic

I made this simple program that prints out all the factors of a given number. The only problem is that it prints out the numbers in different order...For example:

factors of 12:

1*12
2*6
3*4

but this is what my program prints out:

1*12
2*6
3*4
4*3
6*2
12*1


It's taking the numbers and just switching the order, and I was wondering if anyone knew how I could get rid of that.

import java.io.*;
import java.util.*;

public class Factorizer
{
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		System.out.print("Number to factor --> ");
		int limit = Integer.parseInt(br.readLine());
		System.out.println("\n\n<-- Factors --> ");
		ArrayList firstOperand = new ArrayList();
		ArrayList secondOperand = new ArrayList();
		
		for (int i=1; i<=limit; i++)
		{
			for (int j=limit; j>=1; j--)
			{
				if (j *i == limit)
				{
					System.out.println(i+ " * " + j);
				}
			}
		}
	}
}
server_crash 64 Postaholic

server crash, thanks. the website's for science class (u probably figured that out). My teacher's paying for it ;) Do you have any suggestions

The only thing I see that needs to be changed, is the JOptionPanes. They pop up when you browse to that page. I think the user should have the choice of taking it, although that is the page for taking it! I believe if you got rid of the JOptionPanes it would look much better.

server_crash 64 Postaholic

I don't know how you could continue most programs without user input.

server_crash 64 Postaholic

server_crash, that is my website - do u like it?

Yes, looks very nice.

server_crash 64 Postaholic

Is that your website?

server_crash 64 Postaholic

JEdit is my all time favorite..I would prefer it over any IDE, and day. I personally like using the command line to compile and run my junk, but that's just my personal preference.

server_crash 64 Postaholic

It takes a running count of all stats but I only want stats per player...how do I do that?

Hmm...You would have to read one line at a time, and once finished with the calculations, you would have to reset the variables.

server_crash 64 Postaholic

You could use the firstIndexOf() method to return the occurence of the first ","...That method will return an int value, and once you have that, then you can create a substring with just the name, and that will also make it to were you can create a substring of everything to the right, and use the code I gave you in the first post.

String input = file.readLine();
int point = input.firstIndexOf(",");

String name = input.substring(0,point);
String records = input.substring(point,input.length());

That's something what it will look like.

server_crash 64 Postaholic

yes, but is there any other way? or is there any chance of data lose in this way?

I thought that was a very good solution myself, but if you want another way, you could throw it into a string and parse it.