How to embedd Flex within Swing App?

Hi guys,
I'm Java developer and new to Flex.
I have a Swing application, and want to embed a Flex app in the Java desktop app.
How to do?
Thanks in advance!
Sha Jiang

See this link,
http://www.jpackages.com/jflashplayer/
I didn't try this, hope you may find this useful

Similar Messages

  • Closing a Swing App with Window Closing Event With Dialogs On Close

    A while back I started a thread discussing how to neatly close a Swing app using both the standard window "X" button and a custom action such as a File menu with an Exit menu item. Ultimately, I came to the conclusion that the cleanest solution in many cases is to use a default close operation of JFrame.EXIT_ON_CLOSE and in any custom actions manually fire a WindowEvent with WindowEvent.WINDOW_CLOSING. Using this strategy, both the "X" button and the custom action act in the same manner and can be successfully intercepted by listening for a window closing event if any cleanup is required; furthermore, the cleanup could use dialogs to prompt for user actions without any ill effects.
    I did, however, encounter one oddity that I mentioned in the previous thread. A dialog launched through SwingUtilities.invokeLater in the cleanup method would cause the app to not shutdown. This is somewhat of an academic curiosity as I am not sure you would ever have a rational need to do this, but I thought it would be interesting to explore more fully. Here is a complete example that demonstrates; see what you think:
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    public class CloseByWindowClosingTest {
         public static void main(String[] args) {
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        launchGUI();
         private static void launchGUI() {
              final JFrame frame = new JFrame("Close By Window Closing Test");
              JPanel panel = new JPanel();
              panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
              JButton button1 = new JButton("No Dialog Close");
              JButton button2 = new JButton("Dialog On Close");
              JButton button3 = new JButton("Invoke Later Dialog On Close");
              button1.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        postWindowClosingEvent(frame);
              button2.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        JOptionPane.showMessageDialog(frame, "Test Dialog");
                        postWindowClosingEvent(frame);
              button3.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        SwingUtilities.invokeLater(new Runnable() {
                             public void run() {
                                  JOptionPane.showMessageDialog(frame, "Test Dialog");
                        postWindowClosingEvent(frame);
              panel.add(button1);
              panel.add(button2);
              panel.add(button3);
              frame.setContentPane(panel);
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.addWindowListener(new WindowAdapter() {
                   @Override
                   public void windowClosing(WindowEvent event) {
                        System.out.println("Received Window Closing Event");
              frame.setVisible(true);
         private static void postWindowClosingEvent(JFrame frame) {
              WindowEvent windowClosingEvent = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING);
              frame.getToolkit().getSystemEventQueue().postEvent(windowClosingEvent);
    }An additional note not in the example -- if in the button 3 scenario you were to put the window closing event posting inside the invoke later, the app then again closes. However, as implemented, what is it that causes button 3 to not result in the application closing?
    Edited by: Skotty on Aug 11, 2009 5:08 PM -- Modified example code -- added the WindowAdapter to the frame as a window listener to show which buttons cause listeners to receive the window closing event.

    I'm not sure I understand why any "cleanup" code would need to use SwingUtilities.invokeLater() to do anything. Assuming this "cleanup method" was called in response to a WindowEvent, it's already being called on the EDT.
    IIRC, my approach to this "problem" was to set the JFrame to DO_NOTHING_ON_CLOSE. I create a "doExit()" method that does any cleanup and exits the application (and possibly allows the user to cancel the app closing, if so desired). Then I create a WindowListener that calls doExit() on windowClosingEvents, and have my "exit action" call doExit() as well. Seems to work fine for me.

  • How to create printable report from a swing app.

    Hi,
    I have googled quite a bit and have searched the forum extensively but haven't found answers to my questions.
    I have a small swing based application (that uses jtextfields, jbuttons, jlist, etc) that collects information from user
    and stores in some variables; which are like strings, integers, hashmap, etc.
    Now this information is to be formatted and is to be printed as a report.
    Formatted as in, some part of the collected text is to be printed in certain font and other in different color and so on.
    Also the report is to be printed on a paper leaving some space at left and at the top. That means margins need to be set.
    And before all info is to be sent to printer I need to display this information in some report viewer (preview).
    How can I format certain text and set margins? (Is there some Document kind of api which allows me to set margins, change font of certain text?)
    How should I display this text / information as a print preview? (Should I use jeditorpane / jtextpane ?)
    How should I send all the information to the printer? (What java api should be used for printing?)
    The data entered by the user is not saved / persisted to any database. It's to be sent to the printer after submit button is pressed on the swing app.
    Since there is no database I couldn't use jasper-reports.
    Following are links to all threads (not useful) I found when I searched for swing / print / report in the forum :
    http://forums.sun.com/thread.jspa?forumID=331&threadID=225351
    http://forums.sun.com/thread.jspa?forumID=57&threadID=576758
    http://forums.sun.com/thread.jspa?forumID=57&threadID=570629
    http://forums.sun.com/thread.jspa?forumID=1&threadID=489905
    http://forums.sun.com/thread.jspa?forumID=57&threadID=571093
    http://forums.sun.com/thread.jspa?forumID=257&threadID=138450
    http://forums.sun.com/thread.jspa?forumID=57&threadID=583150
    http://forums.sun.com/thread.jspa?forumID=57&threadID=5399572
    http://forums.sun.com/thread.jspa?forumID=57&threadID=579619
    http://forums.sun.com/thread.jspa?forumID=57&threadID=593199
    Help would be much appreciated.

    alan_mehio wrote:
    The simplest thing to do in your case is to load the file content into the JTextArea
    then to create the header and the footer if there is any from java.text.MessageFormat
    then you invoke the print method on the JTextArea instance object> Just let me know if you are face any furrher problem
    Alan Mehio,
    I have been able to set margins and get the printout just the way I want it (after some experiments / trial & error).
    But the problem is, parameters to paper.setImageableArea() are hard coded as in the example code below :
            System.out.println("print?");
            PrinterJob printJob = PrinterJob.getPrinterJob();
            if (printJob.printDialog()) {
                PageFormat pf = printJob.defaultPage();
                Paper paper = pf.getPaper();
                paper.setSize(8.5 * 72, 11 * 72);
                System.out.println("paper width : " + paper.getWidth());// expecting 612
                System.out.println("paper height : " + paper.getHeight());// expecting 792
                System.out.println("ImageableHeight : " + paper.getImageableHeight());
                System.out.println("imageable width : " + paper.getImageableWidth());
                System.out.println("ImageableX : " + paper.getImageableX());
                System.out.println("Imageable y : " + paper.getImageableY());
                //paper.setImageableArea(108, 144, paper.getWidth() - 108, paper.getHeight() - 144);
                paper.setImageableArea(222, 244, paper.getWidth() - 222, paper.getHeight() - 244);
                pf.setPaper(paper);
                printJob.setPrintable(jTextArea1.getPrintable(null, null), pf);
                try {
                    printJob.print();
                } catch (Exception ex) {
                    System.out.println("exception while printing...");
                    ex.printStackTrace();
            }In my case the left margin should be 1.5 inches (38.1mm) and top margin should be 2 inches (50.8 mm)
    Considering 72dpi printer for a A4 size page (8.5in X 11in), the parameters to paper.setImageableArea() should be
    (108, 144, paper.getWidth() - 108, paper.getHeight() - 144);
    But the printout leaves only 1inch for top and left margins.
    Here are o/p lines for method-call with above said params :
    paper width : 612.0
    paper height : 792.0
    ImageableHeight : 648.0
    imageable width : 468.0
    ImageableX : 72.0
    Imageable y : 72.0
    When I pass the following values I get text printed with desired margins on the paper but the above printlns remain exactly the same!
    paper.setImageableArea(222.4, 244, paper.getWidth() - 222.4, paper.getHeight() - 244);
    Although I have been able to achieve what I wanted to without using 3rd party libraries,
    I feel this hard coding of values isn't a good idea and leaves a doubt whether this will work on other systems with different printers.
    My question is, how to get these numbers correct every time? Is there a formula for obtaining these numbers?
    Also formatting of certain part of to-print text is something that is yet to be figured out.
    Thanks.

  • How to restrict the ordering of apps from within an app

    My grandkids somehow run up charges by ordering apps from within an app they are using usually games  without even knowing they are doing it. How do I restrict them from doing it?  And how do I get the charges to Itunes removed when this happens?

    You can go into settings, and restrictions and turn off 'in app purchases'
    You may also want to set your apple id from 'require after 15 minutes' to 'require immediately'
    As to getting the charges reversed you can contact the app developer. Maybe they will reverse the charges, but they don't have to. The terms of sale are that all sales are final.

  • How make Swing app Rotated 90 Deg? i.e. On its side

    I want to make my entire swing app (including buttons, JTextArea, etc) rotated 90 deg to the right. I know this sounds weird, but I want to do it for a PDA. I can use swing on a PDA (check on google for swing personal java) and I want to be able to have the screen the long width.
    Does anyone know how I can do this?

    I can suggest some solution but it has not been proved to work. So just read it and make your own component carefully.
    First, subclass the Swing-widget to be rotated and name it RButton or whatever.
    Then, draw the content on a new BufferedImage instance and use AffineTransform to draw this BufferedImage onto the original Graphics context. Here is the example code.public class RButton extends javax.swing.JButton {
      public void paintComponent( Graphics g ) {
        // 1. create a new BufferedImage to draw on.
        BufferedImage bi = new BufferedImage( this.getWidth(), this.getHeight(), BufferedImage.TYPE_INT_RGB );
        // 2. draw the content (using JButton's paintComponent())
        super.paintComponent( bi.getGraphics() );
        // 3. save the old transformation matrix
        Graphics2D g2 = (Graphics2D)g;
        AffineTransform oldTransform = g2.getTransform();
        // 4. set the rotation transformation matrix
        g2.setTransform( AffineTransform.getRotateInstance( Math.toRadians( /*degree*/ ) ) );
        // 5. draw the BufferedImage on 'g'
        g2.drawImage( bi, 0, 0, this );
        // 6. reset the old transformation matrix
        g2.setTransform( oldTransform );
    }And this suggestion will just rotate the drawn content. You have to resize and rearrange those Rxxx components you've created to fit with the rotated graphics.

  • How to pass Objects from Java App to JavaFX Application

    Hello,
    New to the JavaFX. I have a Java Swing Application. I am trying to use the TreeViewer in JavaFX since it seems to be a bit better to use and less confusing.
    Any help is appreciated.
    Thanks
    I have my Java app calling my treeviewer JavaFX as
    -- Java Application --
    public class EPMFrame extends JFrame {
    Customer _custObj
    private void categoryAction(ActionEvent e)   // method called by Toolbar
            ocsCategoryViewer ocsFX;    //javaFX treeviewer
            ocsFX = new ocsCategoryViewer();    // need to pass in the Customer Object to this Not seeing how to do it.
                                                  // tried ocsFX = new ocsCategoryViewer(_custObj) ;    nothing happened even when set this as a string with a value
    public class ocsCategoryViewer extends Application {
    String _customer;
    @Override
        public void start(Stage primaryStage) {
         TreeView <String> ocsTree;
         TreeItem <String> root , subcat;
      TreeItem <String> root = new TreeItem <String> ("/");
            root.setExpanded(true);
             ocsTree = new TreeView <String> (root);
             buildTree();     // this uses the Customer Object.
            StackPane stkp_root = new StackPane();
            stkp_root.getChildren().add(btn);
            stkp_root.getChildren().add(ocsTree);
            Scene scene = new Scene(stkp_root, 300, 250);
            primaryStage.setTitle("Tree Category Viewer");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void main(String[] args) {
            _customer = args[0];      // temporarily trying to pass in string.
            launch(args);

    JavaFX and Swing integration is documented by Oracle - make sure you understand that before doing further development.
    What are you really trying to do?  The answer to your question depends on the approach you are taking (which I can't really work out from your question).  You will be doing one of:
    1. Run your Swing application and your JavaFX application as different processes and communicate between them.
    This is the case if you have both a Swing application with a main which you launch (e.g. java MySwingApp) and JavaFX application which extends application which you launch independently (e.g. java MyJavaFXApp).
    You will need to do something like open a client/server network socket between the applications and send the data between them.
    2. Run a Swing application with embedded JavaFX components.
    So you just run java MySwingApp.
    You use a JFXPanel, which is "a component to embed JavaFX content into Swing applications."
    3. Run a Java application with embedded Swing components.
    So you just run java MyJavaFXApp.
    You use a SwingNode, which is "used to embed a Swing content into a JavaFX application".
    My recommendation is:
    a. Don't use approach number one and have separate apps written in Swing and Java - that would be pretty complicated and unwarranted for almost all applications.
    b. Don't mix the two toolkits unless you really need to.  An example of a real need is that you have a huge swing app based upon the NetBeans platform and you want to embed a couple of JavaFX graphs in there.  But if your application is only pretty small (e.g., it took less than a month to write), just choose one toolkit or the other and implement your application entirely in that toolkit.  If your entire application is in Swing and you are just using JavaFX because you think its TreeView is easier to program, don't do that; either learn how to use Swing's tree control and use that or rewrite your entire application in JavaFX.  Reasons for my suggestion are listed here: JavaFX Tip 9: Do Not Mix Swing / JavaFX
    c. If you do need to mix the two toolkits, the answer of which approach to use will be obvious.  If you have a huge Swing app and want to embed one or two JavaFX components in it, then use JFXPanel.  If you have a huge JavaFX app and want to embed one or two Swing components in it, use a SwingNode.  Once you do start mixing the two toolkits be very careful about thread processing, which you are almost certain screw up at least during development, no matter how an experienced a developer you are.  Also sharing the data between the Swing and JavaFX components will be trivial as you are now running everything in the same application within the virtual machine and it is all just Java so you can just pass data around as parameters to constructors and method calls, the same way you usually do in a Java program, you can even use static classes and data references to share data but usually a dependency injection framework is better if you are going to do that - personally I'd just stick to simply passing data through method calls.

  • What is a quick alternative to launching an enterprise DPS app if Apple Store rejects the App? We are under a major deadline and can't wait for Apple. We want to host the app elsewhere. How do we host our DPS app on our client's website?

    What is a quick alternative to launching an enterprise DPS app if Apple Store rejects the App? We are under a major deadline and can't wait for Apple to approve. We want to host the app elsewhere. How do we host our DPS app on our client's website? Thanks.

    Unless I misunderstand the question, you can't do what you're asking to do. Apple doesn't allow you to bypass their store and host public apps on a website. The exception is an enterprise app, which requires an Enterprise account with both Apple and Adobe. This type of enterprise app can be distributed only within the company. If that's what you want to do, you can learn more here:
    Digital Publishing Suite Help | Creating viewer apps for private distribution
    Distributing enterprise iOS viewer applications with Digital Publishing Suite | Adobe Developer Connection
    Another option is to add the development app to several devices and use those for your demo.

  • How can I move my iMovie app to "purchased" in my appstore account???

    how can I move my iMovie app to "purchased" in my appstore account???

    I would not recommend that you move iMovie files to the Time Capsule. You will not get sufficient performance for editing. For this reason, iMovie does not show the Time Capsule as an attached drive within iMovie.
    If you move these files using the Finder, you will likely make the projects unusable, because the links between the projects and events will be broken.
    Use a locally attached external hard drive tha is formatted as Mac OS Extended (journaled).
    See this User Tip for how to move the Events and Projects to a locally attached drive. (By locally attached, I mean a drive that is attached to your Mac via USB, Firewire, or Thunderbolt cables.)
    https://discussions.apple.com/docs/DOC-4141

  • In Lightroom mobile how can move photos within the collection????

    In Lightroom mobile how can move photos within the collection????

    What you can do is to move (or copy) a photo form one collection to another. This can be triggered via the top right app menu item from grid view. Same menu is available when you open up an image for editing. Hope that helps. -Guido

  • How do I set up my app to display its name in Chinese?

    Within my app-descriptor.xml
    <name>
            <text xml:lang="en">Appname</text>
            <text xml:lang="es">ESAppname</text>
            <text xml:lang="ch">背痛</text>
            <text xml:lang="zh_CN">背痛</text>
            <text xml:lang="zh_TW">背痛</text>
        </name>
    When the iPhone language is set to English, or Spanish, the app name is displayed correctly, but for Chinese Simplifled it reverts back to displaying the English name.
    Would anyone know how to achieve this?
    Using AIR 16 as 17 currently has bug issues for me.
    Thanks,
    Mark

    Thanks for replying Chris.
    Unfortunately though that had no affect but when reading your post I did spot another post which seems to work.
    <text xml:lang="zh_Hans">背痛</text>

  • I have purchased a from within an app. I submit my password for the app, and then my Apple ID.  I then get the following messages "Regrant failure _ please log in with the same user that has bought this app"  and that is followed  by "cant conn with IT _

    I have purchased an item from within the app PocketBible on my iPad.  However when I try to download it I am asked for my app User Name and Password and then my Apple ID and password.  I give both of these.  I then get a message which says Regrant failure - Please log in with the same user that has bought the app.  That is then followed by  Pocket Bible Alert - cannot connect to iTunes Store.
    Anybody got any ideas, both what the 1st alert means and how I get round the problem please.

    I had the same problem. My wife had the PocketBible on her Ipad 2 and she transferred ownership to me. I had to delete the app and reinstall it from the App store(logged in with my apple ID) and its working without a problem. I do not get those error messages when I attempt to Buy/Upgrade or Add/Remove books.

  • How do I know if an app uses password encryption?

    Hi,
    With all the apps in the App Store, how do I know what kind of security they use?  Will it be in the T's and C's before accepting the app?  I do try to read those, but I've missed this.  Here's the reason for my question.
    A few months ago I downloaded an App called ATT Call International which offered a lower rate for international calls.  I used it a few times, it bills to a credit card.  This morning I tried to use it and I didn't remember my password.  I was emailed a new password which I copied and pasted into the browser but it still wouldn't let me in.  I called the support number for the ATT app and the agent asked me what I wanted my new password to be.  That was odd, but I made up a temp password to work with her and we got me signed on.  I immediately went in to change my password but the app wouldn't let me.
    I called back, got the same woman who told me that even if I do change my password, it's not encrypted so she can see it.
    Really?  And this is an ATT app?  She tells me that this is an ATT app but it's supported by a third party.
    So, I asked her to delete my account but I'm feeling VERY EXPOSED to think that in some database somewhere they have my credit card information and with an unencrypted password on my account. There is no delete option for me to delete it myself.
    What questions do I need to ask before I download?

    Eddie,
    To see what apps are "running" in the background, double click the HOME button (it's the round one at the bottom of the phone's front... not being sarcastic here, had to look at the manual myself just to be sure!). To me it's the coolest looking if done from one of the icon (desktop?) pages, as the dock will slide up and get grayed out, but i've done it from within open apps, it works but not nearly as neat looking to me! Anyhow, if you have a bunch open, you'll have to scroll them sideways to see all of them, plus there are ipod controls and a screen lock all the way to the left. To actually close out an app, press and hold one of them until they start shaking, like when you want to delete an app from your phone, the difference is there will be a "-" instead of an "x" on the icon and when you touch the icon it will disappear and stop "running".
    I put "running" in quotes, because from what i've read, some of the apps aren't really running, iOS4 has actually saved it's place in the app that you left off, but i'm pretty sure the gps type apps ARE working, using up precious memory and battery life.
    HTH
    John

  • How to add flex SDK to IntelliJ

    how to add flex free SDK to intelliJ6 or any IDE

    I don't have any issues with playing MP4. You must understand that mp4 should meet MP4 format requirements. If your video can't be played - this may be caused by issues with that mp4 video file but not Adobe Air.
    For example this AS3 code succesfully play mp4 video that meet mp4 requirements by format (not Adobe whimsy). Also you may note that StageVideo available on Direct render mode. Auto or CPU will not support native mp4 playing.
    package  {
        import flash.display.Sprite;
        import flash.net.NetConnection;
        import flash.net.NetStream;
        import flash.media.StageVideo;
        import flash.geom.Rectangle;
        public class sv extends Sprite {
            private var nc : NetConnection;
            private var ns : NetStream;
            private var client : Object = {};
            private var StageVideoContainer : StageVideo;
            public function sv() {
                client.onMetaData = onMetaDataCallback;
                nc = new NetConnection();
                nc.connect(null);
                ns = new NetStream(nc);
                ns.client = client;
                StageVideoContainer = stage.stageVideos[0];
                StageVideoContainer.attachNetStream( ns );
                StageVideoContainer.viewPort = new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
                ns.play("162447510.mp4");
            private function onMetaDataCallback(e:Object):void{
    Here is Windows 7 Adobe Air project config from Flash CC. MP4 works prefect!
    In this sample app I use Adobr Air 4.0.0.1390 from latest official release. You can chat to my skype therabbitwindfall and I will support you with my mp4 and Win7 project.
    P.S. this mp4 works fine on iOS also.

  • ServiceLocator for swing app

    can anyone show me way how to speedup ejb invocation from remote swing app?
    I read about servicelocator for jsp application, but can no find topic about remote swing app servicelocator.
    my network call to remote ejb methods is dramatically slow :(
    thanks !

    Yes, good question, on my remote app it is very slow too....

  • Flash SWF file within Swing JFrame

    I was wondering whether its possible to open a Flash swf file within a JFrame
    I am looking for a solution similar to the usage of Flash Activex control in .NET
    thanks in advance
    Vikas

    I have read the forum link and other such entries in this forum. I have found the following:
    1.) JFlash - a java based flash player. https://jflash.dev.java.net/
    Could'nt find the app or the official site
    2.) a few projects on sourceforge.org :
    java flash bridge where you embed the flash inside an Integrated Browser Component
    3.) SWT Flash integration.
    I do not find any of these solutions satisfactory.except the SWT/Flash integration which I havent tried.
    My question is that isnt there an easier and simpler way to :
    Embed Flash into Swing app where actionscript and java can communicate.
    I am aware of Remoting and web services. But It is a desktop app I am talking about.
    Can anyone suggest anything?
    thanks in advance..
    from a very frustrated programmer....

Maybe you are looking for

  • Media key is not working

    Hello Recently, the volume buttons, pause/play, fast forward and rewind media keys only work when I am on the Now Playing screen whereas they were working on every other screen in the past; even when my phone was locked. I don't know why it's suddenl

  • Access class variables on new operator

    Hi I've created a class with a few public final int's public class myClass(){ public final int SHOW_MENU = 1; public final int SHOW_STATUSBAR = 2; public myClass(int Flags){ now when I create this class I want to specify the flags by there logical na

  • Cs5 serial number not allowed for cs6 upgrade?

    hello I am trying to install CS6 Design Premium (via CD) and have CS5. However I am denied installation because my CS5 serial number is not allowed (it appears I must have CS5.5).  All phone lines are engaged. As well as frustrating, this would seem

  • The ringtone that rings isn't the one set in the active profile

    I have not linked any ringtone to any contact, yet in one of my profiles the ringtone that rings for all calls isn't the one that I have specified for that particular profile. How can I fix this?

  • Windows Media Components for Quicktime by Flip4Mac 2.2.2.3

    5-17-09 1 pm Eastern U.S.A. Hello to everybody. After checking the Flip4Mac Update area, it stated that the version that had been working fine since Nov. 08 was outdated and would I like to update to the newer version 2.2.2.3, I first investigated th