Skip to Main Content Skip to Search
Login
File Exchange
MATLAB Newsgroup
Link Exchange
  Blogs  
 Contest 
MathWorks.com

Thread Subject: add a uicontainer or uipanel to a JPanel

Subject: add a uicontainer or uipanel to a JPanel

From: Andrew Watson

Date: 9 Aug, 2007 21:09:08

Message: 1 of 9

I would like to add either a uipanel or uicontainer that has
MATLAB graphics children to a JPanel. After an evening of
playing around with this but to no avail I thought I'd open
it up to a wider audience. Any suggestions would be very
much appreciated.

Thanks in advance

Andrew

Subject: add a uicontainer or uipanel to a JPanel

From: Arwel Hughes

Date: 10 Aug, 2007 09:55:39

Message: 2 of 9

Hi Andrew,
I've tried this too but got nowhere. It really does look
like the matlab graphics are in some sort of Java
containers (you can see this by running Yair Altman's find
Obj
http://www.mathworks.com/matlabcentral/fileexchange/loadFile
.do?objectId=14317&objectType=file)
But they seem to be weird Mathworks wrappers for the java
objects rather than the 'real' thing. My hope was that I
could plot a Matlab graph (hidden), and then just grab the
relevant content pane and put that in a java frame. But I
got nowhere unfortunately.
I'm currently resorting to doing all the plotting in Java
(using JFreeChart), which isn't quite as nice.
If you do find out how to do this, it would be very useful
for lots of people I think.
Cheers
Arwel









"Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
<f9fvpk$t63$1@fred.mathworks.com>...
> I would like to add either a uipanel or uicontainer that
has
> MATLAB graphics children to a JPanel. After an evening of
> playing around with this but to no avail I thought I'd
open
> it up to a wider audience. Any suggestions would be very
> much appreciated.
>
> Thanks in advance
>
> Andrew

Subject: add a uicontainer or uipanel to a JPanel

From: Yair Altman

Date: 10 Aug, 2007 11:32:02

Message: 3 of 9

"Arwel Hughes" <a.v.hughes@rl.ac.uk> wrote in message
<f9hcmr$dhk$1@fred.mathworks.com>...
> I've tried this too but got nowhere. It really does look
> like the matlab graphics are in some sort of Java
containers...

That's my experience too. I, and several others, have
asked/pleaded/begged MathWorks to enable Matlab components
(most importantly an axis) to be added to a Java container
(there are other Matlab/Java integration issues, but this is
topmost). We hit a blank wall - MathWorks simply does not
want to do this for reasons which were undisclosed. The
official answer is that this is currently unsupported and
will be added to the list of possible future enhancements
and have a nice day...

Yair Altman
http://ymasoftware.com

Subject: add a uicontainer or uipanel to a JPanel

From: Andrew Watson

Date: 10 Aug, 2007 11:45:34

Message: 4 of 9

Hi Arwel,

I thought as much. I saw your original posting and Yair
Altman's comments and was hoping to do something similar.
I'm sure this must be possible but it's starting to feel
akin to banging my head against a brick wall.

Going down the Java route for plotting isn't something I
really want to do as MATLAB is so good at this. I'm just
disappointed that I will have to resort to creating a
"second class" GUI.

Thank you very much for your reply and I agree that this
would be very useful to a lot of people.

Kind Regards

Andrew


