server_crash 64 Postaholic

you might want to play around with the DecimalFormat class some, if you want your numbers to have commas after every three numbers and an % before or after your numbers.

server_crash 64 Postaholic

The % is a sign for modular division in java.

server_crash 64 Postaholic

Thank you guys very much, you were both a big help...

server_crash 64 Postaholic

I started learning about it a while back, but each time I learn something about it, I find myself going back to 1.4. I thought the generics were pretty cool. At my school, we use 1.4, and half of my programs won't work on their machines, so I have to wind up converting it back to 1.4. It just seems to me that everyone is sticking to 1.4.

server_crash 64 Postaholic

I'm curious as to how many of you routinely use jdk 1.5 tigers added features, methods, api's and whatever. Or, do you just stick to 1.4?

server_crash 64 Postaholic
drawOval(int x, int y, int width, int height)

Just use threads to increment the x and y value position at certain intervals.

server_crash 64 Postaholic

I don't know.lol

server_crash 64 Postaholic

This is what I'm trying right now, but it's not working..

public File PathStart()
   {
	for (char dirs='A'; dirs >= 'Z'; dirs++)
	{
		File path = new File(dirs + "://");
			if (path.isDirectory())
			{
				startingPath = path;
				System.out.println(startingPath.toString());
			}
	}
	return startingPath;
   }
server_crash 64 Postaholic

Ok, I found out how to search. Now the only thing I need to know is, how do you find out what the users root directory is?

server_crash 64 Postaholic

I know how to find a directory if I know the full path name of the directory I'm searching for..But, let's say I only know the directory name, and not the full path name..How can I find that directory on a users system? Is there some recursive function or looping structure to achieve this?

server_crash 64 Postaholic

If you use an ArraList like jwenting suggested, you can use:

Collections.sort(ArrayList);

You might could use that on a vector, but I doubt it. Never tried.

Also, isn't there some way to use the comparator interface to sort?

server_crash 64 Postaholic

Im curious, why do you create an instance of the class in each method?

CurrencyConv2 a1 = new CurrencyConv2();
server_crash 64 Postaholic

How come you prompt the user for amount in pennies?

server_crash 64 Postaholic

Thanks server_crash,


I have read this discussion and it is very helpful. But I think this discussion is not similar to my issue. My issue is that the sound can not be played, and the discussion is dealing with how to solve delay issue (the sound can be played in this discussion). I am wondering your comments.


regards,
George

I knew it was a little different, but I was hoping you could use their methods of playing sound in your app.

server_crash 64 Postaholic

Check out this:

http://www.javakb.com/Uwe/Forum.aspx/java-programmer/14139/re-playing-sound-in-J2ME

I don't know if this will help or not. I haven't had any experience working with j2me either.

server_crash 64 Postaholic

If you simply want to play a .wav file, there are much simplier ways of doing this. That is of course, if your wanting to do this on a pc....

server_crash 64 Postaholic

You already have a bunch of values that represent the currency amounts. The best thing to do, would be store these in an array, and then start calculating them through a loop. I know this is possible, because I have AP Comp Sci, and had this same project except ours had to include a gui, and some other advanced things.

server_crash 64 Postaholic

In your main method, you call some method, but for some reason that method also creates another instance of the class your already in and continues from there. I think you should put this all under the main method, and maybe it won't be so confusing for you.

server_crash 64 Postaholic
public static void main(String[] args) {
	
	try {
		Player player = [B]Manager.createPlayer"http://localhost/sample.wav");[/B]
		player.start();
	} catch (MediaException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}
}

could the problem be leaving out a parenthesis?

public static void main(String[] args) {
	
	try {
		Player player = Manager.createPlayer("http://localhost/sample.wav");
		player.start();
	} catch (MediaException e) {
		e.printStackTrace();
	} catch (IOException e) {
		e.printStackTrace();
	}
}
server_crash 64 Postaholic

It can be used as a recursive function. I guess that's what he was talking about...Maybe...?

server_crash 64 Postaholic
int a = 5;
int b = 7;

if (a > b)
{
   b += 1;
}
else 
{
  b -= 1;
}

Is this what your talking about?

server_crash 64 Postaholic

Maybe if I have time I'll look at it, but right now I don't.

server_crash 64 Postaholic

You really need to work on how it's written.

server_crash 64 Postaholic

I was afraid they would change it every day...Since I was just going to do this for fun, I guess I won't worry about it. As you said, it's probably the equivilent of stealing..

Thanks for all your help.

server_crash 64 Postaholic

what about reading the source code of the web site using a url connection..I think you could get the info you want like that, but it would probably be very hard..What do you think?

server_crash 64 Postaholic

it's not static.

It MUST have the exact signature:

public static void main(String[] args) //you can call the string array whatever
{
}

server_crash 64 Postaholic

you forgot the main method:

public static void main(String[] args)
{
}

