Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Jishnu was the one who asked a few days ago. This guy is definitely just reposting questions at this point and hopefully on the fast track to a ban.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Many of the javax packages are included in the JDK distribution. A few of them, however, are separate downloads on the Sun site. The media framework is one of them. You can get it here: http://java.sun.com/products/java-media/jmf/

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Certainly... and you have even been told how to go about it right here in your other thread: http://www.daniweb.com/forums/thread97476.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yep, as masijade pointed out, if the compiler sees that you have an execution path that could lead to a variable being used before an assignment has been made (as in your "if" clause above), it will warn you of that. If you assign a default value when you declare the variable, you'll be fine. Even if you want it to remain null you will need to declare that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The user need to press three times to give the three points of the triangle....or am i missing something?

Correct. Your mouse listener class can just keep a counter of the clicks as it collects the points. When you have collected the number of points needed for the polygon (any polygon would work, not just a triangle), you can draw the poly and reset the listener counter.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You'll just need to add a mouse listener to the frame, from which you can get the x and y coords clicked, and create your GeneralPath or Polygon (http://java.sun.com/javase/6/docs/api/java/awt/Polygon.html) from the clicked points.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I guess your cynicism/sarcasm detector is failing you today, as my comment was meant in that vein and I agree with your rant.

That was kind of the point...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Diversity != Politically Correct

Diversity == Good

Politically Correct == *&^$##%&**^&%$

Sounds like you have not experienced corporate "Diversity Training". It crams extreme PC down your throat to the degree that you'll be lucky to be able to communicate anything to anyone without worrying about possibly offending someone else :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, I tried a small test program doing exactly the same thing with the above statement (with ip field defined as Text in mysql) and it worked just fine. Not sure where the breakdown is occurring for you, but as you mention, using older versions of php and mysql may be the case.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If your group is too Politically Correct, yes, it can vapor lock and get nothing done.

Ok, back to Diversity Training for you!
Guards, take this dissenter!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

ok.. yah.. i need to reach each digit .. not read the number as a whole so i can count the number to times that the number appeared... can someone give me the code hehe...

They already told you how to do it. Get the number as a String and examine each character. In fact, you are reading the number as a String to begin with, so why bother converting it to an int if you just want to convert it back to a String? Read the API for String, there are plenty of very clear methods for looking at smaller pieces of that String.

Write some code for it and if you still can't get it to work, post it. Giving you the code won't help you learn a thing.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

you migh wanna do a binary search and keep some parameters until

Keep in mind though, binary search will only be of use with ordered data. At this point, since the poster is not even sure how to find the nearest match, a binary search is probably only going to add unnecessary complication where he has no need of it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, the core of it was that they were screwed on DVD residuals (those being a percentage) and do not want to get further screwed as the studios and producers develop new revenue streams.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Free thinking americans! Dear God. I take back my previous statement. More coverage of the writers strike and less coverage of Bangladesh. Because media coverage is totally going to make the strike end faster. Its not just adding more fuel to the fire at all...

Yes, see the coverage of the strike keeps them focused on the lack of preferred fodder and makes them crave it all the more!

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Are you aware that, before the telephone, "hello" was a Norse war cry and sort of a mild swear word?

Can't seem to find any mention of this elsewhere. Are you making things up again? :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are all forgetting the most important reason that the strike must end soon. If the masses are not pacified with the mindless drivel on the shiny screen, they may actually begin to look around them and take an active interest in things the church and state prefer they ignore. :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I agree with you. Why the scientists are not trying to solve the basic problem of food , like getting it from air , then we would not require money at all.

I'm not sure you are getting enough air yourself....

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's what I see this time of year.

So what. Christ has been co-opted for pushing things onto people since inception. Nothing new to see here really.

That and the Walton kids getting richer.

And it makes you angry that they are making a lot of money? Well, so are a lot of others. You resent all of them as well? Get over it.

Save America export Wal Mart.

What are you saving America from exactly? Capitalism? Cheap socks and radios? Peoples' desires to buy cheap crap will survive the the extinction of a single large retailer.

scru commented: I think you need a hug too +0
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I ended up using this ...

fout = new FileOutputStream ("c:\\afmd.tmp");
new PrintStream(fout).println ("xxBL," + textBL.getText());
new PrintStream(fout).println ("xxBA," + textBA.getText());

You do not need to create a new PrintStream for each call.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

With comparison operators and subtraction.

This would normally be done through a query to a database though, not in your Java code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

anyone?

Anyone what?
If you're talking about your "driver class" question, just write your own if you really want to (though I can't see why for the life of me). There is only one constructor and one method of any external consequence.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

