Applet viewer compiling errros

cant seem to get applet viewer to work

Page 1 of 1

13 Replies - 880 Views - Last Post: 30 August 2009 - 08:33 PM Rate Topic: -----

#1 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Applet viewer compiling errros

Posted 29 August 2009 - 01:56 PM

This is my first time trying out applet on java. I am trying to build a simple chat room but before i can build that i need to develop a window where viewers will interact or log in

i have an .html file <APPLET CODE=Client.class WIDTH=600 HEIGHT=300>
</APPLET>

and my code is
  
 import java.applet.*;
 import java.awt.*;

public Client()  
	  {
	  appletContainer.setLayout(new FlowLayout());
 
	  appletContainer.add(nameLabel);
	  appletContainer.add(nameTextField);
	  appletContainer.add(joinButton);
	  appletContainer.add(inputTextArea);
	  appletContainer.add(outputTextArea);
	  appletContainer.add(sendButton);
	  appletContainer.add(leaveButton);
	  }


i know this is just the beginning of my program and it should work, any guidance or advice will be greatly appreciated

the main error it gives is : class, interface, or enum expected
appletContainer.add(LeaveButton);

Is This A Good Question/Topic? 0
  • +

Replies To: Applet viewer compiling errros

#2 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Applet viewer compiling errros

Posted 29 August 2009 - 02:00 PM

where's the rest of the class?
Was This Post Helpful? 0
  • +
  • -

#3 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 29 August 2009 - 02:10 PM

View Postmostyfriedman, on 29 Aug, 2009 - 01:00 PM, said:

where's the rest of the class?

This is all i've got for now, i was told that it should compile and run correctly just to give me a desing of how its going to look like, i will work on the rest but i have to get this working first. Tnxs for any help or advice
Was This Post Helpful? 0
  • +
  • -

#4 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Applet viewer compiling errros

Posted 29 August 2009 - 02:32 PM

import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{
	public Client()  
	{
		appletContainer.setLayout(new FlowLayout());
		appletContainer.add(nameLabel);
		appletContainer.add(nameTextField);
		appletContainer.add(joinButton);
		appletContainer.add(inputTextArea);
		appletContainer.add(outputTextArea);
		appletContainer.add(sendButton);
		appletContainer.add(leaveButton);
	}
}


but you should also declare and initialize appletContainer and the other components that you are adding to you're applet
Was This Post Helpful? 1
  • +
  • -

#5 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 30 August 2009 - 06:23 PM

View Postmostyfriedman, on 29 Aug, 2009 - 01:32 PM, said:

import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{
	public Client()  
	{
		appletContainer.setLayout(new FlowLayout());
		appletContainer.add(nameLabel);
		appletContainer.add(nameTextField);
		appletContainer.add(joinButton);
		appletContainer.add(inputTextArea);
		appletContainer.add(outputTextArea);
		appletContainer.add(sendButton);
		appletContainer.add(leaveButton);
	}
}


but you should also declare and initialize appletContainer and the other components that you are adding to you're applet


So will this compile correctly or do i have to initialize appletContainer before, i tried running it and it gave me an error. or was it just me? tnxs for the help
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Applet viewer compiling errros

Posted 30 August 2009 - 06:43 PM

View PostIcNumb3rs, on 30 Aug, 2009 - 05:23 PM, said:

View Postmostyfriedman, on 29 Aug, 2009 - 01:32 PM, said:

import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{
	public Client()  
	{
		appletContainer.setLayout(new FlowLayout());
		appletContainer.add(nameLabel);
		appletContainer.add(nameTextField);
		appletContainer.add(joinButton);
		appletContainer.add(inputTextArea);
		appletContainer.add(outputTextArea);
		appletContainer.add(sendButton);
		appletContainer.add(leaveButton);
	}
}


but you should also declare and initialize appletContainer and the other components that you are adding to you're applet


So will this compile correctly or do i have to initialize appletContainer before, i tried running it and it gave me an error. or was it just me? tnxs for the help

Don't see where the variable "appletContainer" is defined
this code won't even compile
Was This Post Helpful? 0
  • +
  • -

#7 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 30 August 2009 - 07:02 PM

View Postpbl, on 30 Aug, 2009 - 05:43 PM, said:

View PostIcNumb3rs, on 30 Aug, 2009 - 05:23 PM, said:

View Postmostyfriedman, on 29 Aug, 2009 - 01:32 PM, said:

import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{
	public Client()  
	{
		appletContainer.setLayout(new FlowLayout());
		appletContainer.add(nameLabel);
		appletContainer.add(nameTextField);
		appletContainer.add(joinButton);
		appletContainer.add(inputTextArea);
		appletContainer.add(outputTextArea);
		appletContainer.add(sendButton);
		appletContainer.add(leaveButton);
	}
}


but you should also declare and initialize appletContainer and the other components that you are adding to you're applet


So will this compile correctly or do i have to initialize appletContainer before, i tried running it and it gave me an error. or was it just me? tnxs for the help

Don't see where the variable "appletContainer" is defined
this code won't even compile

so setting it up something like "private string appletContainer; would that be a step in the correct direction?
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Applet viewer compiling errros

Posted 30 August 2009 - 07:09 PM

View PostIcNumb3rs, on 30 Aug, 2009 - 06:02 PM, said:

so setting it up something like "private string appletContainer; would that be a step in the correct direction?

You cannot add component to a String
what in your mind/design/architecture appletContainer should an instance of ?
Was This Post Helpful? 0
  • +
  • -

#9 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 30 August 2009 - 07:23 PM

View Postpbl, on 30 Aug, 2009 - 06:09 PM, said:

View PostIcNumb3rs, on 30 Aug, 2009 - 06:02 PM, said:

