How to add swing components in an applet

hello friends;
I encounterd one problem that is I created one applet which I derived from JApplet and now I want to add some swing components to that applet. I added them properly and when I am testing my applet in Appletviewer it is working fine but when I tested it in internet explorer it is not working. Please help me overcome this problem
Thanks in advance.

IE does not support swing if you do not have the java-plugin installed. Either install that, then IE can display Swing components - or use AWT which can be displayed by IE.

Similar Messages

  • How to add scroll function in  the applet launched by  Java Web Start?

    I have Java Web Start installed in order for the applet to launch.The applet size: width:700 height:1000
    my compuer resolution:800*600
    the applet launched by Java Web Start can only be seen partly,especially height.How to add scroll function in the applet launched by Java Web Start?
    Thanks for help.
    email:[email protected]

    You can very easily add a JScrollPane manually between the Applet and your content. Perhaps it would be beter if javaws did this automatically. In the browser, an applet can be any size. In Java Web Start an applet is directly contained within a JFrame, so it cannot be smaller than the minimum size of a JFrame, or Larger than the max.

  • 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.
    Carl Rapson

  • Swing components without using applets

    hi there
    can i display swing components on the browser without using applets through jsp.
    if the answer is yes.please help me by sending a sample code.thanking u.

    A JSP is compiled into a (server-side, obviously) servlet, which responds to Http requests by constructing a String of HTML/JavaScript etc to send back to the browser which then displays it.
    A Swing component is a piece of Java. The only way for such a component to run on the client side is to use either Applets or the new Java WebStart technology (see the JDC), which allows you to run a Java App locally from a Web Browser.
    You cannot possible use JSP to view Swing Components, without also using either of the above.

  • 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.
    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 {
    public var action: function();
    override protected function createJComponent () : JComponent {
    button = new JButton();
    button.addActionListener(ActionListener {
    public override function actionPerformed(e:ActionEvent){
    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.
    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

  • Not getting swing components when the applet reloads

    I am facing one problem that is related to reloading of swing components. I Have a JPanel inside JApplet which contains some swing components and a button to launch the same JPanel again in the JApplet. When I click on the button the JPanel should get added in the JApplet once again below the upper JPanel. But new JPanel is not getting displayed although the reference of the new JPanel is created.

    My guess is that you haven't added your swing components to the right place. Are you adding them to the contentpane?

  • How to add a components in Visual Administrator??

    Hi all,
    how can I add a component in the Security Provider service inside the Visual Administrator??
    Thanks all.

    Solved on my own.

  • How to add wifi password from nm-applet to kdewallet

    I would ask you for help. I followed solution on www in order to disable password check-in on every boot by kdewallet. Changed kdewallet password for blank password, then i deleted kdewallet. After that i found that my wifi won't connect. I have to delete wifi network, add new one, enter password each time on every single boot. I want to restore kdewallet with password for wifi so i created new kdewallet but it won't store password from nm-applet, wifi  network.
    For the very first time kdewallet asked if i want to store password, the one new created don't ask for this, so i thinkl it is why he won't store password. Is there a way to fix it in order kdewallet to store password for wifi, like the first one, that opened on every boot? I don't wan't to delete my wifi network, create it again in order to connect.

    Thank you for answer. Yes, i did that. I deleted wallet from kde4 but result is the same. I create new one, but there is no question for storing password there (example: when using wifi that is password protected i have to enter password, no question if i would like to store it)
    Sorry forum bumping. Won't happen again.
    Last edited by firekage (2013-08-06 15:56:44)

  • Swing components and Mac OS/9

    Hi all,
    I 've developped an app using swing components (Simple app using a hsqlbd database) and i read that it was kind of possible to port it on a mac os/9.
    I had a look on the net, on the apple site, without any luck as how to "add" swing library on the mac os/9.
    If someone could point me to the right direction (Web site, book etc), I 've been looking for a while without finding any clear and precise info on how to tackle this kind of problem.
    Thanks in advance.

    As per my knowledge, u can use JJEdit editor on MAC OS X. By using this editor, you can run the applets. Here I am using JJEdit as a java editor on MAC OS X. just dowload the JJEdit. and run the applet on it.
    nr konjeti

  • 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.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));
       JButton button1 = new JButton("User guide");
         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.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?");
       new ActionListener() {
               public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.add(new JLabel(new ImageIcon("images/WhatIsAStack.jpg")));
       JButton button3 = new JButton("STACK(ADT)");
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.add(new JLabel(new ImageIcon("images/StackADT.jpg")));
       JButton button4 = new JButton("Stacks in the Real World");
       new ActionListener() {
             public void actionPerformed(ActionEvent e)
                   if(displayPanel.getComponents().length > 0)displayPanel.removeAll();
                   displayPanel.add(new JLabel(new ImageIcon("images/StacksInTheRealWorld.jpg")));
       JButton button5 = new JButton("DEMONSTRATION");
       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.
       JButton button6 = new JButton("Towers Of Hanoi");
       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.setBackground(; //sets mainPanel's background color for 'Towers Of Hanoi'
       //adding buttons to the buttonPanel.
       JPanel p = new JPanel(); // Used so that the buttons maintain their default shape
       //Positioning of holdingPanel in mainPanel.
       //indent mainPanel so that its not touching the applet window frame.
       mainPanel.setPreferredSize(new Dimension(850,600)); //size of applet window
       mainPanel.setOpaque(false); // Needed for Applet

    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...
    <title>Wia Rekenmodule hello!</title>
    <body bgcolor="#C0C0C0">
    CODEBASE= ""
    ARCHIVE= "Actiz/wia_actiz_archive.jar, Generic/wia_archive.jar"
    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'">

  • How to list/access swing components?

    hi all,
    Can anyone give me a clue, how can I access or simply list swing components I have on a frame, long after I created them. E.g. I'd like to change their setEnabled() attribute at a later time, not at creation time, but I don't know how to access them.
    Does Swing/AWT/JFC provides a component hierarchy? can someone share some code on this issue?
    Thanks for any help.

    I guess, you are saying the use of getComponent(int n)?
    Since I'm a beginner in Swing see my short code below:
    import java.awt.BorderLayout;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTextArea;
    public class EasyFrame {
        public EasyFrame() {
        public void startHere() {
            JFrame frame = new JFrame("SwingApplication");
            JButton button = new JButton("click here");
            JTextArea area = new JTextArea();
            frame.setSize(300, 200);
            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add(area, BorderLayout.CENTER);
            frame.getContentPane().add(button, BorderLayout.SOUTH);
            area.setText("Hello World");
            JMenuBar menuBar = new JMenuBar();
            JMenu menu = new JMenu("A Menu");
            JMenuItem menuItem = new JMenuItem("A text item");
            menuItem = new JMenuItem("hello");
            JMenu subMenu = new JMenu("submenu");
            menuItem = new JMenuItem("sub1");
            menuItem = new JMenuItem("sub2");
            frame.getContentPane().add(menuBar, BorderLayout.NORTH);
         public static void main(String[] args) {
         EasyFrame ef = new EasyFrame();
    }If I make a System.out.println(frame.getContentPane().getComponentCount());I get 3. But I should dig deeper (with getComponent(2)) to access JMenuBar. But this way I receive a AWT Component / not a JMenuBar Swing component to get its JMenu / and its JMenuItems. And I cannot make it cast to JMenuBar since this walk-through routine should be a universal while(isThereMoreCompenent){} procedure, I don't know when to cast to what (JMenu, JMenuItem, Button and so on).
    My problem is that how can I access the JMenuItems one by one, and change e.g. the setEnabled attribute of the "hello" menu?
    I hope you can make it clear to me.
    Please help if so.

  • Can't add in Swing components with Background

    Alright, so I'm trying to add a background to an application I made. Looking through a bunch of 'tutorials', I found what I was looking for. And after trying to add the components I had on the application back again over and over, failing each time, I decided to finally come here.
    Could anybody please tell me how I'd go about, where in the code, I would go about adding the components such as JLabels and JProgressBars again?
    Thanks in advance,
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class Main extends JFrame
         JScrollPane scrollPane;
         ImageIcon icon;
         JFrame mainFrame;
         JTextArea textArea;
         JProgressBar progressBar;
         public Main()
              mainFrame = new JFrame("WQI - Sending data");
              progressBar = new JProgressBar(0,100);
              progressBar.setPreferredSize(new Dimension(384,27));
             icon = new ImageIcon("ScapeGaming.jpg");
             textArea = new JTextArea() {
               Image image = icon.getImage();
               public void paintComponent (Graphics g) {
                 g.drawImage(image, 0, 0, this);
             scrollPane = new JScrollPane(textArea);
             Container content = mainFrame.getContentPane();
             content.add(scrollPane, BorderLayout.CENTER);
             mainFrame.setSize(404, 109);
         private void addComponent(Container container,Component c,int x,int y,int width,int height)
         public static void main(String [] args)
              Main frame = new Main();

    Yes, I did compile my code. It compiles fine.
    And could you please explain how using BufferedImage and ImageIO would change anything?
    Just to show a bit of what this topic is about, I guess:
    Note the progress bar. Without the progress bar-adding lines, the background is there. With it, the progress bar is added but the background disappears (goes back to the regular 'tannish' BG.
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.*;
    public class Main extends JFrame
         JScrollPane scrollPane;
         ImageIcon icon;
         JFrame mainFrame;
         JTextArea textArea;
         JProgressBar progressBar;
         public Main()
              mainFrame = new JFrame("WQI - Sending data");
              progressBar = new JProgressBar(0,100);
              progressBar.setPreferredSize(new Dimension(384,27));
             icon = new ImageIcon("ScapeGaming.jpg");
             textArea = new JTextArea() {
               Image image = icon.getImage();
               public void paintComponent (Graphics g) {
                 g.drawImage(image, 0, 0, this);
             scrollPane = new JScrollPane(textArea);
             Container content = mainFrame.getContentPane();
             content.add(scrollPane, BorderLayout.CENTER);
              addComponent(content, progressBar, 5, 5, 384, 27);
             mainFrame.setSize(404, 109);
         private void addComponent(Container container,Component c,int x,int y,int width,int height)
         public static void main(String [] args)
              Main frame = new Main();

  • How can I learn "Drag and Drop" with Swing components?

    Im using swing components, so using paint() to draw a "drag icon" doesnt seem acceptable. Im basically trying to move a JPanel image to be dragged/dropped over another JPanel in the same program/applet.
    I looked at Sun's Java Tutorial for information on doing drag and drop, but there was no trail completed yet.
    Does anyone know of any good resources to learn? Or can at least give me a general idea of how to do drag and drop?

    Did you see this?

  • How to add images into a java application (not applet)

    I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
    Thank you,

    Your' better off looking in the java 2d forum.
    package images;
    import java.awt.*;
    import java.awt.image.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    /** * LogoImage is a class that is used to load images into the program */
    public class LogoImage extends JPanel {
         private BufferedImage image;
         private int factor = 1; /** Creates a new instance of ImagePanel */
         public LogoImage() {
              this(new Dimension(600, 50));
         public LogoImage(Dimension sz) {
         public void setImage(BufferedImage im) {
              image = im;
              if (im != null) {
                        new Dimension(image.getWidth(), image.getHeight()));
              } else {
                   setPreferredSize(new Dimension(200, 200));
         public void setImageSizeFactor(int factor) {
              this.factor = factor;
         public void paintComponent(Graphics g) {
              //paint background 
              Graphics2D g2D = (Graphics2D) g;
              //Draw image at its natural size first. 
              if (image != null) {
                   g2D.drawImage(image, null, 0, 0);
         public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
              LogoImage logoImage = new LogoImage();
              BufferedImage image;
              try {
                   FileInputStream fileInput =
                        new FileInputStream("images/" + filename);
                   image =;
                   logoImage =
                        new LogoImage(
                             new Dimension(image.getWidth(), image.getHeight()));
              } catch (Exception e) {
              return logoImage;
         public static void main(String[] args) {
              JFrame jf = new JFrame("testImage");
              Container cp = jf.getContentPane();
              cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
    }Now you can use this class anywhere in your pgram to add a JPanel

  • How can I use two fonts in swing components?

    I want to implement a project. When a part of the JMenuBar, JButton or other swing components' text is English, I use Tahoma font, and other of these components' text is Chinese, I use SimSun font, just like the Chinese Windows OS. How can I implement it??

    Ooh, thats a tricky one. I'm not sure whether you can do that, but maybe someone else with more experienced can correct me.
    You'll probably have to create your own custom JMenu that displays two labels, one for English and one for the Chinese parts?

Maybe you are looking for

  • Itunes 10.5.2. hanging up during IPhone 4 Sync

    I have an Imac running OS 10.6.8 and am using Itunes 10.5.2. on same.  Ever since the recent unfortunate debut of Icloud and wifi syncing, I have been having nothing but tons of problems with Apple sync software creating thousands of duplicate entrie

  • How to lock playhead and scroll film strip, standard on adobe?

    It is normal while editing to have playhead stationary in the middle of a screen and to have the clips running underneath left or right. In playback my playhead/cursor keeps dissapearing of the monitor which is a pain! The clips/strip start to move o

  • Document streaming in jsp

    hi there, i'm trying to stream some pdfs to the user's browser so that the first page of the pdf displays whilst the rest of the document loads. i have been able to get this to work when i call a file directly from the file system but i need to be ab

  • How do I sync photos between iPad 2 and iPhone 4s?

    I have iCloud enabled on both, yet the photos are NOT in sync. And apparently I cannot Bluetooth the two together?? Any suggestions on syncing these two for file sharing or better yet... Getting iCloud to hold/make accessible?

  • HT4859 If I have the app turned off for storage in iCloud does this mean the app can not be downloaded to a new device?

    Manage Storage. 1.  What am I deleting specifically when this message appears "Are you sure you want to turn off CNN backups and delete the backup data from the cloud? 2.  If I have the app turned off for storage in iCloud does this mean the app can