server_crash 64 Postaholic

Thank very much. That was EXTREMELY helpful. I checked out this one site, and it turns out you do have to pay for it.

server_crash 64 Postaholic

Is it possible to update your programs information from other websites? I mean if you have like a stock program or currency program, the data changes everyday. So can you recieve updates from websites, and change this info? If so could you point me to a site that explains how, or some kind of api that can achieve this?

server_crash 64 Postaholic

Thanks Christian, very helpful relpy!

server_crash 64 Postaholic

Here is my classpath: Note: Your's will probably be different.

.;%classpath%.;.;C\Program Files\Java\jdk1.5.0\lib\tools.jar

classpath should point to the tools.jar file


Here is what my path variable looks like:

C:\Program Files\Java\jdk1.5.0\bin


it just points to the bin folder.


Note: to set your environment variable, right click on the my computer icon, then select advanced, then at the bottom there will be something that says environment variables.

server_crash 64 Postaholic

That's the problem with your purely linear way of doing things.
Create a parsetree and recursively process it from the inside out.

Yep, I knew the way I was doing would only allow two operands, but that's really all I could think of. I'll try the parsetree as you suggested..Sounds like something trivial, so I might have to come back for help!

server_crash 64 Postaholic

Does anyone know how you could process an equation, or even get an equation with more than two operands? Right now, in my calculator, I can only have two operands, and I want to have more.