"Arwel Hughes" <a.v.hughes@rl.ac.uk> wrote in message
<f9hcmr$dhk$1@fred.mathworks.com>...
> Hi Andrew,
> I've tried this too but got nowhere. It really does look
> like the matlab graphics are in some sort of Java
> containers (you can see this by running Yair Altman's find
> Obj
> http://www.mathworks.com/matlabcentral/fileexchange/loadFile
> .do?objectId=14317&objectType=file)
> But they seem to be weird Mathworks wrappers for the java
> objects rather than the 'real' thing. My hope was that I
> could plot a Matlab graph (hidden), and then just grab the
> relevant content pane and put that in a java frame. But I
> got nowhere unfortunately.
> I'm currently resorting to doing all the plotting in Java
> (using JFreeChart), which isn't quite as nice.
> If you do find out how to do this, it would be very useful
> for lots of people I think.
> Cheers
> Arwel
>
>
>
>
>
>
>
>
>
> "Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
> <f9fvpk$t63$1@fred.mathworks.com>...
> > I would like to add either a uipanel or uicontainer that
> has
> > MATLAB graphics children to a JPanel. After an evening of
> > playing around with this but to no avail I thought I'd
> open
> > it up to a wider audience. Any suggestions would be very
> > much appreciated.
> >
> > Thanks in advance
> >
> > Andrew
>

Subject: add a uicontainer or uipanel to a JPanel

From: Andrew Watson

Date: 10 Aug, 2007 11:50:27

Message: 5 of 9

Thanks Yair,

An axis is ultimately what I wanted to add to to a JPanel
but I figured that a uicontanier or uipanel in which an axis
can sit might be more native to the Java environment.

Thanks for the response and all the matlab/java functions on
FEX.

Kind Regards

Andrew Watson

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<f9hibi$m7t$1@fred.mathworks.com>...
> "Arwel Hughes" <a.v.hughes@rl.ac.uk> wrote in message
> <f9hcmr$dhk$1@fred.mathworks.com>...
> > I've tried this too but got nowhere. It really does look
> > like the matlab graphics are in some sort of Java
> containers...
>
> That's my experience too. I, and several others, have
> asked/pleaded/begged MathWorks to enable Matlab components
> (most importantly an axis) to be added to a Java container
> (there are other Matlab/Java integration issues, but this is
> topmost). We hit a blank wall - MathWorks simply does not
> want to do this for reasons which were undisclosed. The
> official answer is that this is currently unsupported and
> will be added to the list of possible future enhancements
> and have a nice day...
>
> Yair Altman
> http://ymasoftware.com
>

Subject: add a uicontainer or uipanel to a JPanel

From: Bill York

Date: 12 Sep, 2007 23:49:07

Message: 6 of 9

"Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
<f9hje3$62v$1@fred.mathworks.com>...
> Thanks Yair,
>
> An axis is ultimately what I wanted to add to to a JPanel
> but I figured that a uicontanier or uipanel in which an
axis
> can sit might be more native to the Java environment.

The short answer to the posted question is you can't do
that.

The uicontainers and uipanels and axes, for that matter,
just can't be put in arbitrary Java components. It's not
that we don't want to make it possible, it's just a ton of
work and other priorities keep coming up.

As for putting an axes in a Java container, you can use the
print or imwrite commands to dump the contents of a figure
into a bitmap then shove that into any Java canvas which
can show a bitmap. We've done some hackery where you take
the output from imwrite and stuff it onto a JButton for
example.

As for putting non-bitmap axes into Java containers, could
you tell me more about why you want to do it? What is the
MATLAB thing you can't do without this capability?

Thanks,

Bill

Subject: add a uicontainer or uipanel to a JPanel

From: Yair Altman

Date: 15 Sep, 2007 18:36:56

Message: 7 of 9

"Bill York" <BillDotYork@MathWorks.com> wrote in message
<fc9ttj$eh5$1@fred.mathworks.com>...
> "Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
> <f9hje3$62v$1@fred.mathworks.com>...
> > Thanks Yair,
> >
> > An axis is ultimately what I wanted to add to to a JPanel
> > but I figured that a uicontanier or uipanel in which an
> axis
> > can sit might be more native to the Java environment.
>
> The short answer to the posted question is you can't do
> that.
>
> The uicontainers and uipanels and axes, for that matter,
> just can't be put in arbitrary Java components. It's not
> that we don't want to make it possible, it's just a ton of
> work and other priorities keep coming up.
>
> As for putting an axes in a Java container, you can use the
> print or imwrite commands to dump the contents of a figure
> into a bitmap then shove that into any Java canvas which
> can show a bitmap. We've done some hackery where you take
> the output from imwrite and stuff it onto a JButton for
> example.
>
> As for putting non-bitmap axes into Java containers, could
> you tell me more about why you want to do it? What is the
> MATLAB thing you can't do without this capability?
>
> Thanks,
>
> Bill


