Results 1 to 3 of 3
  1. #1
    such orb is offline Member
    Join Date
    Mar 2012
    Posts
    24
    Rep Power
    0

    Default adding a JFXPanel to a JFrame

    i'm not sure if this is the correct forum... maybe i should have posted in the JavaFX forum?

    here's some code:

    Java Code:
    final JFXPanel coolpanel = new JFXPanel();
            coolpanel.setLayout(null);
            Color mycolor4 = new Color(200, 200, 200);
            Dimension d8 = new Dimension(100, 100);
            coolpanel.setSize(d8);
            coolpanel.setLocation(1800, 200);
            coolpanel.setPreferredSize(d8);
            coolpanel.getRootPane();
            coolpanel.setBackground(mycolor4);
            coolpanel.setVisible(true);
            coolpanel.setFocusable(true);
            coolpanel.validate();
            coolpanel.repaint();
            frame.add(coolpanel);
            frame.validate();
            frame.repaint();
    but the JFXPanel doesn't get drawn at all. do i need to use the following kind of code?


    Java Code:
    public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    initAndShowGUI();
                }
            });
    i am just looking for a swing-like/basic way of adding a JFXPanel to a JFrame. i'm using netbeans 7.2.1 and JDK 7 update 9.

    thanks!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: adding a JFXPanel to a JFrame

    Have you gone through the official documentation?
    JavaFX for Swing Developers

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    such orb is offline Member
    Join Date
    Mar 2012
    Posts
    24
    Rep Power
    0

    Default Re: adding a JFXPanel to a JFrame

    i had a brief look at the official documentation yesterday. i find these types of documentation difficult to understand at times... i'm usually not too good with the oracle documentation. i prefer "actual" code instead.

    can you recommend a JavaFX book to me? unfortunately, the "JavaFX for dummies" isn't due to be published for another year!

    is swing the way to go here? or should i switch to JavaFX?

    thanks again!

Similar Threads

  1. adding keylistener to JFrame
    By Alkor in forum New To Java
    Replies: 3
    Last Post: 03-08-2012, 01:02 PM
  2. Adding Swing JFrame form to an applet
    By diamonddragon in forum Java Applets
    Replies: 2
    Last Post: 02-06-2012, 07:18 AM
  3. Adding JButton to JFrame with background
    By bzknight in forum AWT / Swing
    Replies: 1
    Last Post: 01-19-2011, 07:55 PM
  4. Adding a KeyListener to a JFrame with buttons.
    By jamhead in forum AWT / Swing
    Replies: 1
    Last Post: 12-11-2010, 08:29 PM
  5. [SOLVED] Adding JLabel to JFrame
    By mlfatty in forum AWT / Swing
    Replies: 3
    Last Post: 03-05-2009, 12:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •