Embedding Swing Components within Javafx Scene (on a Mac)

Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
"Process manager already initialized: can't fully enable headless mode." (error attached below)
Currently using java 7 update 51, using java 8 is not an option unfortunately.
Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
Please let me know if providing other things would help. Thank you in advanced!

Currently I trying to embed swing components into javafx through steps located here: SwingNode The Myth not the reality | In-SideFX
Was able to get it working on a PC, however when the packaged jar is run on a mac, I end up with the "Headless exception"
"Process manager already initialized: can't fully enable headless mode." (error attached below)
Currently using java 7 update 51, using java 8 is not an option unfortunately.
Does anyone know of a work around to get this working in mac or possibly point me in the right direction?
Please let me know if providing other things would help. Thank you in advanced!

Similar Messages

  • How to use Swing Components in  JavaFX

    Hi All,
    I am new to JavaFx. I am trying to use java swing components in javafx.
    I found a sample program in net and tried it. But it shows compile time error.
    Code:
    MySwingComponent .fx
    import javafx.ext.swing.SwingComponent;
    import javax.swing.JComponent;
    import javax.swing.JButton;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    * @author nandha
    class MySwingComponent extends SwingComponent{
    var button: JButton;
    public var text: String on replace {
    button.setText(text);
    public var action: function();
    override protected function createJComponent () : JComponent {
    button = new JButton();
    button.addActionListener(ActionListener {
    public override function actionPerformed(e:ActionEvent){
    action();
    return button;
    The above code shows no error.
    Test SwingButton.fx
    import javafx.stage.Stage;
    import javafx.scene.Scene;
    import swingcomponents.MySwingButton;
    * @author nandha
    Stage {
    title: "Swing Button Example"
    scene: Scene {
    width: 250
    height: 80
    content: [
    MySwingButton{  // error message: imcompatible type. found MySwingButton. Required javafx.scene.Node[]
    text: "Click Me!"
    action: function(){
    println("Hello World!");
    This code which used the MySwingButton shows error: imcompatible type. found MySwingButton. Required javafx.scene.Node[] - where i have added the MySwingButton.
    Please help me to fix the error.
    Thanks &Regards,
    Nandha K

    Hi Sasa,
    First thanks for your reply.
    I found the problem and have fixed.
    Problem:
    There is no class MySwingButton in the package swingcomponents. Its MySwingComponent that i should have used, which is a big mistake that i have done. To my surprise i don't know NetBeans didn't show any error message at that line.
    Thanks & Regards,
    Nandha K

  • Swing components in applet not working in web browser

    Hi Guys,
    I've created an applet which makes use of some swing components, but unfortunately, not all of them function properly in my web browser (internet explorer or Mozilla Firefox). Its mainly the buttons; the last buttons works and displays the correct file within the broswer, but the first 5 buttons do not work...
    any help please on how I can sort this problem out?
    Heres the code for my applet:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.applet.*;
    public class MainAppWindow extends JApplet
    int gapBetweenButtons = 5;
    final JPanel displayPanel = new JPanel(new BorderLayout());
    public void init()
       //Panel for overall display in applet window.
       JPanel mainPanel = new JPanel(new BorderLayout());
       mainPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/smalllogo2.gif"))),BorderLayout.NORTH);
       //sub mainPanel which holds all mainPanels together.
       JPanel holdingPanel = new JPanel(new BorderLayout());
       //Panel for displaying all slide show and applications in.
       displayPanel.setBackground(Color.white);
       displayPanel.add(new JLabel(new ImageIcon(getClass().getResource("images/IntroPage.jpg"))),BorderLayout.CENTER);
       displayPanel.setPreferredSize(new Dimension(590,400));
       JPanel buttonPanel = new JPanel(new GridLayout(6,1,0,gapBetweenButtons));
       buttonPanel.setBackground(Color.white);
       JButton button1 = new JButton("User guide");
       button1.addActionListener(
         new ActionListener() {
              public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll(); // If there are any components in the mainPanel, remove them and then add label
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/UserGuide.jpg")));
                   displayPanel.revalidate(); // Validates displayPanel to allow changes to occur onto it, allowing to add different number images/applicaions to it.
       JButton button2 = new JButton("What is a Stack?");
       button2.addActionListener(
       new ActionListener() {
               public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/WhatIsAStack.jpg")));
                   displayPanel.revalidate();
       JButton button3 = new JButton("STACK(ADT)");
       button3.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StackADT.jpg")));
                   displayPanel.revalidate();
       JButton button4 = new JButton("Stacks in the Real World");
       button4.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.setBackground(Color.white);
                   displayPanel.add(new JLabel(new ImageIcon("images/StacksInTheRealWorld.jpg")));
                   displayPanel.revalidate();
       JButton button5 = new JButton("DEMONSTRATION");
       button5.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                 if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                 Demonstration app = new Demonstration();
                 JPanel appPanel = app.createComponents();//gets the created components from Demonstration application.
                 appPanel.setBackground(Color.pink);
               displayPanel.add(appPanel);
               displayPanel.revalidate();
       JButton button6 = new JButton("Towers Of Hanoi");
       button6.addActionListener(
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                     if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                     TowerOfHanoi app = new TowerOfHanoi();
                     JPanel appPanel = app.createComponents();//gets the created components from Towers of Hanoi
                     JPanel mainPanel = new JPanel();//panel used to centralise the application in center
                     mainPanel.add(appPanel);
                     mainPanel.setBackground(Color.pink); //sets mainPanel's background color for 'Towers Of Hanoi'
                     displayPanel.add(mainPanel);
                     displayPanel.revalidate();
       //adding buttons to the buttonPanel.
       buttonPanel.add(button1);
       buttonPanel.add(button2);
       buttonPanel.add(button3);
       buttonPanel.add(button4);
       buttonPanel.add(button5);
       buttonPanel.add(button6);
       JPanel p = new JPanel(); // Used so that the buttons maintain their default shape
       p.setBackground(Color.white);
       p.add(buttonPanel);
       holdingPanel.add(p,BorderLayout.WEST);
       holdingPanel.add(displayPanel,BorderLayout.CENTER);
       //Positioning of holdingPanel in mainPanel.
       mainPanel.add(holdingPanel,BorderLayout.CENTER);
       //indent mainPanel so that its not touching the applet window frame.
       mainPanel.setBorder(BorderFactory.createEmptyBorder(10,20,10,20));
       mainPanel.setBackground(Color.white);
       mainPanel.setPreferredSize(new Dimension(850,600)); //size of applet window
       mainPanel.setOpaque(false); // Needed for Applet
       this.setContentPane(mainPanel);
    }

    Thanks for the response. I don't quite understand what you're talking about though. I have, in my humble knowledge, done nothing with packages. I have put the applet class (WiaRekenToolActiz.class is the applet class) in the jar file wia_actiz_archive.jar. From what I read on the tutorial, java looks for the applet class in all the jar files specified. Since I put my CODEBASE as the main url, I thought it baiscally didn't matter where you out the html file.
    I shall include the complete html page complete with applet tag to perhaps illuminate a bit more what I mean...
    <html>
    <head>
    <title>Wia Rekenmodule hello!</title>
    </head>
    <body bgcolor="#C0C0C0">
    <applet
    CODEBASE= "http://www.creativemathsolutions.nl/test"
    ARCHIVE= "Actiz/wia_actiz_archive.jar, Generic/wia_archive.jar"
    CODE="WiaRekenToolActiz.class" 
    WIDTH=915 HEIGHT=555
    >
    <PARAM NAME = naam VALUE = "Piet Janssen">
    <PARAM NAME = gebdag VALUE = "01">
    <PARAM NAME = gebmaand VALUE = "06">
    <PARAM NAME = gebjaar VALUE = "1970">
    <PARAM NAME = geslacht VALUE = "man">
    <PARAM NAME = dienstjaren VALUE = "10">
    <PARAM NAME = salaris VALUE = "56500">
    <PARAM NAME = deeltijdpercentage VALUE = "100">
    <PARAM NAME = accountnaam VALUE = "Zorginstelling 'De Zonnebloem'">
    </applet>
    </body>
    </html>

  • I can't use swing components in my applets

    When I write an applet without any swing components, my browser never has any trouble finding the classes it needs, whether they're classes I've written or classes that came with Java. However, when I try to use swing components it cannot find them, because it is looking in the wrong place:
    On my computer I have a directory called C:\Java, into which I installed my Java Development Kit (so Sun's classes are stored in the default location within that directory, wherever that is), and I store my classes in C:\Java\Files\[path depends on package]. My browser gives an error message along the lines of "Cannot find class JFrame at C:\Java\Files\javax\swing\JFrame.class"; it shouldn't be looking for this non-existent directory, it should find the swing components where it finds, for example, the Applet class and the Graphics class.
    Is there any way I can set the classpath on my browser? Are the swing components stored separately from other classes (I'm using the J2SE v1.3)?
    Thanks in advance.

    Without having complete information, it appears that you are running your applets using the browser's VM. Further, I assume you are using either IE or Netscape Navigator pre-v6. In that case, your browser only supports Java 1.1, and Swing was implemented in Java 1.2. You need to use the Java plug-in in order to use the Swing classes (see the Plug-in forum for more information), or else download the Swing classes from Sun and include them in your CLASSPATH.
    HTH,
    Carl Rapson

  • How to use List within javaFX(*.fx) script?

    How to use java.util.List within javaFX(*.fx) script?
    The following is my code in Java
    PDBFileReader pdbreader = new PDBFileReader();
              pdbreader.setPath("/Path/To/PDBFiles/");
              pdbreader.setParseSecStruc(true);// parse the secondary structure information from PDB file
              pdbreader.setAlignSeqRes(true);  // align SEQRES and ATOM records
              pdbreader.setAutoFetch(true);    // fetch PDB files from web if they can't be found locally
              try{
                   Structure struc = pdbreader.getStructureById(code);
                   System.out.println("The SEQRES and ATOM information is available via the chains:");
                   int modelnr = 0 ; // also is 0 if structure is an XRAY structure.
                   List<Chain> chains = struc.getChains(modelnr);
                   for (Chain cha:chains){
                        List<Group> agr = cha.getAtomGroups("amino");
                        List<Group> hgr = cha.getAtomGroups("hetatm");
                        List<Group> ngr = cha.getAtomGroups("nucleotide");
                        System.out.print("chain: >"+cha.getName()+"<");
                        System.out.print(" length SEQRES: " +cha.getLengthSeqRes());
                        System.out.print(" length ATOM: " +cha.getAtomLength());
                        System.out.print(" aminos: " +agr.size());
                        System.out.print(" hetatms: "+hgr.size());
                        System.out.println(" nucleotides: "+ngr.size()); 
              } catch (Exception e) {
                   e.printStackTrace();
              }The following is my code in JavaFX(getting errors)
    var loadbtn:SwingButton = SwingButton{
        text:"Load"
        action: function():Void{
            var pdbreader = new PDBFileReader();
            var structure = null;
            try{
                structure = pdbreader.getStructure(filepath.text);
                List<Chain> chains = structure.getChains(0);
                foreach (Chain cha in chains){
                        List < Group > agr = cha.getAtomGroups("amino");
                        List < Group > hgr = cha.getAtomGroups("hetatm");
                        List < Group > ngr = cha.getAtomGroups("nucleotide");
            } catch (e:IOException) {
                e.printStackTrace();
        };I'm using Netbeans 6.5 with JavaFX
    (PDBFileReader, Chain, Structure etc are classes from my own package, already added to the library folder under the project directory)
    Simply put, How to use List and Foreach in JavaFX?

    We can not use Java Generics syntax in JavaFX. But we can use Java Collection classes using the keyword 'as' for type-casting.
    e.g.
    import java.util.LinkedList;
    import java.util.List;
    import javafx.scene.shape.Rectangle;
    var outerlist : List = new LinkedList();
    var innerlist : List = new LinkedList();
    innerlist.add(Rectangle{
        width: 10 height:10});
    innerlist.add(Rectangle{
        width: 20 height:20});
    outerlist.add(innerlist);
    for (inner in outerlist) {
        var list : List = inner as List;
        for (element in list) {
            var rect : Rectangle = element as Rectangle;
            println("(width, height)=({rect.width}, {rect.height})");
    }

  • Multifont output in Swing components

    Hi there,
    though I'm not new to Java but I'm new to displaying different fonts in Swing components.
    I have an Swing-based application which is running on a Terminal Server. It works fine for Central, Western und Northern Europe. The next
    country to roll out is Greece. So what does a greek user see on his monitor when he uses his greek keyboard?
    I am writing a test app where I type german text into a JTextField and want to get e.g. the greek representation in another JTextField. How can I achieve this? Converting the bytearray with Cp1253 did not work
    Can anybody give me a hint?
    Thanks
    Dierk.

    as I wrote, it is a test app to learn how I get greek
    fonts on the screen. Of course the real app is used by
    greek users who put greek text into the system. In the
    system we do not use resource bundles as the GUI texts
    are stored in the database. It is a CMS for product
    information in different languages.Ah, I see... mind you, I don't think your German text would have a great deal of Cyrillic characters in them, right? Still, it's only a test! ;-)
    Now what I'm doing to get my german text in greek
    letters is this:
    utf8Bytes =
    = getorigTextField().getText().getBytes("UTF16");
    isr = new InputStreamReader(new
    w ByteArrayInputStream
    (utf8Bytes), "Cp1253");
    As far as I understand, the InputStreamReader gives
    the translation
    of my german letters in the encoding of CP1253
    (Windows Greek). That
    means the unicode characters change into the ones of
    the greek language
    so I should be able to show them in a Swing component.This is where your problem is. Java's Strings will always be in UTF-16 when they are held internally. So anything within a textfield is going to be UTF-16 no matter what you do with it.
    The line you think is converting to Cp1253 is actually trying to convert from Cp1253 to UTF-16.
    Hopefully this is the reason your characters aren't appearing - the unneeded conversion above could be mashing them. Instead, you need expect everything to always be in UTF-16, and to expect to display in it (don't worry, it handles any character you can throw at it, let alone Greek). So then it all comes down to the font you're using.
    I'm not too sure of the name of the Windows default Cyrillic font, but that would be a logical starting point.
    Hope that helps!
    Martin Hughes

  • Release memory from Swing components

    Ive experiencing memory leak when using swing components in a custom node object.
    When I set the node to null or just delete it from my group node the garbage collector kicks in but when I add a swing component the memory clogs up quickly.
    Ive been using the code below for adding a swing component:
    insert textField = SwingTextField {
    columns: 20
    borderless: false;
    width: beginBalk - 5;
    height: 30;
    enabled:false;
    text: "Sample text";
    editable: false;
    } into grp.content;
    grp is a common Group node and other component are added aswell.
    The complete group node is added to another group which if I want to refresh I use:
    delete grp from rootGrp.content;
    rootGroup is the other group node that is added to a scene.
    I works fine without the swing components so it has got nothing to do with other objects in the group.
    Hope anyone has the solution for this,

    Hi Hugo,
    I'haven't got the solution but perharps the way for destructing the SwingComp can be different.
    Has I understood the jvm keep object in survival space until it is referenced by the program.
    So If you use
    delete comp for group.contentthe jvm probably keep a reference on the comp object.
    You can try
    delete group.content[idx]instead, then you can adjust jvm garbage collection if the problem persists.

  • Need help with using graphics in swing components

    Hi. I'm new to Java and trying to learn it while also developing an application for class this semester. I've been following online tutorials for about 2 months now, though, and so I'm not sure my question counts as a "new to Java" question any more as the code is quite long.
    Here is the basic problem. I started coding the application as a basic awt Applet (starting at "Hello World") and about a month in realized that Swing components offer better buttons, panels, layouts, etc. So I converted the application, called BsfAp, to a new JApplet and started adding JPanels and JComponents with layout managers. My problem is, none of the buffered graphics run in any kind of JPanel, only the buttons do. I assume the buffered graphics are written straight to the JApplet top level container instead but I'm not entirely sure.
    So as to not inundate the forum with code, the JApplet runs online at:
    http://mason.gmu.edu/~dho2/files/sensor.html
    The source code is also online at:
    http://mason.gmu.edu/~dho2/files/BsfAp.java
    What I would like to do is this - take everything in the GUI left of the tabbed button pane and put it into a JScrollPane so that I can use a larger grid size with map display I can scroll around. The grid size I would like to use is more like 700x1000 pixels, but I only want to display about 400x400 pixels of it at a time in the JScrollPane. Then I could also move this JScrollPane around with layout manager. I think this is possible, but I don't know how to do it.
    I'm sure the code is not organized or optimized appropriately to those of you who use Java every day, but again I'm trying to learn it. ;-)
    Thanks for any help or insight you could provide in this.
    Matt

    Couple of recs:
    * Don't override paint and paint directly on the JApplet. Paint on a JPanel and override paintComponent.
    * The simplest way to display a graphic is to put an image into an ImageIcon and show this in a JLabel. This can then easily go inside of the JScrollPane.
    * You can also create a graphics JPanel that overrides the paintComponent, draw the image in that and show that inside of the JScrollPane.
    * don't call paint() directly. Call repaint if you want the graphic to repaint.
    Here's a trivial example quickly put together:
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GradientPaint;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Paint;
    import java.awt.RenderingHints;
    import java.awt.geom.Ellipse2D;
    import java.lang.reflect.InvocationTargetException;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.SwingUtilities;
    public class BsfCrap extends JApplet
        private JPanel mainPanel = new JPanel();
        private JScrollPane scrollPane;
        private JPanel graphicsPanel = new JPanel()
            @Override
            protected void paintComponent(Graphics g)
                super.paintComponent(g);
                Graphics2D g2d = (Graphics2D)g;
                RenderingHints rh = new RenderingHints(
                    RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
                g2d.setRenderingHints(rh);
                Paint gPaint = new GradientPaint(0, 0, Color.blue,
                    40, 40, Color.magenta, true);
                g2d.setPaint(gPaint);
                g2d.fill(new Ellipse2D.Double(0, 0, 800, 800));
        public BsfCrap()
            mainPanel.setPreferredSize(new Dimension(400, 400));
            mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
            graphicsPanel.setPreferredSize(new Dimension(800, 800));
            graphicsPanel.setBackground(Color.white);
            scrollPane = new JScrollPane(graphicsPanel);
            scrollPane.setPreferredSize(new Dimension(300, 300));
            mainPanel.add(scrollPane);
        public JPanel getMainPanel()
            return mainPanel;
        @Override
        public void init()
            try
                SwingUtilities.invokeAndWait(new Runnable()
                    public void run()
                        setSize(new Dimension(400, 400));
                        getContentPane().add(new BsfCrap().getMainPanel());
            catch (InterruptedException e)
                e.printStackTrace();
            catch (InvocationTargetException e)
                e.printStackTrace();
    }

  • I'd like to make a list of interactive Swing components....

    EDIT: I've been doing more research about Layout Managers and it appears that BoxLayout may provide me with the solution I need. I'll mess around with it for awhile and report back if I still need help. Thanks pals!+
    I would like to make a list of JPanels laid out in basically a column. One on top of the other. That's not so difficult, but I need to make it able able to add and remove panels in response to user-driven events (in other words, I can't just hard-code them all, and the panels are generated on the fly, so I don't even know how many I'll need to be displaying until I need to display them.
    Here's a simple mockup of the window I'm talking about.
    |      - o x |
    |____________|
    |            |
    |            |
    |   Panel1   |
    |   Panel2   |
    |   Panel3   |
    |   Panel4   |
    |____________|At first, I thought a JList would serve my purpose, but you can't add interactive Swing components to JLists (or JTables)... they'll render, but that's all. My panels will contain a button and a checkbox, so this is a no-go.
    I was also thinking I could just manage the placement with GridBagLayout and just keep indexes for the current y position, but if there's an easier way, I'd rather not go this route. It has me writing a lot of extra code and manipulating a lot of fields of GridBagConstraints, which opens me to less-understandable code and more error-prone code, on account of I'm great at making little mistakes when I'm setting craploads of constraints.
    Does anyone have any ideas? It'd be ideal if there was just some sort of container I could plop them in with add and remove methods (a la JTabbedPane or something).
    I'm pretty new to Swing, so maybe I'm missing something obvious.
    Edited by: Caryy on Sep 30, 2010 4:15 PM

    I would recommend using BoxLayout or Box.createVerticalBox(). As mKorbel already mentioned, you need to call revalidate() after adding any component to an already realized/visible container, and additionally call repaint() after removing a component. To resize the top level window to accommodate its new content, you would call pack(). Or, again as suggested by mKorbel, wrap your panel/Box in a JScrollPane.
    db

  • Showing swing components in the palette og jdeveloper

    hello, I have found a problem with jdeveloper, as a user uses jdeveloper since 2 years I have never found a problem like this. (IDE problem).
    like habitude I created a simple java project which contains a jframe and an entry class (main class), but when I try to drag and drop from the component palette somes swing components I didn't find
    the page of swing components ( I found in the components palette just "my components" page in the jcombobox selection category). this problem will delay a big project and causes big problems
    please any person who know some things help me as soon as possible.
    Best Regards.

    Check this post -
    showing palette containing JButton,JLabel,JPanel ... components

  • About the difference between the AWT components and the swing components

    As we know that an AWT component has a peer, but dose a lightweight component(e.g: a swing component) has also a peer? And could somebody tell me that who and how creates the CLICKED_EVENT when I click a JButton(a swing component), and where the CLICKED_EVENT to go util it was processed by a method like btn_ok_clicked(Event e)? And if I click a Button(an AWT component), what's the difference?
    Thanks a lot!

    The main difference is that AWT are native components, and Swing components are entirely in java written. That's besides the look and feel. There are a lot of other differences between AWT and Swing, and there are better described in the documentation.

  • How to position the Swing button on javaFx applet

    Hello,
    I am putting a swing button on javaFx page as:
    SwingButton {
                    text: "Go"
                    action: function() {
                        widgetManager.openDirectAlertId(homeBean.getAlert(1).getAlertId());
                }This button always appear on the top of the page.Now, i want to align this button to X and Y coordinates.
    I have two variable varX and varY, how can i bind this button to these coordinates?
    Thanks to reply
    Anuj

    Use translateX and translateY attributes:
                SwingButton {
                    text: "Go"
                    translateX: 50
                    translateY: 10
                    action: function() {
                        widgetManager.openDirectAlertId(homeBean.getAlert(1).getAlertId());
                }       

  • Hindi Numerals and Hejri calender in swing components

    Hi
    Are Hindi numerals and Hejri calender supported in JDK 1.4 swing components or not?
    Please I need this as soon as possible.
    Thanks in advance
    Marwa Aboulfadl

    hello!
    I am developing an arabic editor but i am unable to display the arbic numeric in swing text .Plz help me on this topic and send some code example on this topic.
    I have another problem about events i.e how can i handle the beckspace event, enter event, and spaceevent?
    plz send me mail .
    Thanx for advance.

  • Swing components not displaying correctly in JApplet

    Hello everyone,
    I have experienced some strange problems using Swing components on JApplets. Maybe I missed some documentation somewhere and someone can help me out.
    The problem is that when I add components like JButtons,
    JCheckboxes, JRadioButtons, JTextFields, JPasswordFields,
    and JComboBoxes to JApplets, when I view the applet, the
    component does not become visible until I move the mouse
    pointer over it in the case of buttons. For the JComboBox I have
    to hit the mouse key many times on the component to see the list. Has anyone experienced problems like these? Thanks.
    Keith

    check what is in ur paint(Graphic g) method. if it does nothing, remove the paint(Graphic g) method. if it has some codes, double check ur codes.

  • Swing Components not displaying in a JFrame

    Hi,
    I have a JFrame with a couple of JLabels, JButtons etc. and a Choice Combo Box
    my problem is that when i run the program the only component that gets displayed at first is Choice and in order for me to see the swing components i have to roll over them with my mouse and the JLabels dont even display when i do that..
    Does anyone know how i can fix this please?
    here is my code
    import java.awt.*;
    import java.awt.event.*;
    import java.lang.*;
    import java.awt.Image.*;
    import java.io.*;
    import java.net.*;
    public class ImageViewerAnim extends JFrame {
         private JLabel perc, scale;
         private JTextField inPercent;
         private JButton draw, muteOn;
         private JPanel sPanel;
         private String[] pics = {"Earth", "Moon", "Jupiter", "Pluton", "Neptun"};
         private String[] picsFile = {"images/earth.gif", "images/moon.gif", "images/jupiter.jpg", "images/pluton.jpg", "images/neptun.jpg"};
         private String[] soundsFile = {"sounds/tada.wav", "sounds/notify.wav", "sounds/ding.wav", "sounds/chimes.wav", "sounds/chimes.wav"};
         private Choice ch;
         private Image pic;
         private AudioClip sound = null;
         private int scaleAm = 0;
         private int origScale = 500;
         private int finalScale = 0;
         private boolean proceed = true;
         public ImageViewerAnim() {
              Container c = getContentPane();
              c.setLayout(new BorderLayout());
              sPanel = new JPanel();
              ch = new Choice();
              for(int i = 0; i < pics.length; ++i) {
                   ch.add(pics);
              scale = new JLabel("Scale");
              perc = new JLabel("%");
              inPercent = new JTextField(5); // scale value input field
              draw = new JButton("Draw");
              draw.setBorder(BorderFactory.createEtchedBorder());
              draw.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        int index = 0;
                        index = ch.getSelectedIndex();
                        pic = null;
                        repaint();
                        pic = (Toolkit.getDefaultToolkit().getImage(picsFile[index]));
                        try{
                        File f = new File(soundsFile[index]);
                        sound = Applet.newAudioClip(f.toURL());
                        }catch(MalformedURLException mfe) {
                             mfe.printStackTrace();
                        if(!inPercent.getText().equals("")) {
                             scaleAm = Integer.parseInt(inPercent.getText()); // get the scale amount from the user
                             finalScale = ((origScale * scaleAm)/100); // calculate the final scale amount based on what the user entered
                        }else {
                             finalScale = origScale; // default to original size of the image if no value for scale was entered
                        // creates a scaled instance of an image and takes the amount of scale as an argument
                        repaint();
                        sound.loop();
              muteOn = new JButton("Mute On");
              muteOn.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        sound.stop();
                        muteOn.setText("MuteOff");
              sPanel.add(ch);
              sPanel.add(scale);
              sPanel.add(inPercent);
              sPanel.add(perc);
              sPanel.add(draw);
              sPanel.add(muteOn);
              c.add(sPanel, BorderLayout.SOUTH);
              repaint();
    public void paint(Graphics g) {
         if(pic!=null) {
              g.drawImage(pic,0,0,this);
    public static void main(String args[]) {
         ImageViewerAnim app = new ImageViewerAnim();
         app.setSize(500,500);
         app.setVisible(true);
         app.setDefaultCloseOperation(EXIT_ON_CLOSE);
         app.show();
    thank you in advance
    Ivo

    for future reference
    i was able to fix this by adding
    super.paint(g);in the first line of my paint method
    Ivo

Maybe you are looking for

  • Returning error messages from media server

    My application requires that I can get detailed feedback from the FMS upon a given failure. For instance, if I try to open a stream who's file does not exist, is it possible to have a message or error code returned to Flash so that I can deal with th

  • Removing non-numeric characters from string

    Hi there, I need to have the ability to remove non-numeric characters from a string and I do not know how to do this. Does any one know a way? Example: Present String: (02)-2345-4607 Required String: 0223454607 Thanks in advance

  • Loosing connection to my iMac drive

    Hello Support Community, I have an late 2012 late model iMac and a 13in Retina pro MacBook Pro. I do a lot of graphics work and what I used to do (before upgrading my MacBook) is do most of my graphics work on my iMac, but sometimes want to sit on th

  • How get DOCTYPE name when parsing XML Doc?

    My XML document has this: <!DOCTYPE Users SYSTEM "Users.dtd" []> So the name of this document's type is "Users", i.e. it is a Users document. However, I cannot figure out how to get that during parsing! I have set the following (and implemented all t

  • ADPRECLONE.PL PREPARE THE SOURCE SIDE EFFECT

    we want to clone our production server (24/7) server and as far as we know that when you Prepare the source system tiers for cloning it will chage things on it like some profile option, workflow ...etc. so since its an prodction system i would like t