Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

And how do you figure it's a silly answer? You don't say what about the code you do not understand. Is he supposed to just know that you understand pointers? Do you? Do you expect someone to just explain every portion of "that top template part" to you in excruciating detail?

Perhaps if you can write a clear question you may receive a clear answer - though after that last response I wouldn't bet too much on it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Dim i as integer
i=10
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A search across this site (that little box in the upper right corner) on "final year topic" yields 50 pages of results. That should get you started I would think.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

First you'll want to get a BufferedImage object for the input image. Example code for this here: http://exampledepot.com/egs/java.awt.image/Image2Buf.html?l=rel

BufferedImage will allow you to access the grid of pixels (http://exampledepot.com/egs/java.awt.image/ImagePixel.html?l=rel). You may be able to apply a thresholding function to the pixels to create an array map of the identified paths, perhaps just a binary mapping 0 or 1 to mark available paths.

From there, apply your pathfinding algorithm to the binary map and update the corresponding pixel values on the BufferedImage based upon the desired path and then save it back out to a new file (saving: http://www.exampledepot.com/egs/javax.imageio/Graphic2File.html)

Good luck!

darkagn commented: Really good explanation :) +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Definitely one of the most unique topic suggestions I have seen! :)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This should give you a pretty good idea on how to set them up.

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.*;

public class FrameExample extends JFrame {

    JPanel panNorth;
    JPanel panWest;
    JPanel panCenter;

    public FrameExample() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        setLayout(new BorderLayout());

        // set up top panel
        panNorth = new JPanel();
        panNorth.setLayout(new FlowLayout());
        panNorth.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        JLabel lblUpper = new JLabel("Upper Panel");
        panNorth.add(lblUpper);
        add(panNorth, BorderLayout.NORTH);

        // set up left panel
        panWest = new JPanel();
        panWest.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        panWest.setLayout(new GridLayout(2, 1));
        JButton btnFirst = new JButton("First");
        panWest.add(btnFirst);
        JButton btnSecond = new JButton("Second");
        panWest.add(btnSecond);
        add(panWest, BorderLayout.WEST);

        // set up center panel
        panCenter = new JPanel();
        panCenter.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
        panCenter.setLayout(new BorderLayout());
        JLabel lblMiddle = new JLabel("Middle thing");
        lblMiddle.setHorizontalAlignment(JLabel.CENTER);
        panCenter.add(lblMiddle, BorderLayout.CENTER);
        add(panCenter);

        setSize(300, 300);
        setVisible(true);
    }

    public static void main(String args[]) {
        new FrameExample();
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yeah, they tested the differences between firing frozen vs thawed chickens.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Chickens are fired from guns into aircraft engines and windshields to test birdstrike effects.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Each container can only have one layout manager, however you can easily create any layout you wish by nesting containers with the layout that you want for each one. This could include using a few JPanels inside a JFrame with each JPanel containing a few components. Breaking up the layout like that gives you a lot of control over the grouping and resizing behavior of complex layouts.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Then the class does not need to extend Queue.

The remove person method will not need to take a custName parameter because dequeue() should remove the next item from the queue and return the name of that person. I'm not sure why you are returning the Queue from addPerson() and removePerson().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A leech has 32 brains.
Just saying.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

newbie reps, and those from the coffee house, dont count toward your totals

But they make you feel warm and fuzzy.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Why does MVDList extend Queue but work with an internal Queue reference "aQueue"?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I gave you a reputation

This is all just happening inside your head. None of it is real.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

are you there

no

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Most commercial jingles.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
BigDecimal[][] weightMatrix = new BigDecimal[4][4];
for (int i=0; i<weightMatrix.length; i++){
    for (int j=0; j<weightMatrix[i].length; j++){
        weightMatrix[i][j] = new BigDecimal(yourValue);
    }
}
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please, use [code] [/code] tags around any code that you post - after 22 posts here you should be aware of that by now.

Edit: You can put code tags in your post above by clicking "Edit This Post", "Go Advanced", highlighting the code part and clicking the "#" (Wrap code tags around text) toolbar button.

What questions do you have about the code? You're going to need to be a little more specific than "I need help".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you are just starting to learn Java, trying to jump into a graphic game is going to push you very far into deep water without a grasp on basic fundamentals.

That said, you could take a look at a few of these links:
http://www.gamedev.net/reference/articles/article1262.asp
http://javaboutique.internet.com/tutorials/Java_Game_Programming/
http://www.planetalia.com/cursos/index.jsp

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just use a BufferedReader for the read. Example here: http://www.exampledepot.com/egs/java.io/ReadLinesFromFile.html

jasimp commented: tirelessly helping those that need it in the java forum +6
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Multiplying at those magnitudes are putting you beyond the precision of double. Use BigDecimal instead.

double a = 1.190597027811988E-273;
double b = -2.513498651481222E-273;
System.out.println("double: "+(a*b));
// double: -0.0

BigDecimal c = new BigDecimal(a);
BigDecimal d = new BigDecimal(b);
System.out.println("BigDecimal: "+new DecimalFormat("0.#######E0").format(c.multiply(d)));
// BigDecimal: -2.992564E-546
majestic0110 commented: A great poster, always helpful +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Then you have a bit of studying to do, because that is the heart of the homework assignment. If you need help with homework, you'll need to get a little further than this on your own.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can implement as many interfaces as you like

public class PetAdviceApplet extends Applet implements ActionListener,ItemListener

. Then you need to add the actionPerformed() method to your class to handle the event.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, here is your issue. You don't actually call the deposit method. You just read a value from the input and then show the balance. It's not going to call deposit(amount) on it's own automagically

if (inputChoice == 1)
{
    System.out.println("How much would you like to deposit?");
    Integer.parseInt(userInput.readLine());
    // you need to actually make the deposit() call here with the amount to deposit
    System.out.println("Your new Balance is: " + mattsAccount.getBalance());
}

Also, this part

//method to calculate deposit
		public bankofMark(double initAmount)
		{saBalance = initAmount;}

has nothing to do with making the deposit - you have created another constructor for the class that takes only "initAmount" as it's parameter. Your other constructor is the one that you are using and it already sets "saBalance" (though it really has way too many parameters for a constructor - most of that info should be set with a setXXX() call instead of throwing it all into the constructor - but that's another issue)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As far as the listener, read the link that I posted above on how to write an action listener.

