Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Applet Layout Manager

Have Programming Question? Ask it here!
 
 
 


Gagan
Layout Manager
1 Answer(s)      2 years and 5 months ago
Posted in : Applet


for compile file "Javac SApplet.java" (working fine)

but,

java SApplet (not compile)

error message:
Exception in thread "main" java.lang.NoSuchMethodError:main


Please follow the program

import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class SApplet extends Applet implements ActionListener {
  TextField input,output;
  Label label1,label2;
  Button b1;
  JLabel lbl;
  int num, sum = 0;
  public void init(){
  label1 = new Label("please enter number : ");
  add(label1);
  label1.setBackground(Color.yellow);
  label1.setForeground(Color.magenta);
  input = new TextField(5);
  add(input);
  label2 = new Label("Sum : ");
  add(label2);
  label2.setBackground(Color.yellow);
  label2.setForeground(Color.magenta);
  output = new TextField(20);
  add(output);
//  input.addActionListener( this );
  b1 = new Button("Add");
  add(b1);
  b1.addActionListener(this);
  lbl = new JLabel("This is the Swing Applet Example.  ");
  add(lbl);
  setBackground(Color.yellow);

//  output.addActionListener( this );
  }
  public void actionPerformed(ActionEvent ae){
  try{
//  num = Integer.parseInt(ae.getActionCommand());
  num = Integer.parseInt(input.getText());
  sum = sum+num;
  input.setText("");
  output.setText(Integer.toString(sum));
  lbl.setForeground(Color.blue);
  lbl.setText("Output of the second Text Box : " + output.getText());
  }
  catch(NumberFormatException e){
  lbl.setForeground(Color.red);
  lbl.setText("Invalid Entry!");
  }
  }
}

Advertisement
View Answers

March 2, 2012 at 12:09 PM


You are creating an applet. It doesn't have main method therefore you have got error.Applet always run on browser. You have to compile the applet class and run through the following html file that will call the applet on browser after compilation.

<HTML>
<BODY>
<APPLET CODE ="SApplet.class" WIDTH="800" HEIGHT="500"></APPLET>
</BODY>
</HTML>


