Can anyone tell me how to click the sphere and display a messege???

/* Goal: Want to create a bunch of spheres, and when a sphere is clicked:
* 1) display a message in the textfield
* 2) transform the position of the sphere to (0,0,0)
* (if (0,0.0) is occupied by another sphere, move that sphere somewhere.
* Achieved : create the spheres,can transform,rotate and zoome the spheres.
* Problem: having trouble to click it and display text and change location (problem with picking)
* Thanks!!!!!!
public class node extends Applet{
public static void main(String[] args){
new MainFrame(new node(),1000,800);
Sphere sphere;
PickCanvas pc;
TextField text;
public void init(){
setLayout(new BorderLayout());
GraphicsConfiguration gc=
SimpleUniverse.getPreferredConfiguration();
Canvas3D cv=new Canvas3D(gc);
add(cv,BorderLayout.CENTER);
//add mouseListener
//add mouseListener for click
cv.addMouseListener(new MouseAdapter(){
public void mouseClicked
(java.awt.event.MouseEvent mouseEvent){
pick(mouseEvent);
//create textfield down below
text=new TextField();
add(text,BorderLayout.SOUTH);
BranchGroup bg=createSceneGraph(cv);
bg.compile();
SimpleUniverse su= new SimpleUniverse(cv);
su.getViewingPlatform().setNominalViewingTransform();
su.addBranchGraph(bg);
private BranchGroup createSceneGraph(Canvas3D cv){
     BranchGroup root= new BranchGroup();
TransformGroup spin= new TransformGroup();
spin.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
spin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
root.addChild(spin);
//appearance
Appearance ap=new Appearance();
          ap.setMaterial(new Material());
          //create ten spheres
          for(int i=0;i<10;i++){
               double x=0.1*i;
               double y=-0.05*i;
               //<transform sphere>
               Transform3D tr=new Transform3D();
               tr.setTranslation(new Vector3d(x,y,0));
               tr.setScale(0.03);
               //<transform sphere>
               //<objects>
               sphere=new Sphere();
               sphere.setAppearance(ap);
               TransformGroup Tg= new TransformGroup(tr);
               Tg.addChild(sphere);
               spin.addChild(Tg);
               //<objects>
          //rotation
MouseRotate rotator=new MouseRotate(spin);
BoundingSphere bounds= new BoundingSphere();
rotator.setSchedulingBounds(bounds);
spin.addChild(rotator);
//translation
MouseTranslate translator=new MouseTranslate(spin);
translator.setSchedulingBounds(bounds);
spin.addChild(translator);
//zoom
MouseZoom zoom=new MouseZoom(spin);
zoom.setSchedulingBounds(bounds);
spin.addChild(zoom);
          // <picking>
          BranchGroup bg=new BranchGroup();
spin.addChild(bg);
pc=new PickCanvas(cv,bg);
pc.setTolerance(5);
pc.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
//</picking>
// <background and light>
          BoundingSphere bound=new BoundingSphere();
          Background background=new Background(1.0f,1.0f,1.0f);
          background.setApplicationBounds(bound);
          root.addChild(background);
          AmbientLight light=new AmbientLight(true, new Color3f(Color.cyan));
          light.setInfluencingBounds(bound);
          root.addChild(light);
          PointLight ptlight=new PointLight(new Color3f(Color.green),
                    new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
          ptlight.setInfluencingBounds(bound);
          root.addChild(ptlight);
          PointLight ptlight2=new PointLight(new Color3f(Color.yellow),
                    new Point3f(3f,3f,3f),new Point3f(1f,0f,0f));
          ptlight2.setInfluencingBounds(bound);
          root.addChild(ptlight2);
     // </background and light>
return root;
//mouse event
public void pick(MouseEvent mouseEvent){
pc.setShapeLocation(mouseEvent);
PickResult[] results= pc.pickAll();
//when a sphere is clicked, display Node #
for(int i=0;(results !=null) && (i<results.length);i++){
PickIntersection inter= results.getIntersection(0);
int[] ind=inter.getPrimitiveCoordinateIndices();
text.setText("Node"+ind[0]);
//When a sphere is clicked, i want to change its position
//how to relocate the clicked sphere to position (0,0,0)?
//(if there is a sphere already in(0,0,0),change that sphere to
//somewhere else)
(I import this )
import javax.media.j3d.AmbientLight;
import javax.media.j3d.Appearance;
import javax.media.j3d.Background;
import javax.media.j3d.BoundingSphere;
import javax.media.j3d.BranchGroup;
import javax.media.j3d.Canvas3D;
import javax.media.j3d.Material;
import javax.media.j3d.PointAttributes;
import javax.media.j3d.PointLight;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import com.sun.j3d.utils.behaviors.mouse.*;
import com.sun.j3d.utils.picking.*;
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import java.applet.*;
import com.sun.j3d.utils.applet.MainFrame;
import javax.vecmath.*;

never mind. I got it to work.

Similar Messages

  • Can anyone tell me how to use the loops and backing tracks with a single guitar input? I can't seem to figure out how to set this up

    I am trying to configure Mainstage to input my own guitar and add a backing track from the library or a loop but, I can figure out how to open or add the tracks I've downloaded. Any help would be great

    did you try the PlayBack preset/template?
    once you open the PlayBack plug-in you just load the tracks from the plug-in's menu.

  • Hi, I recently changed my username for my iTunes/iCloud account. Can anyone tell me how i change the username on my iCloud iPad? When I go onto setting to change it it keeps the username grey so I can't even select it?

    Hi, I recently changed my username for my iTunes/iCloud account. Can anyone tell me how i change the username on my iCloud iPad? When I go onto setting to change it it keeps the username grey so I can't even select it?

    Welcome to the Apple Community.
    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    Providing you are simply updating your existing details and not changing to another account, when you delete your account, all the data that is synced with iCloud will also be deleted from the device (but not from iCloud), but will be synced back to your device when you login again.
    In order to change your Apple ID or password for your iCloud account on your computer, you need to sign out of the account from your computer first, then sign back in using your updated details. (System Preferences > iCloud, click the sign out button)
    In order to change your Apple ID or password for your iTunes account on your iOS device, you need to sign out from your iOS device first, then sign back in using your updated details. (Settings > iTunes & App store, scroll down and tap your ID)
    If you are using iMessages or FaceTime, you will also need to log out and into your ID there too.

  • HT1391 Hi can anyone tell me how to find out what and when my last purchases were made from the App Store ? I think my kids used all my credit

    Hi can anyone tell me how to find out what and when my last purchases were made from the App Store ? I think my kids used all my credit

    .from iTunes, go to View > Show sidebar
    From sidebar > Itunes Store > Click top left on your Apple ID email address > Account > ...scroll down > Purchase History > View All

  • Can anyone tell me how to check the balance on an iTunes gift card that is not yet scratched?

    Can anyone tell me how to check the balance on an iTunes gift card that is not yet scratched or activated?

    If it's not printed on the card, then you'll need to check the receipt from the purchase of the card. There's no way to check the value from the card itself without redeeming it.
    Regards.

  • The option to sync apps is no longer available in iTunes, though it used to be. Can anyone tell me how to access the sync apps button please?

    Can anyone tell me how to access the sync apps button please? I used to be able to select it but it is no longer visible.

    You have to connect and select iPhone in computer iTunes Sidebar.
    If you don't see the Sidebar, toggle it on in iTunes menu View > Show Sidebar.
    Take a look at this screenshot on updating apps.

  • Hi, since the last update i find my rented movies remained under rented although unplayable. now i find some, as before the update, are deleting fully - can anyone tell me how to delete the unwatchable covers that remain?

    hi, since the last update i find my rented movies remained under rented although unplayable. now i find some, as before the update, are deleting fully - can anyone tell me how to delete the unwatchable covers that remain?

    bunjamin wrote:
    There is now a new line in BBM that wasn't there before which covers the message that I am typing, so I can't actually see what I am typing.
    Hi bunjamin,
    just go to BlackBerry World, and update all your apps including BBM.
    bunjamin wrote:
    Every time I unlock my phone, my screen enlarges so I can't really see much on the hub/notification screen and it defaults to the hub which it didn't do before).
    you can turn off the magnifying glass :
    device settings >> accessibility >> magnify mode >> OFF
    you can deactivate the "reset to Hub view" :
    hub >> overflow (bottom right button) >> Settings >> Display and actions >> Return to Default View When Idle >> OFF
    bunjamin wrote:
    my ringtone is much softer than it was previously
    yes, BlackBerry has acknowledged this bug in this article from the public knowledge base:
    KB36755 After upgrading BlackBerry 10 OS to version 10.3.1 the volume for notifications is noticed to be significantly lower than in the previous version
    The search box on top-right of this page is your true friend, and the public Knowledge Base too:

  • Can anyone tell me how to setup odbc driver and configure in the setup

    Can anyone tell me how to setup odbc driver and configure in the setup

    You can't switch languages in OS X programs, just in the OS itself. Insert the Leopard OS X disc, and choose your new preferred language when prompted.

  • I used a terminal command to show the Library in the User folder, and now the Finder is behaving erractically.  Can anyone tell me how to reverse the show library terminal command?

    I used a terminal command in Lion to show the LIbrary in the Users folder, and now the Finder is behaving erratically, hanging up and becoming almost paralyzed.  Can anyone tell me how to reverse the terminal command for show Library.  The command I used was:
    chflags nohidden ~/Library/

    Showing the Library folder will not cause the problem you've described. Nevertheless:
    chflags hidden ~/Library
    will hide the folder. To reveal the folder:
    chflags nohidden ~/Library
    Note, there is no "/" after Library.

  • Can anyone tell me how to change the language in the app store?

    can anyone tell me how to change the language in the app store?

    But before making the upgrade to Ios 5 I was able to have the iTunes in italian (since in Switzerland we speak german, french and italian) but now only the blody german is available, i can change the IPAD language to italian or english but the iTunes dont change .... so pist off... i cannot use it!!!!!

  • Please can anyone tell me how to download the flash player to allow virgin anytime on ipad3

    Hi There,
    Please can anyone tell me how to update the flash player on ipad3 to allow virgin anytime to play?
    Regards
    Gary

    Adobe has not made a version of Flash for the iPad.
    Kappy explains why. https://discussions.apple.com/message/19446567#19446567
    5 Flash Player Alternatives http://www.techshout.com/features/2011/01/flash-player-for-ipad-apps/
    Top 4 browsers supports flash player on iPad and iPhone
    http://mashtips.com/flash-player-ios/
     Cheers, Tom

  • Can anyone tell me how to change the names of the networks I have set up on Airport Express

    Can anyone tell me how to change the names of the networks I have set up on Airport Express please? I now work in a UN compound and my network is my own name, would prefer some anonymity so seeking to change the wifi network name that others might see.

    Hi mkl1961,
    Happy Holidays!  The article below will explain how to reset your Airport Express and change the network and base station names back to their defaults.  
    Resetting an AirPort base station FAQ - Apple Support
    http://support.apple.com/en-us/HT3728
    What default settings will my AirPort base station have after a hard or factory default reset?
    AirPort base stations are set to request an IP address by DHCP.
    AirPort base station passwords are "public."
    AirPort base station names revert to "base station xxxxxx," where xxxxxx is the last six digits of the wireless MAC address*.
    AirPort base station network names are "Apple Network xxxxxx," where xxxxxx is the last six digits of the wireless MAC address*.
    *A MAC (Media Access Control) address, also known as a "network ID," is a unique hardware identification number for a network port.  You can find the wireless and Ethernet network IDs on the printed label on the bottom or side of the device.
    Airport Express Setup Guide
    manuals.info.apple.com/MANUALS/1000/MA1613/en_US/airport_express_80211n_2nd_gen _setup_guide.pdf
    I hope this information helps ....
    - Judy

  • Can anyone tell me how to remove the owner when setting the location

    Hello,
    Can anyone tell me how to remove the owner when setting the location?
    Properties
       Table Name:  (Table Name)
       Table Type:   Tables
       Owner:           Public
       Overridden Qualified Table Name:  (Table Name - same as above)
    Any help would be appreciated.
    Thanks
    Ann

    Hi Ann,
    please check this document to determine the correct space for your question:
    Find Topic Spaces on SCN (Forums)
    If you need help moving it, let me know!
    Thanks,
    Kristen

  • I installed OSX server 10.6 snow leopard on my IMAC, but still have choppy videos. can anyone tell me how to fix the problem

    I installed OSX server 10.6 snow leopard on my IMAC, but still have choppy videos. can anyone tell me how to fix the problem

    By your use of "still", did this problem exist before OS X Server was installed?  OS X Server itself has no particular linkages to video processing, beyond what OS X client provides.
    Some details on the configuration might be useful.  Are these videos you're having issues with stored locally in files, or are these videos received over the network and played?  If the videos are local, have you tried playing the videos from a different disk?  If the video files are remote, can you download the videos and play them as a test?
    What software are you using to play the videos?  QuickTime?  QuickTime X?  Does using VLC or another player work better?  There are some discussions of choppy videos around the forums, too.

  • I bought an apple iphone4 from a friend and they had lost and dont remember the apple id nor password can some tell me how to reset the phone and or both

    I bought an apple iphone4 from a friend and they had lost and dont remember the apple id nor password can some tell me how to reset the phone and or both

    It is not possible. You have hit Activation Lock, an anti theft measure. The last owner is the only one who can unlock it with their Apple ID. Tell them to go here
    https://iforgot.apple.com/
    Cheers
    Pete

Maybe you are looking for

  • Where are my photos? Old and new missing.

    I'm not very tech savvy so I apologize in advance. But I recently signed up on icloud.com. Before this, I had to change my appleID in the photo stream (on my phone) because it wasn't matching. All is well after that except all of the old photos I had

  • Manual transfer problems

    Sometimes, when I'm clicking and dragging songs manually from i-tunes to the ipod, i get a "not allowed" symbol (circle with a diagonal line) as I move it over the ipod line, and it won't allow me to make the transfer. Almost all the other songs will

  • Oracle 8.1.6, slow performance using XSU

    Hi, We have a problem with some queries running in our production environment. When we run them directly through sqlplus they take milliseconds, however when we pass them through our wrapper to the XSU, they can take 5 or 6 seconds to return. The typ

  • Here is how to use the no of months in warranty transaction BGM2

    REPORT  ZSDCONVERT data : char_value(10). data : fltp type f . data : fltp1 like fltp. data : decimals like t006-DECAN value 15 . from char to floating point                call function 'CHAR_FLTP_CONVERSION_TO_SI'                 EXPORTING         

  • Printing and email script/button

    I have a form that will be deployed out to employee's laptops that they will use to generate a quote to customers. I need a button that will print the said form as a static pdf document (none of the controls are active that can change the price) and