The reason the output doesn't show is that the container hasn't updated the component spacing to accommodate the longer text that you put into the output field. Adding a call to validate() after you set the text would fix that

public void output(String pet) {
        outputLabel.setText("According to your requirements, I would recommend a "+pet);
        validate();
    }

You would have much more control of the layout if you used something besides the default FlowLayout. See this tutorial on other layout options: http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't show the other code in main(), but if you have properly created the mattsAccount object with the bankofMark(double initAmount) constructor, then mattsAccount.getBalance() should return the balance.

With just pieces of code to go on, we can only assume what you're doing there. If you posted the rest of the main method it would be a lot clearer.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No because the method is getBalance(), not getsabalance (which you are accessing like a public variable anyway, not a method call)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just call mattsAccount.getBalance() .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Too late to edit the previous. You're right, it makes no difference for primitives :)
I never worried about it enough with primitives to get a "final answer".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, the space for the variables is allocated at the "method" level. So, declaring a variable before the loop, or in the loop, has no additional effect what-so-ever. ;-)

The part that I haven't found a definitive answer on is whether that space is re-initialized if the declaration is within the loop. Many older tips on tuning recommend declaring the variable before the loop rather than inside it, but I think more recent compilers will make that optimization on their own. Out of habit, I usually declare such variables just prior to the loop regardless.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So, readability aside, it is more efficient to do a fairly simple calculation two or three times than to store the result?

No, in all likelihood it is not, though allocating such variables in loops can lead to excess GC activity - and even in that case there is a good chance the JIT compiler will re-use a single reference instead of creating a new one each time anyway unless subsequent assignments make that impossible. The short answer is store the calculation in a local variable.

The code in question is going to be called every time the paintComponent method is called on a particular JPanel. So far, it refreshes instantaneously. However, I still have a lot of code to add, and I would like to keep things as efficient as possible, even at the loss of readability.

This is premature optimization at the level you are examining it. The best guideline for tuning painting code is to try to minimize the calculations needed to render. Repaints can occur for many events besides the ones that you are generating in your own code. Updating the variables, either primitives or objects, in the methods that alter them (such as a mouse listener, animation loop, button listener, etc) and letting paint code use those variables is your best choice.

Finishing the code to work correctly with a clean and clear design is much more important at your current stage than worrying about milliseconds of optimization. If you find you do …

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't know what "my format is off" is supposed to mean, so you'll have to clarify that more.

The clear button doesn't work because you haven't written any code for it to do anything. You need to implement and attach an ActionListener for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The general guideline is to write the code in the clearest, most effective way and worry about optimization only if poor overall performance and code profiling warrant changing it.

That said, if you're using the result of a calculation more than once you should probably store it into a variable for consistency and clarity. If that calculation needs to be performed more than one or two times or in different contexts, move it into a method of it's own.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You call validate on the container you added them to - "mainPanel" in your case. Masijade posted that as the very first answer to your question. Obviously you did not try it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to concatenate the string with "+". outputLabel.setText ("According to your requirements, I would recommend a "+pet); . Your current statement is being read as a call with 2 parameters.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I haven't heard any of their newer stuff past Stomp 442, which I think was the second album with John Bush singing. Persistence of Time was probably my favorite, though I like pretty much all of their early stuff.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you try adding the validate() call as suggested? Did you read the api documentation on that method in the link that masijade posted?

