I have exactly same issue with my code. Works on Windows flawlessly, but same problem on Mac OS X with Java 7 (I'm not able to test it with 1.6 to see if it's the same).
Here is the SSCCE which shows the bug
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.PixelFormat;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
// Must import the lwjgl Display class
public class LwjglTest extends JFrame {
public LwjglTest() throws LWJGLException {
this.setSize(500, 200);
this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
RealtimePanel rtCanvas = new RealtimePanel();
this.getContentPane().add(rtCanvas, BorderLayout.CENTER);
JButton btnTest = new JButton("test");
this.getContentPane().add(btnTest, BorderLayout.WEST);
JButton btnTest2 = new JButton("next test");
this.getContentPane().add(btnTest2, BorderLayout.NORTH);
this.pack();
}
public static void main(String args[]) {
try {
new LwjglTest();
} catch (LWJGLException ex) {
ex.printStackTrace();
}
}
private class RealtimePanel extends JPanel {
Thread gameThread;
boolean running = false;
Canvas canvas;
boolean resized = false;
boolean sleeping = false;
public RealtimePanel() {
setFocusable(true);
requestFocus();
setIgnoreRepaint(true);
canvas = new Canvas();
canvas.setIgnoreRepaint(true);
this.setLayout(new GridLayout());
this.add(canvas);
canvas.setFocusable(true);
canvas.setVisible(true);
canvas.requestFocus();
canvas.addComponentListener(new ComponentListener() {
@Override
public void componentResized(ComponentEvent e) {
synchronized (this) {
resized = true;
}
}
@Override
public void componentMoved(ComponentEvent e) {
synchronized (this) {
resized = true;
}
}
@Override
public void componentShown(ComponentEvent e) {
}
@Override
public void componentHidden(ComponentEvent e) {
}
});
}
@Override
public void addNotify() {
super.addNotify();
startLWJGL();
}
public void startLWJGL() {
if (gameThread != null) {
return;
}
gameThread = new Thread() {
@Override
public void run() {
setRunning(true);
try {
Display.setParent(canvas);
Display.create(new PixelFormat().withBitsPerPixel(32).withDepthBits(24).withStencilBits(8));
} catch (LWJGLException e) {
e.printStackTrace();
}
gameLoop();
}
};
gameThread.setName("rendering");
gameThread.start();
}
private void stopLWJGL() {
running = false;
try {
gameThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
protected void initGL() {
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glLoadIdentity();
GL11.glOrtho(0, 800, 0, 600, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
}
public boolean isRunning() {
synchronized (this) {
return running;
}
}
public void setRunning(boolean value) {
synchronized (this) {
this.running = value;
}
}
public void setSleeping(boolean sleeping) {
{
this.sleeping = sleeping;
}
}
public void gameLoop() {
while (running) {
// Clear the screen and depth buffer
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
// set the color of the quad (R,G,B,A)
GL11.glColor3f(0.5f,0.5f,1.0f);
// draw quad
GL11.glBegin(GL11.GL_QUADS);
GL11.glVertex2f(100,100);
GL11.glVertex2f(100+200,100);
GL11.glVertex2f(100+200,100+200);
GL11.glVertex2f(100,100+200);
GL11.glEnd();
if (sleeping) {
try {
Thread.sleep(16);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Display.sync(15);
Display.update();
} else {
Display.sync(45);
Display.update();
}
}
Display.destroy();
System.out.println("GL destroyed");
}
public void destroyRT() {
stopLWJGL();
}
}
}
Check attachments for screenshots..