[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

JOGL using NetBeans

Asked by jhshukla in NetBeans IDE, Java Programming Language, Java AWT & Swing

Tags: netbeans, jogl

I am trying to get familiar with JOGL but cannot seem to get around this little stumbling block. I downloaded demo code for the "Gears" demo from https://jogl-demos.dev.java.net/. The code works fine if used as is.

<<============ Trimmed version of the demo code =============>>
package joglapplication1;

/** imports and JavaDoc **/

public class Main implements GLEventListener, MouseListener, MouseMotionListener {
    public static void main (String[] args) {
        Frame frame = new Frame ("Gear Demo");
        GLCanvas canvas = new GLCanvas ();
       
        canvas.addGLEventListener (new Main ());
        frame.add (canvas);
        frame.setSize (300, 300);
        //final Animator animator = new Animator(canvas);
        frame.addWindowListener (new WindowAdapter () {
            public void windowClosing (WindowEvent e) {
                // Run this on another thread than the AWT event queue to
                // make sure the call to Animator.stop() completes before
                // exiting
                new Thread (new Runnable () {
                    public void run () {
                        //animator.stop();
                        System.exit (0);
                    }
                }).start ();
            }
        });
        frame.setVisible (true);
        //animator.start();
    }
   
    /** private variables **/

    public void init (GLAutoDrawable drawable) {...}
   
    public void reshape (GLAutoDrawable drawable, int x, int y, int width, int height) {...}
   
    public void display (GLAutoDrawable drawable) {...}
   
    public void displayChanged (GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {}
   
    public static void gear (GL gl, float inner_radius, float outer_radius, float width, int teeth, float tooth_depth) {...}
   
    // Methods required for the implementation of MouseListener
...
   
    // Methods required for the implementation of MouseMotionListener
...
}

As you can see, the GLCanvas is added to the Frame and occupies the whole display area. I want only a part of the frame to be displaying OpenGL stuff and want to use the rest for showing other information. So I create a custom class that extends JFrame; add a JPanel to it; and add GLCanvas to the JPanel instead to the form. Something great happens now and OpenGL stuff is nowhere to be seen.

To simplify stuff I removed the JPanel from MyFrame and added the GLCanvas directly to MyFrame. Still no result. Anyways, I finally figured that initComponents() being called from MyFrame ctor is the root cause because somehow it stops events from reaching the GLEventListener. I comment out the call to initComponents() and the wonderful gears show up. but then that defeats the whole purpose of the MyFrame and the GUI to design the form.

Here is the code for initComponents().
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                          
    private void initComponents() {
        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>                        

The code for MyListener is unchanged except that main() is moved to a different file. My guess is that setting layout causes the problems. Any ideas how to reopen the channel to GLEventListener?
[+][-]03/15/07 09:09 AM, ID: 18728102Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/15/07 04:44 PM, ID: 18731393Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03/15/07 07:27 PM, ID: 18732165Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: NetBeans IDE, Java Programming Language, Java AWT & Swing
Tags: netbeans, jogl
Sign Up Now!
Solution Provided By: jhshukla
Participating Experts: 1
Solution Grade: C
 
[+][-]03/15/07 08:08 PM, ID: 18732309Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/15/07 09:54 PM, ID: 18732613Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]03/19/07 04:42 AM, ID: 18747301Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091021-EE-VQP-81