# JOGL / OPENGL in Frame



## Ya-Sin (8. Apr 2010)

Hilfe: JOGL / OPENGL in Frame
Hallo,

Ich habe angefangen ein Programm zu schreiben, bei dem ich ein Koordinatensystem zeichne und ein Würfel drin habe. Dieses Fenster habe ich in ein Frame eingebaut. Ich habe 3 Schieberegler eingebaut in den Frame, mitdem ich mein Korrdinatensystem in dem gewünschten Winkel verdrehen kann.

Jedoch besteht mein Problem darin, das ich nicht vom Hauptfenster in den Panel zugreifen kann...
Ich möchte die Parameter durch get- und set-Methoden zu display() schicken, jedoch kann ich nicht auf die Methoden zugreifen. 


```
package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.EventQueue;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLJPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

/**
*
* @author cylab
* @author mbien
*/
public class SimpleGLJPanel extends JFrame implements MouseListener {

private Animator animator;

/** Creates new form MainFrame */
public SimpleGLJPanel() {
initComponents();
setTitle("Simple JOGL Application");

panel.addGLEventListener(new GLRenderer());
animator = new Animator(panel);

this.addWindowListener(new WindowAdapter() {

@Override
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();
}
});
}

@Override
public void setVisible(boolean show){
if(!show)
animator.stop();
super.setVisible(show);
if(!show)
animator.start();
}

/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
JLabel label = new JLabel();
panel = new GLJPanel(createGLCapabilites());
jSlider1 = new JSlider();

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

label.setText("Below you see a GLJPanel");

GroupLayout panelLayout = new GroupLayout(panel);
panel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(
panelLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 458, Short.MAX_VALUE)
);
panelLayout.setVerticalGroup(
panelLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 257, Short.MAX_VALUE)
);

GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label)
.addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(125, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(label)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap(120, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

/**
* Called from within initComponents().
* hint: to customize the generated code choose 'Customize Code' in the contextmenu
* of the selected UI Component you wish to cutomize in design mode.
* @return Returns customized GLCapabilities.
*/
private GLCapabilities createGLCapabilites() {

GLCapabilities capabilities = new GLCapabilities();
capabilities.setHardwareAccelerated(true);

// try to enable 2x anti aliasing - should be supported on most hardware
capabilities.setNumSamples(2);
capabilities.setSampleBuffers(true);

return capabilities;
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
// Run this in the AWT event thread to prevent deadlocks and race conditions

// panel.addKeyListener();

EventQueue.invokeLater(new Runnable() {
public void run() {

// switch to system l&f for native font rendering etc.
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception ex) {
Logger.getLogger(getClass().getName()).log(Level.INFO, "can not enable system look and feel", ex);
}

SimpleGLJPanel frame = new SimpleGLJPanel();
frame.setVisible(true);
}
});
}

// Variables declaration - do not modify
private JSlider jSlider1;
private GLJPanel panel;
// End of variables declaration

public void mouseClicked(MouseEvent e) {
int i = e.getX();

System.out.println(i);
}

public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

} [/TABLE]



[TABLE]package org.yourorghere;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;


/**
* GLRenderer.java <BR>
* author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
*
* This version is equal to Brian Paul's version 1.2 1999/10/21
*/
public class GLRenderer implements GLEventListener, KeyListener, MouseListener {





public static void main(String[] args) {
Frame frame = new Frame("Simple JOGL Application");
GLCanvas canvas = new GLCanvas();

canvas.addGLEventListener((GLEventListener) new SimpleGLJPanel());
frame.add(canvas);
frame.setSize(640, 480);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {

@Override
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();
}
});
// Center frame
frame.setLocationRelativeTo(null);
frame.setVisible(true);
animator.start();
}




public void init(GLAutoDrawable drawable) {
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));

GL gl = drawable.getGL();

drawable.addKeyListener(this);
drawable.addMouseListener(this);

// Setup the drawing area and shading mode
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glEnable(gl.GL_DEPTH_TEST);
gl.glClearDepth(1.0);
gl.glDepthFunc(GL.GL_LESS);
}

public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL gl = drawable.getGL();
GLU glu = new GLU();
gl.glViewport(x,y,width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();


if (width <= height) {

gl.glOrtho(-2,2,-2*((double) height)/(double) width,2*((double) height)/(double)width,-5,5);
}
else{ gl.glOrtho( -2*((double) width)/(double) height ,2*((double)width )/(double)height,-2,2,-5,5);}


gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(0.5, 0.5, 0.5, 0, 0, 0, 0, 1, 0);
}

public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GLUT glut = new GLUT();
for(int i = 0; i < 6; i++) {
gl.glPushMatrix();

//gl.glRotatef(viewRotX, 1.0f, 0.0f, 0.0f);
//gl.glRotatef(viewRotY, 0.0f, 1.0f, 0.0f);

gl.glColor3f(1.0f,1.0f,1.0f);
glut.glutWireCube(0.8f);

gl.glColor3f(1.0f, 0.5f, 0.0f); // ORANGE
if (i < 4) {gl.glRotatef(i * 90.0f, 0.0f, 1.0f, 0.0f);}
if (i == 4) {gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);}
if (i == 5) {gl.glRotatef(90.0f,-1.0f, 0.0f, 0.0f);}
gl.glTranslatef(0.0f, 0.0f, 1.5f);
gl.glBegin(GL.GL_LINES); {
gl.glVertex3f( 0.0f, 0.0f, 0.0f);
gl.glVertex3f( 0.0f, 0.0f,-1.5f);}
gl.glEnd();
glut.glutWireCone(0.05f, 0.25f, 10, 5);
gl.glRasterPos3f(-0.1f, 0.1f, 0.4f);




switch (i) {
case 0: drawText("Z"); break;
case 1: drawText("X"); break;
case 2: drawText("-Z"); break;
case 3: drawText("-X"); break;
case 4: drawText("-Y"); break;
case 5: drawText("Y"); break;
}
gl.glPopMatrix();
}
}

private void drawText (String text){
GLUT glut = new GLUT();
for (int i = 0; i < text.length(); i++)
{ glut.glutBitmapCharacter(GLUT.BITMAP_9_BY_15, text.charAt(i));}}

public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}

public void keyTyped(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void keyPressed(KeyEvent e) {


System.out.println("38");



}

public void keyReleased(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseClicked(MouseEvent e) {
int i = e.getX();

System.out.println(i);

}

public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

//public class MyGLEventListener Implements GLEventListener, KeyListener {
//
//
//}



}
```


