PDA

View Full Version : GL4Java in a JFrame



01-12-2004, 05:35 AM
Hi all, i'm trying to design a program in java that draws a simple shape (rectangle, triangle or circle) then the user can choose to translate, scale or rotate that shape.. I created two classes: Transformations and OpenGLPart, the Transformations class is a JFrame containing the control panel for the user and a component with the size of 400x400 in which the openGL part is supposed to appear, and the OpenGLPart class contains the openGL code..

There is a button called applyButton in the control panel, when clicked, the values for scaling, rotating, translating and the required shape are stored then a new object from class OpenGLPart is created with these values as constructor parameters, here's the code:

void draw() {

translateX = (float)(translateXSlider.getValue());
translateY = (float)(translateYSlider.getValue());
scaleX = (float)(scaleXSlider.getValue());
scaleY = (float)(scaleYSlider.getValue());
rotate = Float.parseFloat(rotateField.getText());

OpenGLPart ogl = new OpenGLPart(shape, translateX, translateY, scaleX, scaleY, rotate);

canvas = (Component)(ogl);

layout.add(canvas , BorderLayout.CENTER);

contents.revalidate();
}


The problem is.. nothing shows.. only empty space.. can anyone help me please?

Thanks a lot