LWJGL
May 23, 2013, 17:42:37 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL is now using GitHub
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: [CLOSED] swing/nimbus resizing a splitpane causes deadlock  (Read 1068 times)
emzic
Newbie
*
Posts: 22


« on: April 22, 2011, 04:05:31 »

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:

Code:
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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!