----------



## Marco13 (8. Apr 2010)

```
class Hauptfenster
{
    private Panel panel;
    
    public void setPanel(Panel panel) { this.panel = panel; }

    void machWas()
    {
        panel.machWas();
    }
}

...

hauptfenster.setPanel(panel);
hauptfenster.machWas();
```


----------



## Ya-Sin (8. Apr 2010)

???:bahnhof:


----------



## Ya-Sin (8. Apr 2010)

Das Programm soll folgendermaßen aussehen:
Ein Frame, der ein Panel enthält. Unter dem Panel sind 3 Schieberegler angebracht und im Panel soll ein Koordinatensystem (3D) gezeichnet werden
und im Korrdinatensystem soll im Ursprung ein Würfel gezeichnet werden. Dieser Würfel soll dann im Verlauf dann durch die Schieberegler drehbar sein.
Jeder Schieberegler soll den Würfel um eine Achse drehen.

so ist es gedacht... kann mir jem vll eine alternative geben???
das ist echt dringend

danke im vorraus


----------



## Marco13 (8. Apr 2010)

Eine unspezifische Frage, mit 380 Zeilen Quellcode... :bahnhof:

Man speichert sich irgendwo eine Referenz auf den "GLRenderer", hängt einen ChangeListener an den Slider, und gibt den Wert aus dem Slider an den GLRenderer weiter... Mehr sollte der erste Codeschnipsel nicht aussagen.


import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import java.awt.Frame;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

import com.sun.opengl.util.Animator;
import java.awt.EventQueue;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLJPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.event.*;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

/**
*
* @author cylab
* @author mbien
*/
public class SimpleGLJPanel extends JFrame implements MouseListener {

private Animator animator;
 float _;
 GLRenderer __;

/** Creates new form MainFrame */
public SimpleGLJPanel() {
initComponents();
jSlider1.addChangeListener(new ChangeListener()
{
    @Override
    public void stateChanged(ChangeEvent e)
    {__._(jSlider1.getValue() / 100.0f);repaint();
        // TODO Auto-generated method stub
    }});
setTitle("Simple JOGL Application");
__ =new GLRenderer();
panel.addGLEventListener(__);
animator = new Animator(panel);

this.addWindowListener(new WindowAdapter() {

@Override
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();
}
});
}

@Override
public void setVisible(boolean show){
if(!show)
animator.stop();
super.setVisible(show);
if(!show)
animator.start();
}

/** 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
JLabel label = new JLabel();
panel = new GLJPanel(createGLCapabilites());
jSlider1 = new JSlider();

setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

label.setText("Below you see a GLJPanel");

GroupLayout panelLayout = new GroupLayout(panel);
panel.setLayout(panelLayout);
panelLayout.setHorizontalGroup(
panelLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 458, Short.MAX_VALUE)
);
panelLayout.setVerticalGroup(
panelLayout.createParallelGroup(Alignment.LEADING)
.addGap(0, 257, Short.MAX_VALUE)
);

GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(Alignment.LEADING)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addComponent(label)
.addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addContainerGap(125, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(label)
.addPreferredGap(ComponentPlacement.RELATED)
.addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addContainerGap(120, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

/**
* Called from within initComponents().
* hint: to customize the generated code choose 'Customize Code' in the contextmenu
* of the selected UI Component you wish to cutomize in design mode.
* @return Returns customized GLCapabilities.
*/
private GLCapabilities createGLCapabilites() {

GLCapabilities capabilities = new GLCapabilities();
capabilities.setHardwareAccelerated(true);

// try to enable 2x anti aliasing - should be supported on most hardware
capabilities.setNumSamples(2);
capabilities.setSampleBuffers(true);

return capabilities;
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
// Run this in the AWT event thread to prevent deadlocks and race conditions

// panel.addKeyListener();

EventQueue.invokeLater(new Runnable() {
public void run() {

// switch to system l&f for native font rendering etc.
try{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}catch(Exception ex) {
Logger.getLogger(getClass().getName()).log(Level.INFO, "can not enable system look and feel", ex);
}

SimpleGLJPanel frame = new SimpleGLJPanel();
frame.setVisible(true);
}
});
}

// Variables declaration - do not modify
private JSlider jSlider1;
private GLJPanel panel;
// End of variables declaration

public void mouseClicked(MouseEvent e) {
int i = e.getX();

System.out.println(i);
}

public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

}


/**
* GLRenderer.java <BR>
* author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
*
* This version is equal to Brian Paul's version 1.2 1999/10/21
*/
class GLRenderer implements GLEventListener, KeyListener, MouseListener {



 float ì;
void _(float í) { ì = í; }  
public static void main(String[] args) {
Frame frame = new Frame("Simple JOGL Application");
GLCanvas canvas = new GLCanvas();

canvas.addGLEventListener((GLEventListener) new SimpleGLJPanel());
frame.add(canvas);
frame.setSize(640, 480);
final Animator animator = new Animator(canvas);
frame.addWindowListener(new WindowAdapter() {

@Override
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();
}
});
// Center frame
frame.setLocationRelativeTo(null);
frame.setVisible(true);
animator.start();
}




public void init(GLAutoDrawable drawable) {
// Use debug pipeline
// drawable.setGL(new DebugGL(drawable.getGL()));

GL gl = drawable.getGL();

drawable.addKeyListener(this);
drawable.addMouseListener(this);

// Setup the drawing area and shading mode
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
gl.glEnable(gl.GL_DEPTH_TEST);
gl.glClearDepth(1.0);
gl.glDepthFunc(GL.GL_LESS);
}

public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
GL gl = drawable.getGL();
GLU glu = new GLU();
gl.glViewport(x,y,width, height);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();


