dantinkakkar 19 Junior Poster

...
I want the program to type the strings with
Robot r = new Robot();
r.keyPress( keyCode );
r.keyRelease( KeyCode );

The code looks like you're trying to fire an event.
Just have a look at this
Key Press ---> Event Fired ---> Something happens

You are trying to get the key pressed like this
Event Fired ---> Something happens

Jumping to the second step won't make the first step happen. Get my drift?

dantinkakkar 19 Junior Poster

If you want to implement private chat your system needs to be a little more complex than it already is. Obviously you can't send the message from one client to any random client, can you? The client will have to send the name of the client who needs to receive the message and the server will then send the message to that particular name. Now, this introduces another complication, how do you identify clients? That'll require some authentication procedure, however basic... So you'll have to change the client application to send it's identity too while registering with the server.

After implementing all this, you can implement private chat. In addition, if the IPs are not changing with time, one client can send the IP of another client and you can transfer the data using simple socket programming.

Cheers! :)

[EDIT: Also, you may have to keep a record (doesn't need to be serialized, because, as I said, we are speaking of chat at the very basic level) of the clients and their IPs.]

dantinkakkar 19 Junior Poster

also: depending on your IDE to 'auto-complete' your code is a crappy way of writing applications. better taking a few seconds longer, but knowing and understanding what you wrote when compared to knowing 'NetBeans(/Eclipse/...)' 'll solve the problem for me.

I only said that because I didn't remember the function name exactly :\

dantinkakkar 19 Junior Poster

Hey

I want to get the date and time with miliseconds in a format such as:

2012-02-09 12:41:52.982

or

2012-02-09 16:41:52.129

How can I do this in Java?

(If I can get a localized version of "Tuesday" as "Tues" as well even better but if not, I dont mind. Something stupid and unrequired.)

This?

dantinkakkar 19 Junior Poster

Can you explain a bit more? You want the event for key presses to be fired? Be a little more specific.

dantinkakkar 19 Junior Poster

So, basically, what you want to do is print out a string to the screen character by character?

The simplest way to do so is to use a for loop and after every string, use the wait() function...

Thread.getCurrentThread().wait(1000);
//Makes the program wait for 1000 milliseconds, i.e. 1 second!

Hope this helps :)

[EDIT: Isn't your way a little too complicated? I mean, it's fine, but the direct method works fine :)]

stultuske commented: no, that is not what he's trying to do. -3
dantinkakkar 19 Junior Poster

Seriously, dude, it does not matter. Pick any that you are acquainted with, and have already understood the structure of. It's always easier to develop on systems you understand fully.

Ubuntu is not a bad choice. Easy-to-learn-to-use ------- Unleash the power of that penguin!

dantinkakkar 19 Junior Poster

Couple of friends and me came to an idea of making our own distribution.Our idea is to make Linux distribution suitable for not so geeky people(eg.older people like your mom or dad,or young people like children in elementray scholl).Thats how we started making Ubuntu Home Edition.Linux distribution based on Ubuntu that everyone can use.Theres no commom unnecesary problems that cause headache to your family.

I want to hear you opinion and recomondations as well as critics.

On the contrary, I feel that Windows is simpler than Linux. Installing applications on Linux is really a pain in the a** sometimes. :P

dantinkakkar 19 Junior Poster

:\ No Wonder he had to ask for help, then. :D

dantinkakkar 19 Junior Poster

Line 7 is the worst error a human can make :)
This won't help but I suggest to you that you go through "The Java Tutorials" (http://docs.oracle.com/javase/tutorial/) once. :P :D :) :P

DavidKroukamp commented: like you were never a nOOb, dont keep putting others down, just because you think bad of their code -2
DJSAN10 commented: Agree -1
dantinkakkar 19 Junior Poster

Whoa dude. You expect me or anyone else for that matter to go through this? And you've not even placed any comments! I can help you at one place, though --

An ArrayList is a sort of list of elements in which you don't need to define it's size. You can keep adding elements using a func(). It's just an easier to build up and more flexible version of a typical array, and it falls under the java.util package. Next time you want someone to examine your code, please place comments. I'm not going through that.

