[prev in list] [next in list] [prev in thread] [next in thread]
List: rxtx
Subject: Re: [Rxtx] swing jfilechooser lockup
From: Michael Tandy <m.j.tandy () warwick ! ac ! uk>
Date: 2009-05-14 9:05:36
Message-ID: 302aa0340905140205p6ceb5a9br24e00a50e9cafa5 () mail ! gmail ! com
[Download RAW message or body]
Java has a built in deadlock detection utility; run your program from
the command line, then (on windows) press Ctrl+Break (On Linux, Ctrl+\
does the trick I'm told).
That should produce status information and a stack trace for every
running thread, including locks held and locks waited on. Maybe that
would contain enough information for you to work out what's locking
what?
2009/5/13 Bill Rust <wjr@weru.ksu.edu>:
> Tod's solution misses the point. He is picking and opening the serial
> port. That's the step before where my problem occurs.
>
> To recap:
>
> 1. I have a simple java swing app.
> 2. On the menu bar, there is the standard set, file, etc., of jmenu's.
> Under file, there is a jmenuitem, logfileopen, which pops up a
> jfilechooser to select a logfile and another jmenuitem, setprefix, which
> pops up a jdialog to allow the user to type in a file name prefix for
> downloaded images.
> 3. There is another jmenuitem that starts the commport running.
> 4. When logfileopen is pressed before the commport is started, it works.
> 5. When logfileopen is pressed after the commport is started, it hangs.
> 6. setprefix works whether or not the commport is started.
> 7. portIdentifier.open starts a thread that goes into a native
> method, RXTXPort.eventLoop, and never returns.
> 8. java.sun bugs has a bug report, 6741890, that is similar but
> their workaround doesn't.
> 9. When it locks up, there is a swing-shell thread that appears to be
> down in some native libraries, winshellfolder2
> 10. The awt-eventQ thread is unblocked but in code that says its parked.
>
> If you have anymore ideas, I'd really appreciate them.
>
> wjr
>
> Tod E. Kurt wrote:
>> This is the exact technique I use to let the user choose which serial
>> port to use on startup. Here's a method I've got in many of my sketches:
>>
>> void choosePort() {
>> String portlist[] = Serial.list();
>> String port = null;
>> javax.swing.SwingUtilities.invokeLater(new Runnable() {
>> public void run() {
>> try {
>> String port = (String) javax.swing.JOptionPane.showInputDialog(
>> null,
>> "Select Serial Port",
>> "MySuperSketch",
>> javax.swing.JOptionPane.QUESTION_MESSAGE,
>> null, portlist, null);
>> if( port == null ) {
>> javax.swing.JOptionPane.showMessageDialog(null, "No port
>> chosen, goodbye");
>> System.exit(1);
>> }
>> serialPort = port;
>> }
>> catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> } );
>> }
>>
>>
>> On May 8, 2009, at 2:08 p, Brian Schlining wrote:
>>
>>> Bob's probably right...take look at javax.swing.SwingUtilites for the
>>> workaround to get your swing stuff invoked on the EventDispatchThread
>>> (EDT). Some swing-methods do work when called outside of the EDT, but
>>> just to be safe, do your creation and swing calls on the EDT. It's
>>> really simple, here's an example of a synchronous call.
>>>
>>> // Here's how to run stuff on the EDT from a different thread
>>> SwingUtilities.invokeAndWait(new Runnable() {
>>> public void run() {
>>> JFileChooser fc; // create, setup, show your filechooser
>>> // Get the result from the filechooser
>>> }
>>> });
>>>
>>> To do a asynchronous call use SwingUtilities.invokeLater
>>>
>>>
>>> >I wrote a small swing app to download images from an industrial camera.
>>> >I used the two way serial sample code as a starting point. The app works
>>> >fine EXCEPT for a call to jfilechooser. After I open the comm port and
>>> >then try to change the output directory or log file, the jfilechooser
>>> >winds up trying to unpark (note, parking is not something I'm really
>>> >familiar with) and doesn't.
>>> What is the threading structure of your code?
>>>
>>> The various high-function Swing components, such as JFileChooser, are
>>> notorious for doing Really Bad Stuff when invoked from off the Swing
>>> thread.
>>>
>>> Bob
>>> --
>>> Bob Jacobsen, UC Berkeley
>>> jacobsen@berkeley.edu +1-510-486-7355 fax +1-510-643-8497 AIM, Skype
>>> JacobsenRG
>>> _______________________________________________
>>> Rxtx mailing list
>>> Rxtx@qbang.org
>>> http://mailman.qbang.org/mailman/listinfo/rxtx
>>>
>>>
>>>
>>> --
>>> ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
>>> Brian Schlining
>>> bschlining@gmail.com
>>> _______________________________________________
>>> Rxtx mailing list
>>> Rxtx@qbang.org
>>> http://mailman.qbang.org/mailman/listinfo/rxtx
>
> _______________________________________________
> Rxtx mailing list
> Rxtx@qbang.org
> http://mailman.qbang.org/mailman/listinfo/rxtx
>
_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic