Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Java Empty entry in java.awt.Frame[]

Subject: Java Empty entry in java.awt.Frame[]

From: Malcolm Lidierth

Date: 17 Sep, 2010 14:24:05

Message: 1 of 3

Any thoughts on how to handle this:

java.awt.Frame[]:
    [com.mathworks.mde.desk.MLMainFrame ]
    [javax.swing.SwingUtilities$SharedOwnerFrame ]
    [com.mathworks.mwswing.desk.DTSingleClientFrame ]
    ....
    .....
    [ij.gui.ImageWindow ]
    []

This java.awt.Frame array is returned to MATLAB by a call to getFrames() and includes an 'empty' entry (at the end in this case).
Subsreferencing the empty element crashes MATLAB with a segmentation error. How can I get around this?

Subject: Java Empty entry in java.awt.Frame[]

From: Yair Altman

Date: 17 Sep, 2010 15:01:06

Message: 2 of 3

"Malcolm Lidierth" <ku.ca.lck@htreidil.mloclam> wrote in message <i6vtm4$b07$1@fred.mathworks.com>...
> Any thoughts on how to handle this:
>
> java.awt.Frame[]:
> [com.mathworks.mde.desk.MLMainFrame ]
> [javax.swing.SwingUtilities$SharedOwnerFrame ]
> [com.mathworks.mwswing.desk.DTSingleClientFrame ]
> ....
> .....
> [ij.gui.ImageWindow ]
> []
>
> This java.awt.Frame array is returned to MATLAB by a call to getFrames() and includes an 'empty' entry (at the end in this case).
> Subsreferencing the empty element crashes MATLAB with a segmentation error. How can I get around this?


Odd that this happens - java.awt.Frame.getFrames() should only return actual window frames. Anyway, try converting into a cell array - since cells may be empty this may circumvent the crash and you can test the emptiness with isempty():

frames = cell(java.awt.Frame.getFrames);
isempty(frames(end))


Yair Altman
http://UndocumentedMatlab.com

Subject: Java Empty entry in java.awt.Frame[]

From: Malcolm Lidierth

Date: 18 Sep, 2010 12:09:04

Message: 3 of 3

Thanks Yair - that did the trick.
I have not worked out why the frames are returned empty yet- they are visible and functional on screen.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us