if (width <= height) {

gl.glOrtho(-2,2,-2*((double) height)/(double) width,2*((double) height)/(double)width,-5,5);
}
else{ gl.glOrtho( -2*((double) width)/(double) height ,2*((double)width )/(double)height,-2,2,-5,5);}


gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(0.5, 0.5, 0.5, 0, 0, 0, 0, 1, 0);
}

public void display(GLAutoDrawable drawable) {
GL gl = drawable.getGL();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GLUT glut = new GLUT();
for(int i = 0; i < 6; i++) {
gl.glPushMatrix();

//gl.glRotatef(viewRotX, 1.0f, 0.0f, 0.0f);
//gl.glRotatef(viewRotY, 0.0f, 1.0f, 0.0f);

gl.glColor3f(1.0f,1.0f,1.0f);
glut.glutWireCube(0.8f);

gl.glColor3f(1.0f, 0.5f, 0.0f); // ORANGE
if (i < 4) {gl.glRotatef(i * 90.0f+ì*90, 0.0f, 1.0f, 0.0f);}
if (i == 4) {gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);}
if (i == 5) {gl.glRotatef(90.0f,-1.0f, 0.0f, 0.0f);}
gl.glTranslatef(0.0f, 0.0f, 1.5f);
gl.glBegin(GL.GL_LINES); {
gl.glVertex3f( 0.0f, 0.0f, 0.0f);
gl.glVertex3f( 0.0f, 0.0f,-1.5f);}
gl.glEnd();
glut.glutWireCone(0.05f, 0.25f, 10, 5);
gl.glRasterPos3f(-0.1f, 0.1f, 0.4f);




switch (i) {
case 0: drawText("Z"); break;
case 1: drawText("X"); break;
case 2: drawText("-Z"); break;
case 3: drawText("-X"); break;
case 4: drawText("-Y"); break;
case 5: drawText("Y"); break;
}
gl.glPopMatrix();
}
}

private void drawText (String text){
GLUT glut = new GLUT();
for (int i = 0; i < text.length(); i++)
{ glut.glutBitmapCharacter(GLUT.BITMAP_9_BY_15, text.charAt(i));}}

public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
}

