मैं एक समस्या यह है कि हो सकता है की मौसम Netbeans मंच (7.1.2) या JavaFX 2. मैं एक स्विंग JPanel
लिए एक बहुत ही सरल Scene
के साथ एक JFXPanel
जोड़ना चाहते थे कुछ सिद्धांत में समझ की कमी के कारण होता है मिल गया है कि एक टॉपकंपोनेंट का बच्चा है। मैं निम्नलिखित कोड कर यह उपलब्धि हासिल:क्यों मेरे TopComponent पर JavaFX सामग्री गायब हो जाती है?
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);
}
यह एक समस्या है और एक JavaFX Button
प्रदर्शित किया जाता है बिना संकलित जब मैं पहली बार TopComponent
दिखा। लेकिन जैसे ही घटक छिपा हुआ है और फिर दिखाया गया है, जावाएफएक्स Button
गायब हो जाता है जबकि अन्य बच्चे अभी भी दिखाई दे रहे हैं।
जावाएफएक्स सामग्री गायब क्यों होती है?
संपादित करें:
मैं अब पूरी TopComponent के स्रोत शामिल हैं। मुझे लगता है कि आपको इसे अपने लिए परीक्षण करने की ज़रूरत है। मैंने कोई अन्य फाइल नहीं बदली।
/*
* 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">
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))
);
}// </editor-fold>
// 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
}
}
मेरे मामले में, इस TopComponent
एक घटक JavaFX का संदर्भ और एक सादे नायब प्लेटफार्म आवेदन द्वारा संदर्भित है जो AccountExplorer कहा जाता है का हिस्सा है।
मैं NetBeans 7.1 और JavaFX 2.1 उपयोग करके अपनी समस्या पुन: पेश करने की कोशिश की। अपेक्षित के रूप में सभी घटक फिर से दिखाई देते हैं। कृपया एक एसएससीसीई पोस्ट करें। – pmoule
प्रयास के लिए धन्यवाद। मेरी परियोजना देखें [यहां] (https://rapidshare.com/files/894496305/FinancialEngineer.7z) – dajood
क्षमा करें, कोई परियोजना डाउनलोड लिंक नहीं है, कृपया। दूसरों को शामिल करने और इसे मदद करने के लिए और अधिक आकर्षक बनाने के लिए, एक [एसएससीसीई] (http://pscode.org/sscce.html) पोस्ट करें। – pmoule