Hello!

I try to paint a filled oval on the glasspane, but it doesn't seems to work.

This works on a regular JFrame but doesn't seems to work on a JMainFrame
even do it extends from JFrame.

My code to test my attemtp is below.

So if any one could give me a hint or solution for this it would be great.

The reason for this is to paint a aim like a haircross in a 3D-world. So
perhaps someone got a better strategy for this.

Best regards
Fredrik

//The glasscomponent

import java.awt.*;

public class AimPane extends JComponent
{
    int x;
    int y;

    public AimPane(int x, int y)
    {
        this.x = x;
        this.y = y;
        setVisible(true);
        repaint();
    }

    protected void paintComponent(Graphics g)
    {
        g.setColor(Color.blue);
        g.fillOval(x, y, 20, 20);
    }
}

//The class to run this
import java.applet.*;
import java.awt.*;
import java.awt.Frame;
import java.awt.event.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.behaviors.keyboard.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import javax.swing.*;

import java.util.*;

import com.sun.j3d.utils.applet.*;




public class TestAimPane extends Applet
{
        Canvas3D canvas3D;
        SimpleUniverse simpleUniverse;

        public void init()
        {
                long start = System.currentTimeMillis();
                setLayout(new BorderLayout());
                GraphicsConfiguration config = 
SimpleUniverse.getPreferredConfiguration();
                canvas3D = new Canvas3D(config);
                add("Center", canvas3D);
                simpleUniverse = new SimpleUniverse(canvas3D);

                TransformGroup transformGroup = new TransformGroup();
                Transform3D transform3D = new Transform3D();
                transform3D.setTranslation( new Vector3d( 0.0, 0.0, -8.0 ) );
                transformGroup.setTransform(transform3D);
                transformGroup.addChild(new ColorCube());

                BranchGroup branchGroup = new BranchGroup();
                branchGroup.addChild(transformGroup);

                simpleUniverse.addBranchGraph( branchGroup );

                long end = System.currentTimeMillis();
                System.out.println((end-start)/1000);
        }


        public static void main(String[] args)
        {
                JMainFrame jMainFrame = new JMainFrame(new TestAimPane(), 700, 300);
                Dimension dimension = jMainFrame.getToolkit().getScreenSize();
                Rectangle bounds = jMainFrame.getBounds();
                jMainFrame.setBounds( (dimension.width - bounds.width) / 2,
(dimension.height - bounds.height) / 2, 700, 300);
                AimPane aimPane = new AimPane(bounds.width/2, bounds.height/2);
                jMainFrame.setGlassPane(aimPane);
                aimPane.setVisible(true);

                try
                {
                        java.awt.Robot robot = new java.awt.Robot();
                        robot.mouseMove(dimension.width/2,dimension.height/2);
                }
                catch(Exception e)
                {
                }

    }

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to