Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's actually relative to whatever your projects "current working directory" is, which I am not sure what that is by default in Eclipse. You could try placing a copy of that file in your project's root directory (not the src directory). Or you could just specify the full path to the file.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Once you get that part working, you have a bit of work to do on the logic of your loops to populate the puzzle array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your current code is passing your System.in scanner to your Sudoku constructor. You need to create a new scanner for your input file and that is the one you want to pass to your constructor.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

After 61 posts here, you should be well aware that "chat-speak" or "IM-speak" is discouraged in the forum rules. Are you really too lazy to type out all of the letters and use punctuation where appropriate? Should anyone else spend their time to help someone who doesn't care enough to take the time to communication properly? Think about it.

That said, try the Java Media Framework. You can find a lot of demo code and examples here: http://java.sun.com/javase/technologies/desktop/media/jmf/reference/codesamples/index.html

stephen84s commented: Excellent post. +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you mean you want to open it for general browsing in the OS (with Explorer for example), you'll have to use Runtime.exec() or ProcessBuilder for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a look at the constructor you wrote for Rectangle and compare that to the code you are using to create it (which you are doing when you add the "new" keyword). You have collected the info to use that constructor, you just aren't doing so.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, it is "read" in Thread1, because it's the same static "cnt" that you declared in your top level class - but you really should pass it as a parameter. I'd recommend writing a constructor for Thread1 (which you really should rename - Thread1 doesn't really convey anything about what that class is for) which takes that count as a parameter and initializes the arrays to the proper sizes. Make those arrays plain private members. They don't need to be public static.

I'd also recommend adding a println check on the value of "cnt" before starting that thread to verify that it is the value you think that it should be.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And are you certain that "cnt" is greater than zero when those arrays are getting declared?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not going to count each line to find line 45, but it's most likely your first access of the "transition" array in Thread1. "(cnt*(cnt-1)/2)" is most likely coming up zero and leaving you with zero-length arrays.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

@rapture: No, because that method signature does not have a parameter. He is calling it correctly, but it's not doing what he thinks it might be doing.

That method is not actually doing anything but returning a null string variable that was never initialized, which in turn is causing a null pointer exception I would imagine (I haven't run any of the code and he didn't specify the error).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What errors? You didn't specify what they are. Have you read the stack trace of the error? It indicates the nature of the problem and the line number.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your while loop is fine as long as you re-prompt for the next value at the end of your loop code. In pseudo code, you want something like this

prompt "continue?"
while ("yes"){
 // do stuff

  prompt "continue?"
}

As for as "tracing", just start with the initial value of "counter" in your loop (which is zero) and walk it through your code mentally (or on paper if you prefer). That's all tracing is. You don't have to run through it very far to understand why you are getting the output that you are.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

>When I run my program I input 1 sales figure and the program goes into a never ending loop. Why?
Because you never change this condition

while  (dollars > 0)
        {

>and where are all the tallies "*" beside my references coming from and why
They are coming from your loop on your fixed "Sales" array. Trace the value of "counter" through those loops and compare them to the output you are getting.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should be overriding paintComponent(), not paint(), in your "NewClass" class.
(And find a new name for that class because NewClass is an awful name for a component)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Since your assignment specifies it, do you not have any class notes related to StringTokenizer? Seems strange to me that you have an assignment on things that were not covered in class at all.

StringTokenizer is also a legacy class and it's usage in new code is discouraged:

StringTokenizer is a legacy class that is retained for compatibility reasons although its use is discouraged in new code. It is recommended that anyone seeking this functionality use the split method of String or the java.util.regex package instead.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's because you aren't repainting the background rectangle before you paint the oval. Even so, you really should do your custom painting on a lightweight component such as a JPanel or small JComponent class that overrides paintComponent(), rather then painting directly on the JFrame. Here is your code with a small canvas component for the painting:

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Graphics;
import javax.swing.JComponent;
import javax.swing.JFrame;

public class Court extends JFrame implements Runnable {

    private int x = 10;
    private int y = 20;
    private int r = 3;

    public Court() {
        setBounds(0, 0, 200, 200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setBackground(Color.BLACK);

        // adding the new component here
        getContentPane().add(new CanvasComponent());

        this.setVisible(true);
        start();

    }

    // Custom component for your paint work.
    // JPanel is also a good candidate for this.
    class CanvasComponent extends JComponent {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.setColor(Color.BLACK);
            g.fillRect(0, 0, getWidth(), getHeight());
            g.setColor(Color.GREEN);
            g.fillOval(x - r, y - r, 2 * r, 2 * r);
        }
    }

    public void run() {
        while (true) {
            x++;
            repaint();

            try {
                Thread.sleep(10);
            } catch (InterruptedException ex) {}
        }
    }

    public void start() {
        Thread thread = new Thread(this);
        thread.start();
    }

    public static void main(String[] args) {
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Court();
            }
        });
    }
}//end
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One thing to note on the do-while loop verruckt24 posted above:
You probably want a normal while() loop there instead of the do-while(), otherwise you're performing the loop code before checking the user's response.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, it depends on where your code stands now after addressing the other two things I mentioned.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, "code" is the tag name.

