Hi Jimmy,

Thank you for your advice. I was encoureged by your explanation
and was able to solve the problem. However, I think it is important
to know WHICH heavyweight component should be used to add Swing
component to it.

You cannot use Frame, because you cannot add Window to Window. I used
AWT Panel and it worked. I decided to write about it because almost
all examples which I saw subclassed Applet and used special method
MainFrame() to run the applet as application. I think it is quite
inconvenient - to use Frame is much more common.

Here is the code snippet:

public class MyAxisApp extends Frame
{
  static Canvas3D canvas3D;
...........................
 public static void main(String[] args)
  {
    Frame frame = new Frame();

    frame.addWindowListener(new WindowAdapter()
    {
      public void windowClosing(WindowEvent event)
      {
        System.exit(0);
      }
    });

    canvas3D = new Canvas3D(null);
    canvas3D.setBounds(0, 0, 128, 128);
    MyAxisApp MyAxisApp = new MyAxisApp();

    DisplayImageJPanel displayImageJPanel = new DisplayImageJPanel(); //
Swing component

    int createImageFlag = displayImagePanel.CreateImage();

    Panel contentPanel = new Panel();

    contentPanel.add(displayImagePanel);

    frame.add(canvas3D);
    frame.add(contentPanel);
    frame.setVisible(true);
    frame.validate();
  }
}

Regards,

Jacob Nikom


Jimmy Talbot wrote:
>
> Hi,
>
> > I am trying to work with Java3D and Swing on Linux. I was able to
> > run some 3D programs but stuck when I tried to place JPanel and
> > Canvas3D on the same Frame.
>
> I was faced with the same problem; You can put them in the same frame, but
> you have to put your swing components in their own heavyweight object
> which you then put in the same frame as the other heavyweight
> objects. That seems to work pretty good for me. Please let me know if you
> find a better solution :)
>
> Jimmy
>
> ===========================================================================
> 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".

===========================================================================
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