Thanks a lot for your comment Bill. It is sometimes
important to place Matlab axes in Java containers, since
Java (Swing in particular) enables richer GUI than Matlab
enables. For example, if I need JSplitPane functionality I
have to rely on Java, not Matlab, but then I cannot add a
Matlab axes to either side of the split-pane, which is a
major drawback. You'll agree with me, I hope, that
reprogramming a JSplitPane from scratch in Matlab just to
solve the axes issue would be a shameful waste...

Remember that Matlab axes (& children) are rich objects
themselves, and simple imwrite falls far short of the needs
(callbacks and online data updates are just two examples).

If only an axes could be placed within a JContainer, that
would automatically solve all these issues, for all Swing
components.

Yair Altman

Subject: add a uicontainer or uipanel to a JPanel

From: Andrew Watson

Date: 17 Sep, 2007 09:46:46

Message: 8 of 9

"Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
<fch8o8$ee7$1@fred.mathworks.com>...
> "Bill York" <BillDotYork@MathWorks.com> wrote in message
> <fc9ttj$eh5$1@fred.mathworks.com>...
> > "Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
> > <f9hje3$62v$1@fred.mathworks.com>...
> > > Thanks Yair,
> > >
> > > An axis is ultimately what I wanted to add to to a JPanel
> > > but I figured that a uicontanier or uipanel in which an
> > axis
> > > can sit might be more native to the Java environment.
> >
> > The short answer to the posted question is you can't do
> > that.
> >
> > The uicontainers and uipanels and axes, for that matter,
> > just can't be put in arbitrary Java components. It's not
> > that we don't want to make it possible, it's just a ton of
> > work and other priorities keep coming up.
> >
> > As for putting an axes in a Java container, you can use the
> > print or imwrite commands to dump the contents of a figure
> > into a bitmap then shove that into any Java canvas which
> > can show a bitmap. We've done some hackery where you take
> > the output from imwrite and stuff it onto a JButton for
> > example.
> >
> > As for putting non-bitmap axes into Java containers, could
> > you tell me more about why you want to do it? What is the
> > MATLAB thing you can't do without this capability?
> >
> > Thanks,
> >
> > Bill
>
>
> Thanks a lot for your comment Bill. It is sometimes
> important to place Matlab axes in Java containers, since
> Java (Swing in particular) enables richer GUI than Matlab
> enables. For example, if I need JSplitPane functionality I
> have to rely on Java, not Matlab, but then I cannot add a
> Matlab axes to either side of the split-pane, which is a
> major drawback. You'll agree with me, I hope, that
> reprogramming a JSplitPane from scratch in Matlab just to
> solve the axes issue would be a shameful waste...
>
> Remember that Matlab axes (& children) are rich objects
> themselves, and simple imwrite falls far short of the needs
> (callbacks and online data updates are just two examples).
>
> If only an axes could be placed within a JContainer, that
> would automatically solve all these issues, for all Swing
> components.
>
> Yair Altman
>

Bill,

At the time of posting I was looking for the same
functionality that Yair Altman has mentioned, that of a
JSplitPane. It is not a trivial exercise to code one up
from scratch. Also the results will never be as robust,
fluid or aesthetically pleasing as a JSplitPane.

Thanks for your suggestion of using imwrite or some other
such method but as Yair has pointed out, I also want to
maintain the functionality of an axis object i.e callbacks
and what not.

Andrew

Subject: add a uicontainer or uipanel to a JPanel

From: Amir

Date: 27 Nov, 2007 07:52:25

Message: 9 of 9

