Results 1 to 2 of 2

Thread: Applet wont run in browser...

  1. #1

    Thread Starter
    Hyperactive Member rockies1's Avatar
    Join Date
    Jul 1999
    Location
    Stuck at work
    Posts
    375

    Exclamation

    My applet will run just fine in the applet viewer, but not at all in my browser...

    File is named Lab7.java
    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.TitledBorder;
    
    
    public class Lab7 extends JApplet implements ActionListener
    {
    	JTextField inputOne;
    	JTextField inputTwo;
    	JTextField outputOne;
    	JButton accept;
    	JButton exit;
    
    	public void init()
    	{
    	    Container container = getContentPane();
        	container.setLayout(new BorderLayout());
    
    		inputOne = new JTextField(10);
        	inputTwo = new JTextField(10);
        	outputOne = new JTextField(25);
        	accept = new JButton("Accept");
    
    		outputOne.setEditable(false);
    
    		JPanel p1 = new JPanel();
    		p1.setLayout(new GridLayout(3,3));
    
    		p1.add(inputOne);
    		p1.add(inputTwo);
    		p1.add(outputOne);
    		p1.add(accept);
        p1.setBackground(Color.blue);
        p1.setBorder(new TitledBorder("Last Name then First Name"));
    
       	accept.addActionListener(this);
    
    		container.add(p1,BorderLayout.NORTH);
    	}
    
    	public void actionPerformed(ActionEvent e)
    	{
    		if (e.getSource() == accept)
    			outputOne.setText(inputOne.getText() + " " + inputTwo.getText());
    	}
    }
    In my browser, I use this:
    Code:
    <HTML>
    <APPLET CODE="Lab7.class" height = 400 width = 400></applet></HTML>
    Any ideas?

    Thanks!
    Morgan
    [email protected] - Home
    [email protected] - Work
    Using VB6 SP6 but trying to learn VB2005EE

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    The browser probably doesn't have the Swing classes with it . Try using the Java2 plugin -- that works a lot more reliably.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

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



Click Here to Expand Forum to Full Width