so setting it up something like "private string appletContainer; would that be a step in the correct direction?

You cannot add component to a String
what in your mind/design/architecture appletContainer should an instance of ?

The appletcontainer will be an instance of the buttons where the user will input his name or choose to enter the room. Sorry im a beginner, so i might be sounding a little dumb.
Was This Post Helpful? 0
  • +
  • -

#11 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Applet viewer compiling errros

Posted 30 August 2009 - 07:36 PM

I finally got, I think what you mean, try

import java.applet.*;
import java.awt.*;

public Client()  
	  {
	   Container appletContainer = getContentPane();
	  appletContainer.setLayout(new FlowLayout());

	  appletContainer.add(nameLabel);
	  appletContainer.add(nameTextField);
	  appletContainer.add(joinButton);
	  appletContainer.add(inputTextArea);
	  appletContainer.add(outputTextArea);
	  appletContainer.add(sendButton);
	  appletContainer.add(leaveButton);
	  }


Was This Post Helpful? 1
  • +
  • -

#12 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 30 August 2009 - 08:06 PM

awesome, tnxs for the help so far i appreciate it. that code alone though still wont compile correctly because it seems it cannot find the symbols the ones after appletContaiener.add like (leavebutton) or send (sendButton) so i tried to fix it but it still came out wrong this is what i have.
 
import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{
public void init()
{
private  nameLabel = new nameLabel("Enter Your Name");
private  nameTextField = new nameTextField(24);
private  joinButton  = new joinButton("Join The Chat Room");
private  leaveButton  = new leaveButton("Leave");
private sendButton  = new sendButton("Send");
private  inputTextArea  = new inputTextArea(10,40);
private  outputTextArea  = new outputTextArea(10,40);

}
	public Client()  
	  {

	 Container appletContainer = getContentPane();
	  appletContainer.setLayout(new FlowLayout());

	  appletContainer.add(nameLabel);
	  appletContainer.add(nameTextField);
	  appletContainer.add(joinButton);
	  appletContainer.add(inputTextArea);
	  appletContainer.add(outputTextArea);
	  appletContainer.add(sendButton);
	  appletContainer.add(leaveButton);
	  }
}
any advice tnxs.
Was This Post Helpful? 0
  • +
  • -

#13 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8346
  • View blog
  • Posts: 31,908
  • Joined: 06-March 08

Re: Applet viewer compiling errros

Posted 30 August 2009 - 08:16 PM

View PostIcNumb3rs, on 30 Aug, 2009 - 07:06 PM, said:

awesome, tnxs for the help so far i appreciate it. that code alone though still wont compile correctly because it seems it cannot find the symbols the ones after appletContaiener.add like (leavebutton) or send (sendButton) so i tried to fix it but it still came out wrong this is what i have.

There is nothing in the code you posted after

appletContainer.add(leavebutton) ;

*Edited: a few voyels missing... too much beers I guess

This post has been edited by pbl: 30 August 2009 - 08:18 PM

Was This Post Helpful? 0
  • +
  • -

#14 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Applet viewer compiling errros

Posted 30 August 2009 - 08:16 PM

seems you need to go over java basics but there you go
private  JButton nameLabel = new JButton("Enter Your Name");
private  JTextField nameTextField = new JTextField(24);
private  JButton joinButton  = new JButton("Join The Chat Room");
private  JButton leaveButton  = new JButton("Leave");
private  JButton sendButton  = new JButton("Send");
private  JTextArea inputTextArea  = new JTextArea(10,40);
private  JTextArea outputTextArea  = new JTextArea(10,40);


also that shouldnt be in the init()

This post has been edited by mostyfriedman: 30 August 2009 - 08:18 PM

Was This Post Helpful? 0
  • +
  • -

#15 IcNumb3rs  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 27-January 09

Re: Applet viewer compiling errros

Posted 30 August 2009 - 08:33 PM

View Postpbl, on 30 Aug, 2009 - 07:16 PM, said:

View PostIcNumb3rs, on 30 Aug, 2009 - 07:06 PM, said:

awesome, tnxs for the help so far i appreciate it. that code alone though still wont compile correctly because it seems it cannot find the symbols the ones after appletContaiener.add like (leavebutton) or send (sendButton) so i tried to fix it but it still came out wrong this is what i have.

There is nothing in the code you posted after

appletContainer.add(leavebutton) ;

*Edited: a few voyels missing... too much beers I guess

tnxs for that, sorry about the mispelling its just that when codes go wrong the feeling is not so nice.

ok sorry about that, it seems i finally got it, i noticed my mistake now i just need to run it correctly. tnxs for the help
 import java.applet.*;
import java.awt.*;
import javax.swing.*;
public class Client extends JApplet
{

private  JButton nameLabel = new JButton("Enter Your Name");
private  JTextField nameTextField = new JTextField(24);
private  JButton joinButton  = new JButton("Join The Chat Room");
private  JButton leaveButton  = new JButton("Leave");
private  JButton sendButton  = new JButton("Send");
private  JTextArea inputTextArea  = new JTextArea(10,40);
private  JTextArea outputTextArea  = new JTextArea(10,40);

}
public Client()
{

	 Container appletContainer = getContentPane();
	  appletContainer.setLayout(new FlowLayout());

	  appletContainer.add(nameLabel);
	  appletContainer.add(nameTextField);
	  appletContainer.add(joinButton);
	  appletContainer.add(inputTextArea);
	  appletContainer.add(outputTextArea);
	  appletContainer.add(sendButton);
	  appletContainer.add(leaveButton);
	  }
}
the code works great but how do i get the box to change if the user makes the box smaller, then how would i get the scroll feature to turn on so that nothing will go away when the screen becomes smaller

This post has been edited by IcNumb3rs: 30 August 2009 - 08:51 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1