Right here is what I have:

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Calculator extends JFrame implements ActionListener
{
	JButton[] btnNums;
	JButton btnBack;
	JButton btnClear;
	JButton btnCalculate;
	String[] strNames;
	String strOperand1;
	String strOperand2;
	Boolean wasClicked;
	String answer;
	double dd;

	final String STR_MULTIPLY = "MULTIPLY";
	final String STR_DIVIDE = "DIVIDE";
	final String STR_ADD = "ADD";
	final String STR_SUBTRACT = "SUBTRACT";

	String whichOperator;
	
	
	JTextField txtDisplay;
	
	public Calculator()
	{
		Container content = getContentPane();
		setSize(210,250);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		
		/*  construct a JPanel and the textfield that 
		 *  will show the inputed values and outputed 
		 *  results
		 */
		JPanel jpDisplay = new JPanel();
		jpDisplay.setLayout(new BorderLayout());
		txtDisplay = new JTextField(15);
		txtDisplay.setHorizontalAlignment(JTextField.RIGHT);
		jpDisplay.add(txtDisplay);
		
		/*  contstruct a JPanel that will contain a back
		 *  button and a clear button.
		 */
		JPanel jpRow2 = new JPanel();
		btnBack = new JButton("Backspace");
		btnBack.addActionListener(this);
		btnClear = new JButton("Clear");
		btnClear.addActionListener(this);
		btnClear.addActionListener(this);
		jpRow2.add(btnBack);
		jpRow2.add(btnClear);
		
		/*  construct a string array with all the names of the
		 *  buttons, then in a for loop create the new buttons
		 *  and add their name and an actionListener to them.
		 */
		String[] strNames = {"7","8", "9","/", "4", "5", "6","*", "1",
					   "2", "3","+", "0", "+/-", ".", "-"};
		btnNums = new JButton[16];
		JPanel jpButtons = new JPanel();
		jpButtons.setLayout(new GridLayout(4,4));
		
		  for (int i = 0; i < 16; i++)
		  {
			  btnNums[i] = new JButton(strNames[i]); …
server_crash 64 Postaholic

hmm. If I remember right, java doesn't support those file extensions. I think it supports weird ones like au, aiff, and stuff like that. But, I do think it supports .wav files.

Maybe someone will correct me if I'm wrong

server_crash 64 Postaholic

Thank you guys. Both replys were helpful. I just wanted to know what other people that's been around it, thought about it. So thank you.

server_crash 64 Postaholic

Thanks server_crash,


I am wondering how you debug your applications since you do not use log utility.


regards,
George

lol I never really did. Sometimes I used System.out.println()'s, and sometimes I just knew what to do from the error. I've never really created anything so big, that it require a lot of debugging. But, my text editor I'm working on right now is in need of it. So I might have to put it to some use.

server_crash 64 Postaholic

I had no clue you could do that in java. I looked at some of the logging api's, and it looked very useful.

server_crash 64 Postaholic

I think I might have to try it out. I'm stuck on JEdit, so I guess it will be good to try something new.

server_crash 64 Postaholic

remember using the substring function that it also starts at index 0. So if you wanting to get the first character, I think you would do this:

menu_opt.substring(0,1);

and the second one :

menu_opt.substring(1,2);

As for the numeric data, I think it depends on your jdk version. In some you may be able to do this:

indata.readDouble();

some not.

You can always take the inputed string and convert it to a Double or int

int x = Integer.parseInt(string);

or

double d = Double.doubleValue(String);

server_crash 64 Postaholic


PS: Don't be bothered about what narue said, some people simple refuse to help others out but when they need help they expect others to help them out.

I've seen it many times on here. You would think that some people would realize there is no need for a forum if you simply tell people to look on google. I guess it's just they don't know how to do it. The point of a forum is to help people.

server_crash 64 Postaholic

I don't recall anything like that. I would either leave them, or remove them manually.

server_crash 64 Postaholic

It does start at element or index 0. You only have one element in your array or [0]. You have a for loop trying to shove mulltiple things in an array with only one element. I'm not sure I understand what your wanting to do with the menu_Opt array.

server_crash 64 Postaholic

never mind, I got it.

public void actionPerformed(ActionEvent ae)
	{
		for (int i =0; i < 16; i++)
		{
			if (ae.getSource() == btnNums[i])
			{
				txtDisplay.setText(txtDisplay.getText() + btnNums[i].getLabel());
			}
		}
		
	}
server_crash 64 Postaholic

instead of this:

public static void main(String[] args)


do this:

public static void main(String[] args) throws IOException


then it will compile

server_crash 64 Postaholic

What's the scanf function? I'm not familar with C++..

server_crash 64 Postaholic

I have this simple calculator I just started on, and I'm having just a few problems. First of all, I don't know how to append text to a textfield. Maybe I would have to create a string buffere or something. Then, when the user clicks one of the buttons, the compiler goes crazy, and nothing is displayed.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Calculator extends JFrame implements ActionListener
{
	JButton[] btnNums;
	JButton btnBack;
	JButton btnClear;
	JButton btnCalculate;
	String[] strNames;
	
	JTextField txtDisplay;
	
	public Calculator()
	{
		Container content = getContentPane();
		setSize(210,250);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		/*  construct a JPanel and the textfield that 
		 *  will show the inputed values and outputed 
		 *  results
		 */
		JPanel jpDisplay = new JPanel();
		jpDisplay.setLayout(new BorderLayout());
		txtDisplay = new JTextField(15);
		txtDisplay.setHorizontalAlignment(JTextField.RIGHT);
		jpDisplay.add(txtDisplay);
		
		/*  contstruct a JPanel that will contain a back
		 *  button and a clear button.
		 */
		JPanel jpRow2 = new JPanel();
		btnBack = new JButton("Backspace");
		btnClear = new JButton("Clear");
		btnClear.addActionListener(this);
		jpRow2.add(btnBack);
		jpRow2.add(btnClear);
		
		/*  construct a string array with all the names of the
		 *  buttons, then in a for loop create the new buttons
		 *  and add their name and an actionListener to them.
		 */
		String[] strNames = {"7","8", "9","/", "4", "5", "6","*", "1", "2", "3","+", "0", "+/-", ".", "-"};
		btnNums = new JButton[16];
		JPanel jpButtons = new JPanel();
		jpButtons.setLayout(new GridLayout(4,4));
		
		  for (int i = 0; i < 16; i++)
		  {
			  btnNums[i] = new JButton(strNames[i]);
			  btnNums[i].addActionListener(this);
			  jpButtons.add(btnNums[i]);
		  }
		  
		  /*  construct the final JPanel and add a 
		   *  calculate button to it.
		   */
		  JPanel jpLastRow = …
server_crash 64 Postaholic

Yeah, it's the same way here. I was hoping to have a teacher that was a guru at java so I could learn a lot. But, I guess it's not all his fault.

server_crash 64 Postaholic

What about this? It's probably not exactly what you want, but it will get you on your way.

import java.io.*;

public class HexToByteConverter{

 public static void main(String[] args) throws IOException{

  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  String line = null;
  while (!(line = br.readLine()).equals("")){
   for (int i = 0,j = line.length(); i < j; i++){

System.out.print(Integer.toBinaryString(Character.digit(line.charAt(i),16)));
   }
   System.out.println();
  }
 }
}
server_crash 64 Postaholic

Note: Area you using a DocumentRenderer for the printing of the JTextPane?

server_crash 64 Postaholic

http://forum.java.sun.com/thread.jspa?threadID=587153
It's something about the offset is different.


I personally have never tryed to print in java. I've been working on this text editor and that is my next job, which I will hate!

I did search the java forums and found some people with similar problems, but unfortunately, no one posted with answers on any of the questions.

I found a link that looked like it my do you some good, but it might not. It looked like they were using something to count the pages and then using a book object declaring what was to be printed, and it looked like you could specify the number of pages to be printed. But I think what you wanted was the user selection.

http://www.javaworld.com/javaworld/jw-06-1999/jw-06-step.html


If it's the user selection you want printed, how are you getting the selected text and appending it to a printjob?
Does the print dialog even have an option for printing the selected text? I didn't see one on some of examples they had. This makes me wonder if you would have to print the selection without a dialog.


Note: I really don't know much about the printing, but hopefully some of the suggestions will help.