Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy disappears the JavaFX content on my TopComponent?
    primarykey
    data
    text
    <p>I've got a problem that maybe is caused by a lack of understanding in some principles of wether the Netbeans Platform(7.1.2) or JavaFX 2. I wanted to add a <code>JFXPanel</code> with a very simple <code>Scene</code> to a Swing <code>JPanel</code> that is a child of a TopComponent. I achieved this by the following code:</p> <pre><code> public accexTopComponent() { initComponents(); setName(Bundle.CTL_accexTopComponent()); setToolTipText(Bundle.HINT_accexTopComponent()); putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); //Begin of my code myFX = new JFXPanel(); //myFX is a static JFXPanel Platform.runLater(new Runnable() { @Override public void run() { myFX.setScene(new Scene(ButtonBuilder.create().minHeight(40.0).minWidth(40.0).build())); } }); jPanel1.add(myFX); } </code></pre> <p>This compiles without a problem and a JavaFX <code>Button</code> is displayed when i show the <code>TopComponent</code> for the very first time. But as soon as the component is hidden and shown again, the JavaFX <code>Button</code> disappears while the other children still are visible.</p> <p>Why does the JavaFX content disappear?</p> <p>Edit:</p> <p>I now include the source of the whole TopComponent. I guess that's all you need to test it for yourself. I didn't change any other file. </p> <pre><code>/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package de.jeed.nbgan.accexplorer; import java.awt.Color; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.Scene; import javafx.scene.control.ButtonBuilder; import javafx.scene.text.TextBuilder; import javafx.scene.web.WebView; import javafx.scene.web.WebViewBuilder; import org.netbeans.api.settings.ConvertAsProperties; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; import org.openide.windows.TopComponent; import org.openide.util.NbBundle.Messages; /** * Top component which displays something. */ @ConvertAsProperties(dtd = "-//de.jeed.nbgan.accexplorer//accex//EN", autostore = false) @TopComponent.Description(preferredID = "accexTopComponent", //iconBase="SET/PATH/TO/ICON/HERE", persistenceType = TopComponent.PERSISTENCE_ALWAYS) @TopComponent.Registration(mode = "explorer", openAtStartup = true) @ActionID(category = "Window", id = "de.jeed.nbgan.accexplorer.accexTopComponent") @ActionReference(path = "Menu/Window" /* * , position = 333 */) @TopComponent.OpenActionRegistration(displayName = "#CTL_accexAction", preferredID = "accexTopComponent") @Messages({ "CTL_accexAction=accex", "CTL_accexTopComponent=Konten-Explorer", "HINT_accexTopComponent=Durchsuchen von Abteilungen und Konten" }) public final class accexTopComponent extends TopComponent { static JFXPanel myFX; public accexTopComponent() { initComponents(); setName(Bundle.CTL_accexTopComponent()); setToolTipText(Bundle.HINT_accexTopComponent()); putClientProperty(TopComponent.PROP_CLOSING_DISABLED, Boolean.TRUE); myFX = new JFXPanel(); Platform.runLater(new Runnable() { @Override public void run() { myFX.setScene(new Scene(ButtonBuilder.create().minHeight(40.0).minWidth(40.0).build())); } }); jPanel1.add(myFX); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ // &lt;editor-fold defaultstate="collapsed" desc="Generated Code"&gt; private void initComponents() { jPanel1 = new javax.swing.JPanel(); jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); jPanel1.setLayout(new java.awt.GridBagLayout()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(54, 54, 54) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(153, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(33, 33, 33) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 193, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(74, Short.MAX_VALUE)) ); }// &lt;/editor-fold&gt; // Variables declaration - do not modify private javax.swing.JPanel jPanel1; // End of variables declaration @Override public void componentOpened() { // TODO add custom code on component opening } @Override public void componentClosed() { // TODO add custom code on component closing } void writeProperties(java.util.Properties p) { // better to version settings since initial version as advocated at // http://wiki.apidesign.org/wiki/PropertyFiles p.setProperty("version", "1.0"); // TODO store your settings } void readProperties(java.util.Properties p) { String version = p.getProperty("version"); // TODO read your settings according to their version } } </code></pre> <p>In my case, this <code>TopComponent</code> is part of a Component called AccountExplorer which references JavaFX and is referenced by a plain NB Platform Application.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload