Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: javacomponent ( tab constructor )
Replies: 5   Last Post: Aug 21, 2011 9:24 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Jens Langer

Posts: 30
Registered: 3/21/07
Re: javacomponent ( tab constructor )
Posted: Aug 17, 2011 11:48 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi,

fortunatly this code snippet is not as harmful at it seems to be.

As i unterstand the javacomponent function in above case it should create a certain java swing object placing it in a specific parent handle with postion p and returns the java handle and its hg container.

[javaHandle, hgContainer] = javacomponent(swingObject, position, parentHandle);

The way i thought it should work:
1. Create a figure object.
2. Create a java object (jTabbedPane) and place it in the figure object.
3. Create a java object (jPanel) and place it in the jTabbedPane object.
4. Create a java object (jLabel) and place it in the jPanel object.
5. Add the jPanel object to the jTabbedPane object.
-> A tabbedPane with a single tab named like defined while creating the jPanel object is placed on the figure object.

Code:
1. f=figure();
2. [jTabbedPane, jTabbedPaneC] = javacomponent(javax.swing.JTabbedPane(),[0 0 400 400],f);
3. [jPanel,jPanelC] = javacomponent(javax.swing.JPanel,[],jTabbedPaneC);
4. [jLabel,jLabelC] = javacomponent(javax.swing.JLabel('Tab 1'),[],jPanelC);
5. jTabbedPane.addTab(jPanel);

The jPanel isn't named like defined in jLabel. Placing jLabel in jPanel seems not to work. But this is not critical, there are many ways to solve this problem:

Code:
1. f=figure();
2. [jTabbedPane, jTabbedPaneC] = javacomponent(javax.swing.JTabbedPane(),[0 0 400 400],f);
3. [jPanel,jPanelC] = javacomponent(javax.swing.JPanel,[],jTabbedPaneC);
4. jPanel.setName('Tab 1');pause(0.1);
5. jTabbedPane.add(jPanel);

This works fine! Unfortunately i missed to talk about the bigger problem:

--> How to place an uicontrol like an uipanel or axes to this java created tab? <--

My first intention was using the returned hg container handle while creating the java object with the javacomponent command and define this handle as parent handle for the specific object created with the common matlab coding commands.
e.g.
...
6. matPanel = uipanel('parent',jPanelC,'units','normalized','position',[0 0 1 1],'BackgroundColor','white');
7. myAxes = axes('parent',matPanel);

Returning neither warning nor error messages and indeed returning a valid handle to the uicontrol created object and even valid object itself, it does not appear on the parent handle.




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.