"Andrew Watson" <andruwatson@yahoo.co.uk> wrote in message
<fclie6$q6i$1@fred.mathworks.com>...
> "Yair Altman" <altmanyDEL@gmailDEL.comDEL> wrote in message
> <fch8o8$ee7$1@fred.mathworks.com>...
> > "Bill York" <BillDotYork@MathWorks.com> wrote in message
> > <fc9ttj$eh5$1@fred.mathworks.com>...
> > > "Andrew Watson" <andruwatson@yahoo.co.uk> wrote in
message
> > > <f9hje3$62v$1@fred.mathworks.com>...
> > > > Thanks Yair,
> > > >
> > > > An axis is ultimately what I wanted to add to to a
JPanel
> > > > but I figured that a uicontanier or uipanel in which an
> > > axis
> > > > can sit might be more native to the Java environment.
> > >
> > > The short answer to the posted question is you can't do
> > > that.
> > >
> > > The uicontainers and uipanels and axes, for that matter,
> > > just can't be put in arbitrary Java components. It's not
> > > that we don't want to make it possible, it's just a
ton of
> > > work and other priorities keep coming up.
> > >
> > > As for putting an axes in a Java container, you can
use the
> > > print or imwrite commands to dump the contents of a
figure
> > > into a bitmap then shove that into any Java canvas which
> > > can show a bitmap. We've done some hackery where you
take
> > > the output from imwrite and stuff it onto a JButton for
> > > example.
> > >
> > > As for putting non-bitmap axes into Java containers,
could
> > > you tell me more about why you want to do it? What is
the
> > > MATLAB thing you can't do without this capability?
> > >
> > > Thanks,
> > >
> > > Bill
> >
> >
> > Thanks a lot for your comment Bill. It is sometimes
> > important to place Matlab axes in Java containers, since
> > Java (Swing in particular) enables richer GUI than Matlab
> > enables. For example, if I need JSplitPane functionality I
> > have to rely on Java, not Matlab, but then I cannot add a
> > Matlab axes to either side of the split-pane, which is a
> > major drawback. You'll agree with me, I hope, that
> > reprogramming a JSplitPane from scratch in Matlab just to
> > solve the axes issue would be a shameful waste...
> >
> > Remember that Matlab axes (& children) are rich objects
> > themselves, and simple imwrite falls far short of the needs
> > (callbacks and online data updates are just two examples).
> >
> > If only an axes could be placed within a JContainer, that
> > would automatically solve all these issues, for all Swing
> > components.
> >
> > Yair Altman
> >
>
> Bill,
>
> At the time of posting I was looking for the same
> functionality that Yair Altman has mentioned, that of a
> JSplitPane. It is not a trivial exercise to code one up
> from scratch. Also the results will never be as robust,
> fluid or aesthetically pleasing as a JSplitPane.
>
> Thanks for your suggestion of using imwrite or some other
> such method but as Yair has pointed out, I also want to
> maintain the functionality of an axis object i.e callbacks
> and what not.
>
> Andrew
>
Bill,

As you know from our past correspondence, there are ways (at
least two I'm aware of) to make a java/matlab figure hybrid
that have java GUI and matlab graphic (aka "the holly
grail"). However, both are non-trivial, non-intuitive, have
limitations (for example, making sure the java components
resize after the user resize the matlab figure) and require
heavy usage of undocumented features. Moreover, it seems
that new Matlab version frequently break such hacks that
worked in the previous version (no real complains here, as
those hacks use UNDOCUMENTED features). However, one gets
tired from using those hacks and want to just implement the
needed business logic instead of fighting with Java/Matlab
integration issues.

Can you comment on when (if at all) will Mathwork be able to
implement a java wrapper around matlab axis that extends
java.com.Component, so we could just drop it inside our
favorite java container as god intended and go on with our
lives.

Amir

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
java Amir 27 Nov, 2007 03:58:44
undocumented Amir 27 Nov, 2007 03:58:40
java Bill York 12 Sep, 2007 19:50:25
undocumented Andrew Watson 9 Aug, 2007 17:10:35
java Andrew Watson 9 Aug, 2007 17:10:35
rssFeed for this Thread

envelope graphic E-mail this page to a colleague

Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.
Related Topics