darkagn 315 Veteran Poster Featured Poster

I'm sorry regent_royal, what was the question? If you want to know how to display that HTML that you have posted in a JEditorPane its just a matter of assigning all of that HTML text via a call to the component's setText() method.

darkagn 315 Veteran Poster Featured Poster

What I'm trying to say is that it's not a good idea to post a chunk of code in answer to someone's question. Instead, try giving clues or pointers to what they need to do and let them code it themselves. They learn better that way and also don't feel like a cheat for blatantly copying your code.

darkagn 315 Veteran Poster Featured Poster

Hi sanaulla123,

At DaniWeb we try to guide those asking for help rather than just blurting out the answer for them to copy. Please repect this in future :)

darkagn 315 Veteran Poster Featured Poster

Your algorithm seems to be correct. How are you calling the method?

darkagn 315 Veteran Poster Featured Poster

www.php.net is probably a good place to start. This site has some really good documentation and sample code. Of course, if you get stuck there is also DaniWeb :)

darkagn 315 Veteran Poster Featured Poster

Try replacing your computer name with your IP Address. You will need to create an InetAddress object using your IP and pass that object into the constructor for Socket.

darkagn 315 Veteran Poster Featured Poster

I know that your tutorial probably says to connect to port 7 for an echo, but try connecting to a port > 1024. Chances are your errors are due to trying to connect to a port that is in use.

darkagn 315 Veteran Poster Featured Poster

Davisor Publisher is a Java API that can convert from a DOC, PPT or PDF to PDF, XHTML, PNG, JPEG, TXT or XML formats. I haven't actually used it before but it seems to be a good one.

darkagn 315 Veteran Poster Featured Poster

You need to call Graphics2D.setStroke(Stroke) method before drawing a line. You will need to create a Stroke first - use the BasicStroke class for now. Also, don't forget to reset the stroke after you have drawn your line.

Ezzaral commented: Concise and correct. +9
darkagn 315 Veteran Poster Featured Poster

StringBuffer is certainly better in handling lots of operations than a normal String and can handle the same number of characters as a String. It is also completely thread safe.

However if you are using JDK 5 or later, you might want to think about using a StringBuilder if system performance is your major concern. Only do this though if you can GUARANTEE that only a single thread will be accessing it at any one time (it is not thread safe).

Hope this helps,
darkagn

darkagn 315 Veteran Poster Featured Poster

Hi Midget,

If it works then it isn't wrong :) However, I should point out that it's not the best idea to post your finished version. Anyone could just come along and copy your code. Here at Daniweb we try to guide people to a solution that they have found themselves rather than blurting out the answer. Please consider that next time.

darkagn 315 Veteran Poster Featured Poster

Use e.getSource() to determine where to copy / paste to / from rather than mPane.field. For example, your PasteActionAdapter.actionPerformed method should be:

public void actionPerformed(ActionEvent e)
{
  e.getSource().paste();
}
darkagn 315 Veteran Poster Featured Poster

Could you just put a simple if-statement in your mouseExited method?

public void mouseExited(MouseEvent e)
{
  if (e.getSource() != this.closeButton)
  {
    // do your current code here
  }
}
darkagn 315 Veteran Poster Featured Poster

Actually, I have just realised the mistake. You want the following code for your connect function in the Connection class:

public function connect()
{
   $dsn = ...
   $username = ...
   $password = ...
   try
   {
     $this->connection = new PDO($dsn, $username, $password);
   }
   catch (PSOException $e)
   {
   echo 'Connection failed: ' . $e->getMessage();
   }
}

Notice the removal of '$this' in the parameters to the constructor of the PDO object. That is because we want to reference the local variables as opposed to the class variables (which this signifies).

darkagn 315 Veteran Poster Featured Poster

Do you have a database on the local server called 'example'? And is there a user called 'root' with a password 'root' that has access to that database? Try testing this by connecting to the example database with that username/password in mysql and see if it works that way. Your connect() method looks correct.

Another thing you can try is to put the connect method in a try/catch block.

public function connect()
{
  $dsn = ...
  $username = ...
  $password = ...
  try
  {
    $this->connection = new PDO($this->dsn, $this->username, $this->password);
  }
  catch (PSOException $e)
  {
    echo 'Connection failed: ' . $e->getMessage();
  }
}
darkagn 315 Veteran Poster Featured Poster

Hi there ajayajayajay and welcome to DaniWeb,

To the best of my knowledge, the whole point of the md5 function is that it is a one-way encryption of a string so that it cannot be decoded. This way if a hacker gains access to your database, they can't just "reset" all the passwords in your database and gain access to all that lovely account data.
As for your second question, I'm not sure exactl what is happening with your hash. What is your code for encoding the hash (the line that calls the md5 function)?

darkagn 315 Veteran Poster Featured Poster

Hi napper_1337 and welcome to DaniWeb,

Can you please post your code for index.php for the lines near 142? Say 140-150 so we can see what is going on?

darkagn 315 Veteran Poster Featured Poster

What errors are your triggers giving?

darkagn 315 Veteran Poster Featured Poster

