|
|
Re: javacomponent ( tab constructor )
Posted:
Aug 17, 2011 11:48 AM
|
|
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.
|
|