public void keyTyped(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void keyPressed(KeyEvent e) {


System.out.println("38");



}

public void keyReleased(KeyEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseClicked(MouseEvent e) {
int i = e.getX();

System.out.println(i);

}

public void mousePressed(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseReleased(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseEntered(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

public void mouseExited(MouseEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}

//public class MyGLEventListener Implements GLEventListener, KeyListener {
//
//
//}



}



(Ohne Code-Tags, natürlich  )


----------



## Ya-Sin (8. Apr 2010)

da liegt das problem... 
 panel.setMethode(ZAHL) funktioniert irgendwie nicht auf dem hauptfenster...


----------



## Ya-Sin (8. Apr 2010)

So sieht mein programm aus und das problem liegt bei der SET-Methode...



```
/*
 * SimpleGLJPanel.java
 *
 * Created on 30. Juli 2008, 16:18
 */

package org.yourorghere;

import com.sun.opengl.util.Animator;
import java.awt.EventQueue;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLJPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

/**
 *
 * @author cylab
 * @author mbien
 */
public class SimpleGLJPanel extends JFrame {

    private Animator animator;

    /** Creates new form MainFrame */
    public SimpleGLJPanel() {
        initComponents();
        setTitle("Simple JOGL Application");

        panel.addGLEventListener((GLEventListener) new SimpleJOGLTest1());
        animator = new Animator(panel);


        this.addWindowListener(new WindowAdapter() {

            @Override
            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();
            }
        });
    }

    @Override
    public void setVisible(boolean show){
        if(!show)
            animator.stop();
        super.setVisible(show);
        if(!show)
            animator.start();
    }

    /** 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {
        JLabel label = new JLabel();
        panel = new GLJPanel(createGLCapabilites());
        jSlider1 = new JSlider();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        addKeyListener(new KeyAdapter() {
            public void keyTyped(KeyEvent evt) {
                formKeyTyped(evt);
            }
        });

        label.setText("Below you see a GLJPanel");

        panel.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent evt) {
                panelMousePressed(evt);
            }
        });
        panel.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent evt) {
                panelMouseDragged(evt);
            }
        });

        GroupLayout panelLayout = new GroupLayout(panel);
        panel.setLayout(panelLayout);
        panelLayout.setHorizontalGroup(
            panelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 458, Short.MAX_VALUE)
        );
        panelLayout.setVerticalGroup(
            panelLayout.createParallelGroup(Alignment.LEADING)
            .addGap(0, 257, Short.MAX_VALUE)
        );

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(Alignment.LEADING)
                    .addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addComponent(label)
                    .addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                .addContainerGap(125, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(panel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jSlider1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(122, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    private void formKeyTyped(KeyEvent evt) {                              
        // TODO add your handling code here:
    }                             

    private void panelMousePressed(MouseEvent evt) {                                   

        int zahl = evt.getX();
        panel.setZahl(zahl);
        
    }                                  

    private void panelMouseDragged(MouseEvent evt) {                                   


        





           


        // TODO add your handling code here:
    }                                  

    /**
     * Called from within initComponents().
     * hint: to customize the generated code choose 'Customize Code' in the contextmenu
     * of the selected UI Component you wish to cutomize in design mode.
     * @return Returns customized GLCapabilities.
     */
    private GLCapabilities createGLCapabilites() {
        
        GLCapabilities capabilities = new GLCapabilities();
        capabilities.setHardwareAccelerated(true);

        // try to enable 2x anti aliasing - should be supported on most hardware
        capabilities.setNumSamples(2);
        capabilities.setSampleBuffers(true);
        
        return capabilities;
    }
    
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        // Run this in the AWT event thread to prevent deadlocks and race conditions
        EventQueue.invokeLater(new Runnable() {
            public void run() {
                
                // switch to system l&f for native font rendering etc.
                try{
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                }catch(Exception ex) {
                    Logger.getLogger(getClass().getName()).log(Level.INFO, "can not enable system look and feel", ex);
                }
                
                SimpleGLJPanel frame = new SimpleGLJPanel();
                frame.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private JSlider jSlider1;
    private GLJPanel panel;
    // End of variables declaration                   

public int zahl;

    
//    public float dragStartX, dragStartY, viewRotY, viewRotX;
//    public boolean showCube;
}
```



```
package org.yourorghere;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;



/**
 * SimpleJOGLTest1.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel) <P>
 *
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */
public class SimpleJOGLTest1 implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGLTest1());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            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();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }


    public void init(GLAutoDrawable drawable) {
        // Use debug pipeline
        // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
        gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see what happens.
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) {
        GL gl = drawable.getGL();
        GLU glu = new GLU();
        gl.glViewport(x,y,width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();


        if (width <= height) {

            gl.glOrtho(-2,2,-2*((double) height)/(double) width,2*((double) height)/(double)width,-5,5);
                   }
        else{           gl.glOrtho( -2*((double) width)/(double) height ,2*((double)width )/(double)height,-2,2,-5,5);}


        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
        glu.gluLookAt(0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
    }

    public void display(GLAutoDrawable drawable) {

        
        
        GL gl = drawable.getGL();

gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
GLUT glut = new GLUT();
gl.glColor3f(1.0f, 0.5f, 0.0f);
for(int i = 0; i < 6; i++) {
gl.glPushMatrix();


if (i < 4) {gl.glRotatef(i * 90.0f, 0.0f, 1.0f, 0.0f);}
if (i == 4) {gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);}
if (i == 5) {gl.glRotatef(90.0f,-1.0f, 0.0f, 0.0f);}
gl.glTranslatef(0.0f, 0.0f, 1.5f);
gl.glBegin(GL.GL_LINES); {
gl.glVertex3f( 0.0f, 0.0f, 0.0f);
gl.glVertex3f( 0.0f, 0.0f,-1.5f);}
gl.glEnd();
glut.glutWireCone(0.05f, 0.25f, 10, 5);
gl.glRasterPos3f(-0.1f, 0.1f, 0.4f);




switch (i) {
case 0: drawText("Z"); break;
case 1: drawText("X"); break;
case 2: drawText("-Z"); break;
case 3: drawText("-X"); break;
case 4: drawText("-Y"); break;
case 5: drawText("Y"); break;
}
gl.glPopMatrix();
}
}
private void drawText (String text){
        GLUT glut = new GLUT();
        for (int i = 0; i < text.length(); i++)
        { glut.glutBitmapCharacter(GLUT.BITMAP_9_BY_15, text.charAt(i));}}
    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) {
    }


    public int zahl;
    public void setZahl(int zahl){this.zahl=zahl;}
    public int getZahl(){return zahl;}

}
```


----------



## Marco13 (8. Apr 2010)

Das "Hauptfenster" ist (unpassenderweise) das SimpleGL*JPanel*. Das "Panel" ist (unpassenderweise) der GLRenderer. Trotzdem ist das, was jetzt dort steht (und was "funktioniert") strukturell ähnlich zu dem, was ich zuerst gepostet hatte - die Richtung könnte durch die Begriffe verhehrtrum gewesen sein, aber... naja.


```
public class SimpleGLJPanel .. // "Hauptfenster"
{
    private GLRenderer renderer; // "Panel"

    ....
    public SimpleGLJPanel() 
    {
        jSlider1.addChangeListener(new ChangeListener()
        {
            public void stateChanged(ChangeEvent e)
            {
                renderer.setAngleX(jSlider1.getValue() / 100.0f); // "MachWas"
                repaint();
             }
          });
     }
}


class GLRenderer // "Panel"
{
    private float angleX;
 
    public void setAngleX(float angleX)
    {
        this.angleX = angleX;
    }

    public void display(GLAutoDrawable drawable) 
    {
        ...
        gl.glRotatef(angleX, 1.0f, 0.0f, 0.0f);
    }
}
```

Versuche, dir klarzumachen, wie aufwändig es sein kann, aus 380 Zeilen unformatierten codes die Stellen rauszu_raten_ auf die sich so eine unpräzise Frage beziehen _könnte_. Wer hier antwortet, will im allgemeinen helfen, aber das ist eher ein "passives Wollen". Jemand der Hilfe will (aktiv) kann sich IMHO auch bemühen, es dem Antwortenden etwas leichter zu machen. Und das bezieht sich auch (aber nicht nur) auf die Punkte aus Wie man Fragen richtig stellt: eine Anleitung wie man Fragen erfolgreich in Usenet, Mailing Listen und Webforen stellt.


----------



## Marco13 (8. Apr 2010)

OK, die letzten Beiträge haben sich überschnitten. 

Es gibt jetzt eine neue Klasse, zwei main-Methoden, viel toten Code... und ohne dir zu nahe treten zu wollen: Wenn man versucht, auf einem GLJPanel eine Methode aufzurufen, die dort einfach nicht existiert, und dann (sehr indirekt, aber doch) fragt, warum das nicht funktioniert, kann man sich schon dir Frage stellen, ob man seine ersten Programmierschritte undbedingt mit JOGL machen sollte....


Die geänderten Zeilen sind mit "XXX" markiert. Sonst ist das so unübersichtlich :meld:

```
import com.sun.opengl.util.Animator;
import java.awt.EventQueue;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLJPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JSlider;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.UIManager;
import javax.swing.WindowConstants;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;

/**
 * SimpleJOGLTest1.java <BR>
 * author: Brian Paul (converted to Java by Ron Cemer and Sven Goethel)
 * <P>
 * 
 * This version is equal to Brian Paul's version 1.2 1999/10/21
 */
class SimpleJOGLTest1 implements GLEventListener
{
    public static void main(String[] args)
    {
        Frame frame = new Frame("Simple JOGL Application");
        GLCanvas canvas = new GLCanvas();

        canvas.addGLEventListener(new SimpleJOGLTest1());
        frame.add(canvas);
        frame.setSize(640, 480);
        final Animator animator = new Animator(canvas);
        frame.addWindowListener(new WindowAdapter()
        {

            @Override
            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();
            }
        });
        // Center frame
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        animator.start();
    }

    public void init(GLAutoDrawable drawable)
    {
        // Use debug pipeline
        // drawable.setGL(new DebugGL(drawable.getGL()));

        GL gl = drawable.getGL();
        System.err.println("INIT GL IS: " + gl.getClass().getName());

        // Enable VSync
        gl.setSwapInterval(1);

        // Setup the drawing area and shading mode
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glShadeModel(GL.GL_SMOOTH); // try setting this to GL_FLAT and see
                                       // what happens.
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width,
        int height)
    {
        GL gl = drawable.getGL();
        GLU glu = new GLU();
        gl.glViewport(x, y, width, height);
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        if (width <= height)
        {

            gl.glOrtho(-2, 2, -2 * ((double) height) / (double) width, 2 *
                ((double) height) / (double) width, -5, 5);
        }
        else
        {
            gl.glOrtho(-2 * ((double) width) / (double) height, 2 *
                ((double) width) / (double) height, -2, 2, -5, 5);
        }

        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();
        glu.gluLookAt(0.5f, 0.5f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);
    }

    public void display(GLAutoDrawable drawable)
    {

        GL gl = drawable.getGL();

        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
        GLUT glut = new GLUT();
        gl.glColor3f(1.0f, 0.5f, 0.0f);
        for (int i = 0; i < 6; i++)
        {
            gl.glPushMatrix();

            if (i < 4)
            {
                gl.glRotatef(i * 90.0f+zahl, 0.0f, 1.0f, 0.0f);
            }
            if (i == 4)
            {
                gl.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
            }
            if (i == 5)
            {
                gl.glRotatef(90.0f, -1.0f, 0.0f, 0.0f);
            }
            gl.glTranslatef(0.0f, 0.0f, 1.5f);
            gl.glBegin(GL.GL_LINES);
            {
                gl.glVertex3f(0.0f, 0.0f, 0.0f);
                gl.glVertex3f(0.0f, 0.0f, -1.5f);
            }
            gl.glEnd();
            glut.glutWireCone(0.05f, 0.25f, 10, 5);
            gl.glRasterPos3f(-0.1f, 0.1f, 0.4f);

            switch (i)
            {
            case 0:
                drawText("Z");
                break;
            case 1:
                drawText("X");
                break;
            case 2:
                drawText("-Z");
                break;
            case 3:
                drawText("-X");
                break;
            case 4:
                drawText("-Y");
                break;
            case 5:
                drawText("Y");
                break;
            }
            gl.glPopMatrix();
        }
    }

    private void drawText(String text)
    {
        GLUT glut = new GLUT();
        for (int i = 0; i < text.length(); i++)
        {
            glut.glutBitmapCharacter(GLUT.BITMAP_9_BY_15, text.charAt(i));
        }
    }

    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
        boolean deviceChanged)
    {
    }

    public int zahl;

    public void setZahl(int zahl)
    {
        this.zahl = zahl;
    }

    public int getZahl()
    {
        return zahl;
    }

}

/**
 * 
 * @author cylab
 * @author mbien
 */
class SimpleGLJPanel extends JFrame
{
    private SimpleJOGLTest1 test; // XXX
    
    private Animator animator;

    /** Creates new form MainFrame */
    public SimpleGLJPanel()
    {
        initComponents();
        setTitle("Simple JOGL Application");
        test = new SimpleJOGLTest1();// XXX
        panel.addGLEventListener(test);// XXX
        animator = new Animator(panel);

        this.addWindowListener(new WindowAdapter()
        {

            @Override
            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();
            }
        });
    }

    @Override
    public void setVisible(boolean show)
    {
        if (!show)
            animator.stop();
        super.setVisible(show);
        if (!show)
            animator.start();
    }

    /**
     * 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.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents()
    {
        JLabel label = new JLabel();
        panel = new GLJPanel(createGLCapabilites());
        jSlider1 = new JSlider();

        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        addKeyListener(new KeyAdapter()
        {
            public void keyTyped(KeyEvent evt)
            {
                formKeyTyped(evt);
            }
        });

        label.setText("Below you see a GLJPanel");

        panel.addMouseListener(new MouseAdapter()
        {
            public void mousePressed(MouseEvent evt)
            {
                panelMousePressed(evt);
            }
        });
        panel.addMouseMotionListener(new MouseMotionAdapter()
        {
            public void mouseDragged(MouseEvent evt)
            {
                panelMouseDragged(evt);
            }
        });

        GroupLayout panelLayout = new GroupLayout(panel);
        panel.setLayout(panelLayout);
        panelLayout.setHorizontalGroup(panelLayout.createParallelGroup(
            Alignment.LEADING).addGap(0, 458, Short.MAX_VALUE));
        panelLayout.setVerticalGroup(panelLayout.createParallelGroup(
            Alignment.LEADING).addGap(0, 257, Short.MAX_VALUE));

        GroupLayout layout = new GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(
                layout.createSequentialGroup().addContainerGap().addGroup(
                    layout.createParallelGroup(Alignment.LEADING).addComponent(
                        panel, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                        .addComponent(label).addComponent(jSlider1,
                            GroupLayout.PREFERRED_SIZE,
                            GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)).addContainerGap(125,
                    Short.MAX_VALUE)));
        layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
            .addGroup(
                layout.createSequentialGroup().addContainerGap().addComponent(
                    label).addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(panel, GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(jSlider1,
                        GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE).addContainerGap(122,
                        Short.MAX_VALUE)));

        pack();
    }// </editor-fold>

    private void formKeyTyped(KeyEvent evt)
    {
        // TODO add your handling code here:
    }

    private void panelMousePressed(MouseEvent evt)
    {

        int zahl = evt.getX();
        test.setZahl(zahl); // XXX
        repaint();

    }

    private void panelMouseDragged(MouseEvent evt)
    {

        // TODO add your handling code here:
    }

    /**
     * Called from within initComponents(). hint: to customize the generated
     * code choose 'Customize Code' in the contextmenu of the selected UI
     * Component you wish to cutomize in design mode.
     * 
     * @return Returns customized GLCapabilities.
     */
    private GLCapabilities createGLCapabilites()
    {

        GLCapabilities capabilities = new GLCapabilities();
        capabilities.setHardwareAccelerated(true);

        // try to enable 2x anti aliasing - should be supported on most hardware
        capabilities.setNumSamples(2);
        capabilities.setSampleBuffers(true);

        return capabilities;
    }

    /**
     * @param args
     *            the command line arguments
     */
    public static void main(String args[])
    {
        // Run this in the AWT event thread to prevent deadlocks and race
        // conditions
        EventQueue.invokeLater(new Runnable()
        {
            public void run()
            {

                // switch to system l&f for native font rendering etc.
                try
                {
                    UIManager.setLookAndFeel(UIManager
                        .getSystemLookAndFeelClassName());
                }
                catch (Exception ex)
                {
                    Logger.getLogger(getClass().getName()).log(Level.INFO,
                        "can not enable system look and feel", ex);
                }

                SimpleGLJPanel frame = new SimpleGLJPanel();
                frame.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify
    private JSlider jSlider1;
    private GLJPanel panel;
    // End of variables declaration

    public int zahl;

    // public float dragStartX, dragStartY, viewRotY, viewRotX;
    // public boolean showCube;
}
```


----------



## Ya-Sin (8. Apr 2010)

wenn du eine andere art kennst, 3d bilder zu machen, dann bitte...


----------



## Ya-Sin (8. Apr 2010)

Danke dir habs zum laufen bringen können 
:applaus:
Tut mir echt leid, bin neu hier... war am verzweifeln und hab mich deswegen hier angemeldet.

wie mache ich das am besten mit den schieberegler... wie bekomme ich es hin, das ich den schieberegler in 360° einteile ???


----------



## Marco13 (8. Apr 2010)

Ja, wie gesagt, für Fragen ist so ein Forum da. Aber bitte für _richtige_ Fragen, auf die man auch eine vernünftige Antwort geben kann 

Das [c]jSlider1 = new JSlider();[/c] erstellt einen JSlider, der standardmäßig von 0 bis 100 geht. 
Mit [c]jSlider1 = new JSlider(0,360,180);[/c] kann man einen erstellen, der von 0 bis 360 geht, und anfangs auf 180 steht. Das steht auch alles recht ausführlich hier How to Use Sliders (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)


----------