Here is a link to tutorials for the PDO package which is really easy to use and works really well with MySQL. The manual can be found here.

darkagn 315 Veteran Poster Featured Poster

Your problem is in the first if-statement:

if ($_FILES["userfile"]["size"] = 0)

You are using an assignment here rather than the comparator == as I think you mean. In PHP though, your statement is legal, just that it will always be evaluated to false (and thus will never cause the code block following it to execute).

As for not getting the error when you upload a 2MB file, I'm not sure what is happening there, especially since 2000000 bytes < 2MB (which is 2 * 2 ^20 = 2 * 1024 * 1024). I would suggest doing the following to see exactly what is happening when you upload a file:

print_r($_FILES);
exit;

Executing this code will print the FILES array and might give you a clue as to why your code is not behaving as you would like.

Hope this has helped,
darkagn :)

antwan1986 commented: Helpful +1
darkagn 315 Veteran Poster Featured Poster

Two areas you could talk about is how mathematics is used to determine shadows and movement of the camera. Read up on Projection Matrices and the Phong Model as a starting point.

It sounds like a very interesting project. Good luck and enjoy :)

darkagn 315 Veteran Poster Featured Poster

Further, Java is a popular cross-platform, interpreted object-oriented programming language.

darkagn 315 Veteran Poster Featured Poster

Hi Ryano24,

We're not allowed to just give you the answers but we can try to point you in the right direction. What do you think the answers are? Take an educated guess and we will let you know where you've gone wrong.

Cheers,
darkagn

darkagn 315 Veteran Poster Featured Poster

What do you mean by "get something in the menu bar?"

darkagn 315 Veteran Poster Featured Poster

I have never used a StreamConnection before (is that one of your classes?) but if it's anything like a ServerSocket that waits to accept() in its acceptAndOpen() method then this call needs to be made in a separate Thread. Otherwise, your main thread will sit waiting to accept and this causes a deadlock.

darkagn 315 Veteran Poster Featured Poster

Hi alpe gulay,

It seems from your questions that you are a bit of a beginner at Java. Take a look at the post at the top of this forum. It contains several great links that might be able to help you in your journey. The website java.sun.com is particularly helpful, with tutorials, examples and the API documentation as well as many other Java resources.

In answer to this specific question, there are probably many ways to do what you want. Off the top of my head I would suggest taking a look at the java.io.File.deleteOnExit() method for a simple way of deleting any file (and therefore directory) when the virtual machine terminates.

Hope this helps,
darkagn :)

darkagn 315 Veteran Poster Featured Poster

I haven't actually used SQL with Java before, but there are plenty of tutorials / examples out there in the world wide web. This link might be a good place to start since you are using MySQL. Good luck :)

darkagn 315 Veteran Poster Featured Poster

Now my problem is when I try to access p from func2(), I am getting a NullPointerException error. I am not initializing p anywhere through D()'s or B()'s no argument constructor. Is that the problem?

Yes, in order to use p it must be initialised somewhere. Try this:

int func2()
{
  System.out.println( p ); // this should print "null" since p has not yet been initialised
  return p; // this should return null since p has not been initialised
}

However if you set p before calling func2() then your problem should be solved. I guess it depends on what you want to do.

darkagn 315 Veteran Poster Featured Poster

Isn't this exactly as my code, I wonder :?:

Apologies peter, but I was trying to reiterate what you had said. From someguy's post I thought that he/she didn't understand, because cg.Blackjack() looked to me like they were trying to call a constructor method or something. I wasn't trying to steal credit for what you had suggested and am sorry if it appeared this way.

darkagn 315 Veteran Poster Featured Poster

Hi ells912 and welcome to DaniWeb,

Both questions are very similar. You need to do the following:

1. Prompt the user for an integer.
2. Store the digits of the integer in an array.
3. Loop over the digits (Q1 in normal order, Q2 in reverse order) and print them out one by one.

We are not allowed to do this for you, but there is a breakdown of what you need to do. Give it a try and if you get stuck post some specific questions (with code to show what you've tried) and we will try to help you out.

Good luck :)
darkagn

darkagn 315 Veteran Poster Featured Poster

You will want something like:

Blackjack bj = new Blackjack();
bj.start();

and have a start() method in your blackjack class that basically runs the game (ie swaps to the Blackjack panel as Ezz suggested earlier).

darkagn 315 Veteran Poster Featured Poster

The problem was that I had permission for writing a file, but the g and o permissions did not. Changing their settings worked. Thanks pritaeas! :)

darkagn 315 Veteran Poster Featured Poster

Hi all,

I am fairly new to PHP (my experience is mostly in Java) and I have inherited a project that was initially implemented in PHP4. I am updating it to use PHP5 and at the same time I am trying to add Logging to the project. I am using the Pear Log package for this purpose, but I am having a bit of trouble getting it going. I am attempting to use a File Handler and my setup code looks like this:

class Booking
{
  private $log;
  public function Booking()
  {
    $this->log = &Log::singleton('file', 'log.txt', 'Booking');
    $this->log->setMask(PEAR_LOG_ALL);
  }
}