All he needed to get reelected was the uninformed, missinformed (Fox News does a perfect job), and relegious fanatics.

All of which we have in abundance.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you'd use IE7 on Vista you wouldn't have to worry about those annoying popups.

Probably because they are broke in Vista - like everything else :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

http://java.sun.com/javase/6/docs/api/java/util/Scanner.html can be used for scanning and processing many kinds of text input from a variety of sources.

http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html allows for buffered reading from an input stream and has a readLine() method that will read a single line from a stream (file in your case).

String.split() http://java.sun.com/javase/6/docs/api/java/lang/String.html#split(java.lang.String) splits a string by the supplied expression and returns the pieces as an array of strings.

The following code fragment opens a BufferedReader against a text file and reads each line.

try {
            BufferedReader reader = new BufferedReader(new FileReader("file.txt"));
            
            String line = null;
            while ((line = reader.readLine()) != null){
                System.out.println(line);
            }
        } catch (Exception e){
            e.printStackTrace();
        }

With that as a starting point, see if you can get the elements into your array and post back if you run into problems.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use Scanner or a BufferedReader and String.split().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

public static String Readfile(String file)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Make the method static.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And what is your question?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Very close. Move the BufferedReader outside of your loop and put a try-catch block around the readLine() and parseInt() section.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the code that you do have and we can take a look at it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ummmm okay, I'm going to state my problem again, cause My problem still isn't fixed...... Alright, so I thought I was doing everything correct, and it looks like it should be coming But, for some reason, the points that are made are not appearing inside the triangle, instead they make a line along the edge of the triangle! I put my problem in Italics, it would be great if someone could tell me why this is happening!

Well, for one thing, you were not calculating the inner point correctly. The code that I reworked a bit for you does give a random inside point, without some of the hassles you were having with the data structures. Since I already took the time to get that working for you, I'm not much inclined to fiddle any more with it. By the way - you're welcome.

edit:

Oh, and tell me anything that might make it better, but simple

Which I did...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

File.mkdir() or File.mkdirs() is what you need to use.

edit: s.o.s. beat me to the post :) The only issue there is that it is not using exception handling to create the directory. Personally, I think that is the better way to do it, but his assignment requires it to be done by handling the exception.

Just catch the exception from the FileOutputStream, create the directory, and then try to create the stream again. Outside of that assignment though, I'd say use the way that s.o.s. posted above. It's much cleaner to check for the existence of the directory prior to trying to use it. The catch block approach breaks the flow of your code because its not reentrant from where the exception occurred.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

They can be useful as small data structures or "helper" objects that only have applicability in the context of their enclosing class. S.O.S. posted an example of such a case above. The 'Entry' is really only useful with the HashMap. It could be published as a full public class, but if it is not used by other classes then it just clutters the API. As a static inner class of HashMap, its usage is clearly scoped.

Jishnu commented: This was helpful. +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could just iterate the available roots from File.listRoots() and check exists() to find it for them, since you know the file name you are looking for.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are a ton of Java tutorials to be found at http://java.sun.com/docs/books/tutorial/ and through Google. A good free online book can be found here: http://www.faqs.org/docs/think_java/TIJ3_c.htm

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

According to the code that you posted, it was due in September of last year and it describes a Box. I don't think you'll get much credit for this assignment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So have you come up with an answer to this homework question yet? When do you think they could be useful?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try this as a starting point

import java.awt.geom.Rectangle2D;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import java.util.ArrayList;


public class Fractal extends JPanel
{
    private int[] triangle01 = {150, 300, 150};
    private int[] triangle02 = {300, 300, 150};

    Random gen = new Random();
    ArrayList<Point> dots = new ArrayList<Point>();  //holds all the points that are made in this program

    Polygon triangle = new Polygon(triangle01, triangle02, triangle01.length);

	public Fractal ()
	{
    	addKeyListener (new DirectionListener());
    	setFocusable(true);
    	setBackground (Color.black);
    	setPreferredSize (new Dimension (1000,1000));
	}


    public static void main(String[] args)
    {
        JFrame frame = new JFrame ("Fractal");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        Fractal panel = new Fractal();

        frame.getContentPane().add(panel);
        frame.pack();
        frame.setVisible(true);
    }
    
    public void paintComponent (Graphics page)
    {
        Graphics2D g2d = (Graphics2D)page;
        g2d.setBackground(Color.black);
        g2d.clearRect(0,0,getWidth(), getHeight());
        g2d.setColor(Color.red);
        for (Point p : dots){
            g2d.fillRect(p.x,p.y,1,1);
        }
        g2d.setColor(Color.white);
        g2d.drawPolygon(triangle);
    }

    
    public void createFractalPoint(Polygon poly){
        Point inner = getInnerPoint(poly);
        Point vertex = getVertex(poly);
        dots.add( getMidpoint(inner, vertex) );
    }