Related Tutorials/Questions & Answers:
layout manager
layout manager  how to use Absolute Layout manager in java form
Layout Manager
Layout Manager  for compile file "Javac SApplet.java" (working fine) but, java SApplet (not compile) error message: Exception in thread "main" java.lang.NoSuchMethodError:main Please follow the program import
Advertisements
Layout manager in flex
Layout manager in flex  Hi.... What is Layout Manager and explain the Properties and Methods? Now let's know how we will use these properties and methods........ Thanks
Java layout manager
Java layout manager  Which containers use a FlowLayout as their default layout
Java layout manager
Java layout manager  What advantage do Java's layout managers provide over traditional windowing systems
Java Layout
Java Layout       In java a layout manager class implements the LayoutManager interface. It is used.... Components can provide size and alignment hints, still the container's layout manager has
java layout
java layout  What is a layout manager
Null Layout is Evil
Java NotesNull Layout is Evil You can set the layout manager to null... is a comparison of the layout section of the FlowLayout constructor with the equivalent null layout constructor. FlowLayoutNull Layout //... Content panel
Border Layout
Border Layout  which containers use a border Layout as their default layout
Resource Manager
Resource Manager   Hi... What is a resource Manager in Flex? Please tell me the answer of this question. Thanks  Ans..., which easily access the single instance of this manager. getInstance
tables for layout
tables for layout  Are there any problems with using tables for layout
java layout
java layout  What method is used to specify a container?s layout
tables for layout
tables for layout  Are there any problems with using tables for layout
java Layout
java Layout  sir i want a program of all the layout of java which have two or three button and a database connectivity
Role of Project Manager
Role of Project Manager  What are the role of a project manager in an Organisation
general layout HTML documents
general layout HTML documents  Explain the general layout HTML documents
HTML Layout
HTML Layout       A Web Page Layout is likey to be the layout of the pages... columns are created by using tables to design the layout. This can be done
rmi Security Manager
rmi Security Manager  what type of security provide java rmi security Manager
Layout problem - Java Beginners
Layout problem  How can i place the component without mentioning the layout ?  Use SetBounds for the components and set the layout as null
php events manager - PHP
php events manager  I am looking for a design and structure for the php events manager. Is there any free app on internet that i can use
Drag Manager in flex
Drag Manager in flex  HI... Please tell me about What is a drag manager in flex? Give me the answer with example Thanks  Ans: The DragManager class manage drag and drop operation in which you can move
HTML table layout
HTML table layout  i have table layout in that i have menu in td...(column) ,plz give me code and give me useful layout examples,because my requirement is layout using table
Alternate Layout Managers
design quickly. Besides a powerful and flexible layout manager... their site: TableLayout is a layout manager that provides all... Java NotesAlternate Layout Managers GridBagLayout is the the best layout
VoIP Manager
VoIP Manager          VoIP Manager connector for Netcool NetIQ VoIP Manager Suite (VoIP Manager) provides the industry?s most comprehensive solution for managing
Struts Layout Examples - Struts
Struts Layout Examples  Hi, Iam trying to create tabbed pages using the struts layout tag. I see the tab names on the page but they cannot be clicked on. Im not able to find simple examples/explanation on it. Any help
DividedBox layout container
DividedBox layout container       DividedBox Layout Container is similar to Box Layout Container. The difference is, it adds a divider between its child components which can be used
VDividedBox layout container
VDividedBox layout container       VDividedBox Layout Container is similar to VBox Layout Container. The difference is, it adds a divider between its child components which can be used
HDividedBox layout container
HDividedBox layout container       HDividedBox Layout Container is similar to HBox Layout Container. The difference is, it adds a divider between its child components which can be used
Summary - GUI Layouts 2 - BoxLayout, CardLayout, GridbagLayout
are discussed: a) BoxLayout b) CardLayout c) GridBagLayout Layout, layo, becomes that layout manager for container p (a JPanel or Container...); Creates layout for container p. dir is BoxLayout.X_AXIS BoxLayout.Y_AXIS
Java Swing Card Layout
layout manager. Multiple components on card can be added but at a time only one...Java Swing Card Layout Java technology uses Layout Managers to define... types of Layout Managers which implements the LayoutManager interface
Flex Cursor Manager Example
in your flex application. The most important work of the cursor manager.... If the user don't want to use the system cursor then cursor manager... is UIComponent that is set the cursor. The cursor manager is import
Struts-Layout
Struts-Layout       Struts-Layout is a tag library for Apache Struts which provides easy and fast interface creation. This is achieved by powerful tags which display panels, input fields
What is the responsibility of project manager in software company
What is the responsibility of project manager in software company  What is the responsibility of project manager in software company
How to disable task manager using java
How to disable task manager using java  How to disable task manager using java
Role of Project Manager
A software project manager plays a key role for the development of any... manager should be clearly defined in order to manage all the things effectively and enhance the productivity. The project manager should be responsible for setting
Business manager qualifications
It is important for a manager to fixed target and planning to achieve this. He... handling the people and team. A manager has to deal with the many difficult... for. Handling difficult people and team members are unavoidable and hence manager
Task manager enable and disable thru java
Task manager enable and disable thru java  I would like to know, how to enable and disable task manager using java. Kindly, please Let me know
Visibal Certical scrollbar with struts collection layout.
Visibal Certical scrollbar with struts collection layout.  how to Visibal Vertical scroll bar with struts collection layout
Form Layout Container in Flex4
Form Layout Container in Flex4: The Form Layout container is a MX container. There is no Spark equivalent. Flex uses the Form Layout container for making a Form. The Form container controls the layout of form, required field option
Driver Manager Class
Driver Manager Class       The JDBC Driver Manager The JDBC Driver Manager... to a JDBC driver. Usually  Driver Manager is the backbone of the JDBC
difference between business analyst and project manager
difference between business analyst and project manager  What is the difference between a business analyst and a project manager? How can a Project Management Certificate prove helpful for the Business analyst
Business Development manager
Role of a business development manager is very crucial for any business... that organization objective can be fulfilled. Thus it is manager responsibility to utilize all... the goal. Manager is the responsible for the any change and progress
VBox Layout Container
VBox Layout Container       VBox layout container is just like Box container with vertical direction..." layout="absolute"> <mx:VBox width="104
HBox Layout Container
HBox Layout Container       HBox layout container behaves like Box container with horizontal direction.../2006/mxml" layout="absolute"> <mx:HBox width="
Open Source Download Manager
Open Source Download Manager Open source Download manager A download manager is a computer program designed to download files from the Internet... and regularly updating them.    Free Download CFile Manager Open source
Flex Style Manager
StyleManager in Flex:- In this tutorial, user can see how to use Style Manager for implement style in flex application. First, we discuss what is StyleManager in flex?. The class mx.styles.StyleManager define the StyleManager which
Project Manager Job
Project Manager Job       This Project Manager Job is actually... generation web applications. If you are looking for the Project Manager Job
opening node in treeview struts layout - Struts
opening node in treeview struts layout  Example of opening node in treeview struts layoutopening node in treeview struts layout Hello every one, i am new to this group , i am having the same problem , Struts Layout tree view
Tile Layout Container in Flex4
Tile Layout Container in Flex4: The Tile Layout Container is a MX container... use the direction property for determine the layout. There are two values... components high. The Tag of Tile Layout container is <mx:Tile>. Example
 

 

 

DMCA.com