hello, i am not really sure if this bug is on the LWJGL side, on the SWING side, or on my side.
however i am getting a deadlock when resizing a splitpane and setting a jslider from the lwjgl-thread when using the nimbus look and feel.
the following code reproduces the deadlock:
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JSlider;
import javax.swing.JSplitPane;
import javax.swing.UIManager;
import org.lwjgl.opengl.AWTGLCanvas;
import org.lwjgl.opengl.GL11;
public class Mainframe
{
public static void main(String[] args) throws Exception
{
new Mainframe();
}
JFrame frame;
JSlider slider;
int count = 0;
AWTGLCanvas canvas;
public Mainframe() throws Exception
{
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
catch (Exception e)
{
e.printStackTrace();
}
frame = new JFrame("hi");
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
canvas = new AWTGLCanvas()
{
private static final long serialVersionUID = 1L;
@Override
protected void paintGL()
{
try
{
canvas.setVSyncEnabled(false);
GL11.glClearColor((float) Math.sin(count++*0.01f), 0, 0, 1);
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
canvas.swapBuffers();
slider.setValue(count%100);
}
catch (Exception e)
{
e.printStackTrace();
}
};
};
canvas.setMinimumSize(new Dimension(100, 100));
slider = new JSlider();
JSplitPane mainsplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, canvas, slider);
mainsplit.setDividerLocation(0.5);
frame.getContentPane().add(mainsplit);
frame.setVisible(true);
Thread renderThread = new Thread()
{
@Override
public void run()
{
while (true)
{
canvas.update(canvas.getGraphics());
}
}
};
renderThread.start();
}
}
just resize the splitpane.
edit: ok, i just figured out that calling the slider.setValue on the event dispatcher thread solves the problem. i guess this thread can be discarded then.