Then when I try to log something I write

public function getBookingTime()
{
  $this->log->debug("getBookingTime() entered.");
  return $this->bookingTime;
}

After I run my code I can't find a log.txt file anywhere. I also tried using a console handler to see if I could get the log output to console, but this also failed. Am I missing something here?

Thanks in advance for any advice,
darkagn

darkagn 315 Veteran Poster Featured Poster

Is ImageViewer your own class and is it in the same package as PlotVacDisplay? If not you will have to import it.

darkagn 315 Veteran Poster Featured Poster

Do you have any specific questions or would you like us to just write it for you?

darkagn 315 Veteran Poster Featured Poster

yea that worked fine...one other quick question...i tried to run my code and it will not let me but compiled fine...is there something I did wrong with my code or something that I just have not programmed yet because it looks fine on my end...

What error message do you get when you try to run the program?

darkagn 315 Veteran Poster Featured Poster

What's your definition of the cipher alphabet as opposed to the secret code? I thought that a cipher was a type of code, so I don't really understand what you are asking here... :S

darkagn 315 Veteran Poster Featured Poster

Well I have to admit I usually use swing components rather than awt components for my GUIs. Has your instructor specifically asked you to use awt components? Changing to swing is easy - import javax.swing.* and add a J to the front of each of your GUI components. Other than that, looks like number 2 is done for you...

darkagn 315 Veteran Poster Featured Poster

Most of the log calls allow you to print a message and the caught exception. Try this:

try
{
  // do something
} catch ( Exception e )
{
  if ( log.isDebugEnabled() )
  {
    log.debug( "Exception throw.", e );
  }
}

This will log the message and the stack trace (including line numbers) for the caught exception. There are similar methods for info, warn and error.

darkagn 315 Veteran Poster Featured Poster

You can get the time via a call to

System.currentTimeMillis();

and parsing the returned long using the Calendar class. I'm not sure if it is possible to set the System time in Java but I'm not sure that you should either.

darkagn 315 Veteran Poster Featured Poster

Try adding some println statements to your init() method to see where the initialisation fails. Your html code appears correct to me...

darkagn 315 Veteran Poster Featured Poster

Do you have a particular question that the API can't answer for you?

darkagn 315 Veteran Poster Featured Poster

Hi Ryano24,

That all looks pretty good to me. I guess your next step is to add some drawString methods to display the difference, product and quotient. The only comment I have is what happens if the second number entered by the user is 0? Or if either string entered is not a number? You can't just blindly trust that users will enter what you tell them to. Other than that your code seems ok at a quick glance :)

darkagn 315 Veteran Poster Featured Poster

Hi aim and welcome to DaniWeb,

I'm a little unsure about what you mean by "image matching"? Do you mean you have two images in JPEG format and you want a program to work out if they are the same image?

Also, I should point out that we are not allowed to do your homework for you, but we can try to guide you in your efforts. Perhaps you could tell us what you are thinking of doing for your problem? (That might also help us to determine what you are after...)

darkagn 315 Veteran Poster Featured Poster

I find that setPreferredSize tends to work more often than setSize although as jwentig has mentioned it is not guaranteed. A subsequent call to pack(), validate() or invalidate() often overrides any previous call to setting the size anyway.

darkagn 315 Veteran Poster Featured Poster

I don't think that's possible. You can check the String against each String in your array (which is what you've said you don't want to do?) but how does it make sense to compare a single string with an array of strings? When do you expect them to be equal?

darkagn 315 Veteran Poster Featured Poster

Yes, just create an inner class that implements ActionListener. Then in the actionPerformed( ActionEvent e ) method you can call e.getSource() to find the button that was pressed and act accordingly. Then just add a single instance of your inner class to each button.

Hope this helps :)

darkagn 315 Veteran Poster Featured Poster

You have two loops

for (i=0; i<n-1; i++)
{
   for (j=0; j<n-1-i; j++)
  {

but I can't see where you initialise n. Try printing the value of n to the console just before that line and see what happens...

EDIT: Also, I think you will not need the "-1" in each of those loops, but we'll come to that once we work out what is happening with n.

darkagn 315 Veteran Poster Featured Poster

Yes, but to make your code easier to follow it might be worth writing "else if (choice==2)"...

darkagn 315 Veteran Poster Featured Poster
if (choice==1)
{
    //HERE CHOICE = 1
    for (i=0; i<20; i++)
    {
        cout<<"\n"<<num[i]<<endl;
    }
    return 0;
}
    // HERE CHOICE STILL EQUALS 1!
if (choice==2)
    {
        for (i=0; i<n-1; i++)
        {
            for (j=0; j<n-1-i; j++)
            {
                if (num[j+1] < num[j])    /* compare the two neighbors */
                {
                    tmp = num[j];         /* swap a[j] and a[j+1]      */
                    num[j] = num[j+1];
                    num[j+1] = tmp;

                    cout<<"Here are your numbers:"<<tmp<<endl;
                }
            }
        }
    }

Please see my comments in your code for a hint...