java - flash file does not appear -
i want add flash file frame , works fine ,but when make frame using netbeans , flash file did not work more , when remove "initcomponent()" method works, not want remove method , why method make flash file not working or prevent add frame ??
this code :
public class simpleflashexample_1 extends jframe{ public simpleflashexample_1() { initcomponents(); jflashplayer flashplayer = new jflashplayer(); flashplayer.load(getclass(), "/clientserver/fl.swf"); add(flashplayer, borderlayout.center); } private void initcomponents() { setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 675, short.max_value) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 475, short.max_value) ); pack(); } public static void main(string[] args) { uiutils.setpreferredlookandfeel(); nativeinterface.open(); swingutilities.invokelater(new runnable() { @override public void run() { new simpleflashexample_1().setvisible(true); } }); nativeinterface.runeventpump(); } }
take few moments read through code...
public simpleflashexample_1() { // 1... initcomponents(); jflashplayer flashplayer = new jflashplayer(); flashplayer.load(getclass(), "/clientserver/fl.swf"); // 3... add(flashplayer, borderlayout.center); } private void initcomponents() { setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); // 2.... javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 675, short.max_value) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading) .addgap(0, 475, short.max_value) ); pack(); }
first, call initcomponents
. initcomponents
calls getcontentpane().setlayout(layout);
, assigning grouplayout
layout manager frame. add flash player frame, trying use borderlayout
constraint, isn't going compatible grouplayout
(and apparently ignored)
why component doesn't show comes down number of factors, surmise flash player either doesn't have preferred size or grouplayout
, not knowing else it, ignoring component
try setting layout frame borderlayout
in form designer
Comments
Post a Comment