Learning to take advantage of the documentation available is one of the most important things to programming in any language.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Mr. jbennet Im shocked. An obvious metallica fan and you didnt like orion or damage inc. They are up there in my fav metallica songs.

All though when it comes to metal i like it heavier then metallica (Pantera/Slayer)

Pantera, Slayer, Overkill, Testament, Annihilator, Anthrax, Megadeth, Exodus, Corrosion of Conformity - all good (or they were many years ago, some I haven't kept up with :) )

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

hai
i am nireekshan;
i am using Mysql 5.0;
it was instaling C:\Program Files\MySQL;
i am write code Bellow see and
--save c:\ "Mysqlcon.java " in this program
run-in commend Fromt> javac Mysqlcon.java It was NOT Any Errer;
>java Mysqlcon
ERRER ACCERED.......CLASS NOT FOUND EXPATION


//I AM COPY Mysql.jar file in C:\

Try running it with java -cp .;mysql-connector-java-[ver]-bin.jar Mysqlcon . You need to have the jar file in your classpath for it to find the files.
You may want to read this documentation as well: http://dev.mysql.com/doc/refman/5.0/en/connector-j-installing-classpath.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nah, it's just too slow and plodding for me. Disposable Heroes is probably my second favorite on that album behind Master of Puppets, though Battery and Sanitarium are right up there as well (hard for me to rank any of those favored over another actually). Least favored would the The Thing That Should Not Be and Orion (it's okay but too long for an instrumental).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Only 40% - a poor test. I've been into metal for over 20 years :P

ride the lightning
master of puppets (close second)
and justice for all
theblack album otherwise known as "metallica" (this ranking will undoubtably lead to flamewars)
kill em all
load/reload ( crap)
st. anger (total and utter crap)

No flames for me - I'd agree with that ranking, though choosing between the first 2 is just about impossible for me. Don't forget to slide Garage Days in there above Load (of crap).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are getting the error because you defined the class to be in the "AddRFSwitchPac" and you are trying to run it with "java Printing". Use "java AddRFSwitchPac.Printing" instead. That is assuming you have the Printing class in a folder named "AddRFSwitchPac" and that you are trying to run it from the directory above "AddRFSwitchPac".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

fave songs by metallica (best to worst, but bottom doesnt = crap, as they havent been shown)
Highly reccomend listening to all of these.

Welcome Home (sanitarium)
Fade to black
Battery
Master of Puppets
Ride the Lightning
For whom the bell tolls
And justice for all
The thing that should not be
Leper Messiah
To live is to die
My friend of misery
Holier than thou
Wherever i may roam
The god that failed
Holier than thou
Creeping Death
Escape
Blackened
Trapped under ice
Fight Fire With Fire
Disposible Heroes

Ack, I can't believe you pushed Disposable Heroes to the bottom of the list and didn't like Damage Inc, but with the exception of The Thing That Should Not Be it's a good list :P
( I can't remember the last time I didn't hit 'next track' when The Thing That Should Not Be came up)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should be able to set the timeout with this method prior to any calls to getConnection: DriverManager.setLoginTimeout(int)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the runtime errors that you are getting.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please see the Announcement regarding homework help:
http://www.daniweb.com/forums/announcement9-2.html

If you have a test on arrays then you probably covered them in class. Time to crack the book and review your notes. If you have specific questions about some things that are giving you trouble, post the code you have along with your questions.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Oh, I'm sure someone probably could, but that's not really the purpose of this forum. What effort have you made to learn anything about it on your own? Have you searched for any tutorials on it? Have you tried them?

If you have specific questions, ask them, but "send me code" isn't really a valid question here.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i nead java code to connect printer when i click print button in my developing application

Then you "need read this tutorial on AWT printing" and write some:
http://java.sun.com/docs/books/tutorial/2d/printing/index.html

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you are using java 1.5 or above, the java.awt.Container class (which pretty much every Swing UI component extends from in it's hierarchy) has a method setComponentZOrder(java.awt.Component, int) that you can use for this.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Not seeing the other methods that might be involved with painting it's difficult to say with certainty, but the need to start the animation and then draw more things and repaint seems like trouble. Obviously the animation loop is repainting, so it shouldn't be necessary to call repaint again after it's started. What method is that code residing in and how often is it called?

I would ask the same question about the buffered image code that you posted above. Is the buffered image being created each time or just once and updated as needed?