[code] your code goes here [/code]

You can also highlight the code and click the little "#" button on the toolbar to surround it with code tags.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to either specify the collection type with Generics

Data one = new Data("bob", "jackson", "123 main street", "781-345-3245"
	
LinkedList<Data> list = new LinkedList<Data>();		
list.add(one);
 list.getFirst().output();

or cast it to your Data type prior to calling methods on it.

Data one = new Data("bob", "jackson", "123 main street", "781-345-3245"
	
LinkedList list = new LinkedList();		
list.add(one);
Data first = (Data)list.getFirst();
first.output(); 
// or
((Data)list.getFirst()).output();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First, use [code] [/code] tags around your code so it remains readable.
Second, get the "double" out of that expression you posted the error on (line 30). It doesn't belong in there.
Lastly, I don't think input.next.Int() is a valid method on the the Scanner class. Check the API.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are a couple of different ways you can do it. Either of the provided Timer classes can be used to schedule a repeated task to update your internal variables (i.e. seconds). You can read about when to use which here. Alternately, you could have a simple thread running a loop that sleeps 1000 ms, updates your time variables, and schedules a repaint on the the AWT event queue (with invokeLater())

Any of these methods can slip a little time over the long run if you update your internal time with something as simple as seconds++; due to process time slicing, garbage collection, etc. If you want your time to remain more accurate over longer periods, you can update your instance time variables from the difference in System.nanotime() since your last update.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

He is referring to the "Read Me:" posts at the top of this forum: http://www.daniweb.com/forums/forum64.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The Collections Framework has implementations of many such data structures. You only have to write your own if you need functionality that is not available with the existing ones - and even then you can probably just use composition to delegate most of the work to an existing implementation and add whatever extra you need.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Edit your post and use [code] [/code] tags around your code. Reading that unformatted wall of text will turn many away.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What have you done in your code so far? I gave you a model to start with above. Did you read it? Did you understand it?

I am not going to write examples of how to do every single thing you request - especially when you are too lazy to even type all of the letters in a sentence.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

To get more control over the layout, you'll need to learn more about the various layout managers that are available. The following tutorial has a lot of information and samples: http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Neither one. I don't write console applications. :P

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not sure what your professor is expecting you to use here, but a fall-through switch works pretty well for the gifts due to the additive nature of each successive case:

System.out.print("On the ");
        
        String dayString = "";
        switch (day) {
            case 1:
                dayString="first";
                break;
            case 2:
                dayString="second";
                break;
            case 3:
                dayString="third";
                break;
        }

        System.out.print(dayString + " day of Christmas, \nmy true love gave to me\n");

        switch (day) {
            case 3:
                System.out.println("Three french hens,");
                // fall through
            case 2:
                System.out.println("Two turtle doves");
                // fall through
            case 1:
                if (day > 1) {
                    System.out.print("and ");
                }
                System.out.println("A partridge in a pear tree.");
        }//end switch

Arrays to hold the day names and the gifts would also work well and, in that case, a while loop would be appropriate to count down through the gifts.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Because you are looping while day is greater than zero. If you only want the single result, remove the loop.

Another thing to consider though: you are retyping all of the gifts from other days on each case, which is unnecessary because the lines are additive. Each day adds a new line, but the previous lines are the same. Your code should reflect that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Okay, here is a bare-bones example. I've included the EditorPanel here as an inner class just for convenience sake. You would actually want that to be a separate top-level class.
(For future reference, if you want people to take the time to help you out, the least you can do is expend the effort to type complete words. There is no "u" here. Punctuation wouldn't hurt either.)

import java.awt.BorderLayout;
import javax.swing.JEditorPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.text.Document;


public class TabbedEditorExample extends javax.swing.JFrame {

    public TabbedEditorExample() {
        initComponents();
        
        // Add a couple of editor panels for example purposes
        addEditorPanel("C++");
        addEditorPanel("Java");
        
        setBounds(100, 100, 300, 300);
    }

    /** Add a new editor tab */
    protected void addEditorPanel(String name){
        tabbedPane.add(name, new EditorPanel(name));
    }

    /** Example of getting the currently selected editor */
    private EditorPanel getSelectedEditorPane(){
        return (EditorPanel)tabbedPane.getSelectedComponent();
    }

    /** Example of getting the currently selected document. */
    private Document getSelectedDocument(){
        if (tabbedPane.getComponentCount()>0){
            return getSelectedEditorPane().getDocument();
        } else {
            return null;
        }
    }

    /** This class just encapsulates the component details of the editor panel */
    class EditorPanel extends JPanel {
        private String name;
        private JEditorPane editorPane;

        public EditorPanel(String name){
            super();
            this.name = name;
            editorPane = new JEditorPane();
            JScrollPane scrollPane = new JScrollPane(editorPane);
            setLayout(new BorderLayout());
            add(scrollPane, BorderLayout.CENTER);
        }

        /** Provides access to the text document. */
        public Document getDocument(){
            return editorPane.getDocument();
        }

        public String getName(){
            return name;
        }
    }

    private void initComponents() {
        tabbedPane = new javax.swing.JTabbedPane();
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().add(tabbedPane, java.awt.BorderLayout.CENTER);

        pack();
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() …
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you could find it by walking down the container hierarchy from the selected tab with instanceof checks, but I'd consider that an awful hack. You're better off writing an EditorPane class that encapsulates the components of each editor pane. Each tab would contain a single instance of EditorPane and have the necessary references to obtain the text.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, you can either remove them or rename the variables - but you can't declare two different variables with the same name within the same scope.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Atenka is saying that you are only collecting a single value from the user, but you are using an array in your method. If you need many values in an array, you need to prompt the user to enter each one. The "nextDouble" part is just fine - you just aren't collecting enough values to fill the array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look again at your variable declarations in main(). You'll see that you declared other variables for those values, but p, r, and t are not those variables.

zaraeleus commented: Thank you... you caught the obvious that I was missing all along! +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

HashMap.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Check the API on GregorianCalendar (or just Calendar if you wish).

Also keep in mind the forum rules regarding "chat speak" - if you wish to ask for help, take the time to type all of the letters in your words and use capital letters where appropriate.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Don't declare variables with the same names as methods and if you want to share those arrays between methods, you'll need to declare them at the class level. Currently they are local to your methods and are not visible to any code outside those methods.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Do it in Fortran.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Is there a way to get paid well for that instead of actually doing productive work? :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't even understand what you mean by that question. Your code is only processing the top level of each root entry and only then if it's a directory.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Somewhere you have a missing brace, paren, or semi-colon (or perhaps more than one). These should be rather simple structural syntax errors for you to locate. Just start looking backwards from the first line number the stack traces are reporting.

Formatting the code better would also help spot such structural problems, by the way.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just add a call to super.paint(g) prior to your own paint code.

public void paint(Graphics g)
	{
                super.paint(g);
		g.drawString(output, 50, 50);
	}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are quite a few articles, etc. on pros of Python:
http://www.google.com/search?sourceid=mozclient&ie=utf-8&oe=utf-8&q=why+use+python

(I also just noticed the link I posted to the wiki on it missed a left paren. It should have been http://en.wikipedia.org/wiki/Python_(programming_language))

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you don't know what it is or what is good about it, why would you make a decision to learn it?
Start with some basic investigation before posting questions of this level of generality:
http://en.wikipedia.org/wiki/Python_(programming_language)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You basically need a main application context that all necessary components have access to and can call upon for access to the various sub-systems in your app. The reference to that context can be supplied via the constructors.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, that does seem to be the point of a "printValues()" method, yes? The calculation for the number of comparisons has nothing to do with that method and nothing to do with a loop. It is one calculation that only requires the number of elements being sorted.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to be a little more specific on your expectation for this "generic" base class. What do you believe is lacking or wrong?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

basically, this code, is seperate out all the words from text file and then save each of them into a hashmap (which i havent started yet), any takers?

"Any takers" on finishing the work for you? No. Helping you complete it is still a possibility.