    public Point getInnerPoint(Polygon poly){
        Rectangle2D bounds = poly.getBounds2D();
        Point p;
        do {
            p = new Point((int)(bounds.getMinX() + gen.nextFloat()*bounds.getWidth()),(int)(bounds.getMinY() + gen.nextFloat()*bounds.getHeight()));
        } while (!poly.contains(p));
        return p;
    }
    
    public Point getVertex(Polygon poly){
        int index = gen.nextInt(poly.npoints);
        return new Point(poly.xpoints[index], poly.ypoints[index]);
    }
    
    public Point getMidpoint(Point p1, Point p2) {
        return new Point((int)((p1.x+p2.x)/2), (int)((p1.y+p2.y)/2));
    }


    private class DirectionListener implements KeyListener
    {
        public void keyPressed (KeyEvent event)
        {
            createFractalPoint(triangle);
            repaint();
        }
        public void keyTyped (KeyEvent event) {}
        public void keyReleased (KeyEvent event) {}
    }
}

This still gives you some room to grow on. You are just using the midpoint, but the algorithm calls for a random distance between …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Wow... this thread is still going strong? Cool.
Is anyone else standing up for God, as I did?

What? This thread is about God???
:P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It depends on what you expect from the system. If you go the most simplistic route, you assume that the machine has a limitless supply of change in all denominations. In that case, you only need to keep the total amount entered. To make change you just use division and mod functions to return the most efficient change combination.

Obviously, that isn't very realistic though. Real machines have a finite pool of coins of each denomination, in which case you would need separate totals for each, perhaps in a HashMap, in addition to the amount the user had entered. The returnChange() method would attempt to return the most efficient combination of denominations with division and mod, but if those coins were not available it would need to split down to the next combination of coins available to return the required amount.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Which layout manager are you using?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

When I said "The holes in any wall can be plugged by fear." I was implying summary execution.

While I agree that there should be consequences, I don't think you really want to live in a society where the answer to any infraction is immediate execution. That sword may cut in ways you would not care for.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You've asked, but I believe you've written me to bury me rather than to hear me out. I will make an attempt to clarify, but wonder if you really want to hear it.
<snip>

On the contrary, that was a reasoned and well-written post worth reading. Had you posted that earlier, in lieu of the snide condescension, you would not have faced such hostility.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The holes in any wall can be plugged by fear.

Yes, razor wire and machine gun nests would make most think twice ;)

Seriously though, the complete lack of consequences currently does nothing to discourage them. They know that if they are caught, most likely they will merely be hauled back. What incentive is there to respect the law?

If someone repeatedly strolled into my house whenever he felt like it and all that I did when I discovered him was to escort him to the door and politely ask him to not do it again, do you think he's going to take my request very seriously?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That tatt however is not. :(

Doh! Too bad. It's a really nice piece of work.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

From my personal perspective, I think I would be happier if we were able to fuel our life styles in a cleaner way than we have done in the past. We might also be better off economically than if we continue to fund people (through petro-dollars) that are bent on our destruction.

I would agree with that. Even if it were sustainable and "global warming" a baseless concern, our current energy usage and subsequent pollution is making a mess of the environment. As an outdoors enthusiast, I'd gladly welcome cleaner rivers, air, forests, etc. Hopefully innovations in energy production will one day allow us to start reversing some of the damage that's been done. I like to believe that most people don't want to pollute the hell out of everything. There just aren't satisfactory alternatives available on a large enough scale yet. Given that in the early days of oil refining, kerosene was the desired product and everything else was just discarded as waste (often into rivers), I have reasonable faith that we will find more acceptable ways to meet our energy needs in time.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, you give him more credit than is due. He isn't even asking a question - just reposting a piece of the original post. He seems to have done that in a lot of other threads as well. He just reposts a random piece of what someone else posted, adding no useful information whatsoever.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

replaceAll(" ","")

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Apparently you insult what you can't understand.

Well, you had not even bothered to introduce any content to the discussion at all. You didn't even refute any specific claim. You just jumped in and told everyone they didn't know what they were talking about. Even with that longer previous post, you have said very little to support or explain any thoughts you have on the matter. If your only contribution is "ur all dum", you can't really expect anyone to place much value on your comment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This link may be useful as well for JDBC with SQL Server:
http://support.microsoft.com/kb/313100