dantinkakkar 19 Junior Poster

You can get the time in milliseconds very easily... It's System.getTime... something. If you're using an IDE that gives suggestions, just write "System." and that func will come up. :) Hope this helps.

dantinkakkar 19 Junior Poster

I want to build a network protocol analyzer, but I really don't know where to start. Obviously, I don't want the code in hand, I can think it up myself -- but the problem is a little more specific - where do I look at to get the IPs passing in and out? Like, do I need to communicate with the router or look for an operating system-related layer? I'm on Ubuntu 10.04 LTS (Lucid Lynx)...

And I know about things like WireShark and DarkStat -- using them is not what I want. I want something a little more customized for my needs, so can anyone help me out?

[EDIT: I don't want existing software. I'm doing something for my personal use]

dantinkakkar 19 Junior Poster

Now, listen. I got the solution.
The HTTPS protocol will require just a little addition to the previous TCP/IP code. Otherwise, the procedure remains the same!

dantinkakkar 19 Junior Poster

yeah so if you do, i don't see any reason why you can get the token in your app!? seriously this is getting murkier.
see, you can communicate with the FB servers using a simplistic java client. don't expect me to write any code.
just

import java.net.*; //right, i guess?
dantinkakkar 19 Junior Poster

wait i understood your problem
Do you have knowledge of TCP/IP Networking?

dantinkakkar 19 Junior Poster

The following HTML/JavaScript example demonstrates the client-side flow in one self-contained example:

<html> 
   <head> 
     <title>Client Flow Example</title> 
   </head> 
   <body> 
   <script> 
     function displayUser(user) {
       var userName = document.getElementById('userName');
       var greetingText = document.createTextNode('Greetings, '
         + user.name + '.');
   userName.appendChild(greetingText);
     }

     var appID = YOUR_APP_ID;
     if (window.location.hash.length == 0) {
       var path = 'https://www.facebook.com/dialog/oauth?';
   var queryParams = ['client_id=' + appID,
     'redirect_uri=' + window.location,
     'response_type=token'];
   var query = queryParams.join('&');
   var url = path + query;
   window.open(url);
     } else {
       var accessToken = window.location.hash.substring(1);
       var path = "https://graph.facebook.com/me?";
   var queryParams = [accessToken, 'callback=displayUser'];
   var query = queryParams.join('&');
   var url = path + query;

   // use jsonp to call the graph
       var script = document.createElement('script');
       script.src = url;
       document.body.appendChild(script);        
     }
   </script> 
   <p id="userName"></p> 
   </body> 
  </html>

This should make it clear. You should have scoured the documentation properly! It's not tough getting the token into your app now, since the server is returning the following text:-

access_token=x

Can't you obtain x from that?

dantinkakkar 19 Junior Poster

http://YOUR_URL?code=A_CODE_GENERATED_BY_SERVER

With this code in hand, you can proceed to the next step, app authentication, to gain the access token you need to make API calls.

In order to authenticate your app, you must pass the authorization code and your app secret to the Graph API token endpoint at https://graph.facebook.com/oauth/access_token. The app secret is available from the Developer App and should not be shared with anyone or embedded in any code that you will distribute (you should use the client-side flow for these scenarios).

https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE

If your app is successfully authenticated and the authorization code from the user is valid, the authorization server will return the access token

got it?

dantinkakkar 19 Junior Poster

As per what I understood after skimming through the documentation, FB will generate a token for you and you need not do so! Am I right?

dantinkakkar 19 Junior Poster
dantinkakkar 19 Junior Poster

I'm writing a java program that adds event handlers dynamically on the go on instructions by the user. My problem is, that how do I basically add them?

dantinkakkar 19 Junior Poster

I need assistance in printing out a Quine. I googled it and stuff, but I didn't understand the code snippets I saw. Can anyone explain in a more lucid tone?

dantinkakkar 19 Junior Poster

Correct me if I'm wrong anywhere...
Can't you just create an application on FB that can be contacted through your client?
It's safer that way; and I guess it solves your access token problem. That's how most of the mobile clients work!