How to add ViewerComponent to JPanel?

Have jReality programming problems or questions? Post them here.
Post Reply
karunaMaitri
Posts: 90
Joined: Sun 16. Nov 2008, 00:24

How to add ViewerComponent to JPanel?

Post by karunaMaitri » Mon 30. May 2011, 10:18

Hi,

I need to add multiple "ViewingComponents", created from different Viewers,
to a JFrame object. When I tried to do it using a JPanel to each ViewingComponent,
and then adding it to another JPanel (mainPanel), and finally adding it to a JFrame
gives me a blank window.

You can reproduce the result by doing the following simple experiment on the
ViewerFromScratch tutorial in Viewers section. Insert the following code after the
toolSystem is initialized.

Code: Select all

JPanel panel = new JPanel();
panel.add((Component) viewer.getViewingComponent());
Then to the "frame" add this panel (instead of ViewingComponent).

Code: Select all

frame.getContentPane().add(panel);
Any suggestions are most welcome.

I need to add several ViewingComponents to JFrame. Is there
another way to do it?

Many Thanks!
Karuna

karunaMaitri
Posts: 90
Joined: Sun 16. Nov 2008, 00:24

Re: How to add ViewerComponent to JPanel?

Post by karunaMaitri » Tue 31. May 2011, 00:56

I solved the problem by using startupLocal() method of JRViewer, which produces
JRootPane object.

Thanks!
Karuna

Post Reply