oi galera, sou novo em java e estou querendo umas dicas sobre o NetBeans! Tenho problema em gerar uma pagina em Html e através dessa pagina fazer uso de um applet. vou postar o code do programa
// This statement assigns all classes whose source text contains
// this statement to a package.
package penta;
// By importing a package or a class, all declarations
// are made visible that may be made visible in other packages
// based on their access class.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import de.siemens.simaticnet.itcp.api.*;
import de.siemens.simaticnet.itcp.gui.*;
/**
* Example1.java
* <p>Title: Example 1 - Using the ITCP Beans.</p>
* <p>Description: Outputting a value using the CLTextOut Bean with an S7Variable.</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Organization: Siemens AG SIMATIC NET</p>
*
* Outputting a value using the CLTextOut Bean with an S7Variable.
* The memory word MW10 is read.
*
* Components used:
* S7CP
* S7Device
* S7Variable
* CLTimer
* CLTextOut
*
* @author ITCP Team
* @version 1.0
*
*/
public class Main extends Applet implements PropertyChangeListener, ActionListener {
public static void main(String[] args) {
// TODO code application logic here
}
/*-----------------------------------Implemented Interfaces*/
/*----------------------------Basic Class Applet*/
// Declaration of the required components
private CLTextOut cLTextOut1 = null;
private CLTimer cLTimer1 = null;
private S7CP s7CP1 = null;
private S7Device s7Device1 = null;
private S7Variable s7Variable1 = null;
/**
* Is always called when the applet is initialized.
* This occurs immediately after it is loaded.
*
* @see #start
* @see #stop
* @see #destroy
*/
@Override
public void init() {
super.init();
// Sets the name of the component to the specified character string.
setName("Example1");
// Sets the layout manager for this component.
setLayout(null);
// Sets the size of the applet width / height
setSize(426, 240);
/*-----------Height*/
/*------Width*/
// Create an instance for the S7CP bean.
// S7CP is the Ethernet access point to the station
s7CP1 = new S7CP();
// Assign the IP address
// ######## Project-specific adaptation of the IP address necessary ########
s7CP1.setHostString(new HostString ("10.1.1.5:80"));
/*------------------------------------------------Specify port number
normally :80*/
/*-----------------------------------IP address as string*/
// Create an instance for the S7Device bean.
// S7Device is used to address the communication partner in the station.
s7Device1 = new S7Device();
// The address is made up of the rack number and slot number of the
// module. The default of both methods for addressing is ?0?.
// This means that the rack number is unnecessary (.setRack(0)).
// As we want to communicate with the CPU, the slot of the CPU must
// be entered.
// ######## Project-specific adaptation of the rack and slot number ########
// ######## necessary ########
s7Device1.setSlot(2);
/*----------------Slot number 2 (int)*/
// Create an instance for the S7Variable bean.
// The S7Variable bean represents the variable to be read
// or written.
s7Variable1 = new S7Variable();
// The variable is described by an S7 ANY pointer
s7Variable1.setS7Anypointer(
new S7Anypointer((int)5, (int)1, (int)131, (int)0, (int)10, (int)0));
/*--------------------------------------------------------------Bit number 0 ..7*/
/*-----------------------------------------------------Memory area offset*/
/*---------------------------------------------DB number or ?0?*/
/*-----------------------------------Memory area 131 == M*/
/*---------------------------Repetition factor 1 .. n*/
/*-------------------Data type 5 == INT*/
// Sets the name of the component to the specified character string.
s7Variable1.setVariableName("s7Variable1");
// Create an instance for the CLTimer bean.
// The CLTimer bean triggers a PropertyChangeEvent when
// the time elapses. This event implements a cyclic data
// update.
cLTimer1 = new CLTimer();
// The setDelay() method sets the time interval.
cLTimer1.setDelay(2000);
/*----------------Time interval in msec. 2000 == 2 sec.*/
// Create an instance for the CLTextOut bean.
// Using the CLTextOut bean, you as user can enter elementary
// variables.
cLTextOut1 = new CLTextOut();
// Sets the name of the component to the specified character string.
cLTextOut1.setName("cLTextOut1");
// Specify the start position and size of the component.
cLTextOut1.setBounds(0, 0, 200, 45);
/*------------------------------Component height*/
/*-------------------------Component width*/
/*----------------------Start position Y*/
/*-------------------Start position X*/
// Specify the size of the output box.
cLTextOut1.setOutFieldSize(100);
/*-------------------------Length of the output box*/
// Sets the descriptive text to the specified character string.
cLTextOut1.setLabel("Value:");
// Sets the dimension text to the specified character string.
cLTextOut1.setUnit("");
// Insert the component in the applet.
add(cLTextOut1, cLTextOut1.getName());
// Apart from the definition of the methods to be executed when an event
// occurs, an object must register with the corresponding
// event source.
// This is done by calling the addXXXListener method of the event source,
// where »XXX« stands for the corresponding event type.
// The addXXXListener methods all expect a reference to the relevant
// interface:
s7CP1.addPropertyChangeListener(this);
s7Device1.addPropertyChangeListener(this);
cLTimer1.addActionListener(this);
s7Variable1.addPropertyChangeListener(this);
}
/**
* Executes after initialization of an applet.
* With browsers, start() is then also called when a page containing
* an applet is reloaded.
*
* @see #init
* @see #stop
* @see #destroy
*/
@Override
public void start() {
super.start();
}
/**
* There is a call when the browser or the applet viewer is minimized
* to an icon or an HTML page containing an applet is exited in
* a browser.
*
* @see #init
* @see #start
* @see #destroy
*/
@Override
public void stop() {
super.stop();
}
/**
* Is always called when the applet is destroyed.
*
* @see #init
* @see #start
* @see #stop
*/
@Override
public void destroy() {
super.destroy();
// This method deletes all S7Bean instances and discards all threads.
// After calling this method, a reinitialization is necessary.
S7Api.terminate();
}
/**
* Method for handling events for the PropertyChangeListener interface.
*
* @param evt PropertyChangeEvent
*/
public void propertyChange(PropertyChangeEvent evt) {
// Query whether event was triggered by S7CP.
if (evt.getSource() == s7CP1)
// If YES
// Pass event to the S7Device instance
s7Device1.propertyChange(evt);
// Query whether or not event was triggered by S7Device.
if (evt.getSource() == s7Device1)
// If YES
// Pass event to the S7Variable instance
s7Variable1.propertyChange(evt);
// Query whether or not event was triggered by S7Variable.
if (evt.getSource() == s7Variable1)
// If YES
// Then transfer output value to the CLTextOut instance.
cLTextOut1.propertyChange(evt);
}
/**
* Method for handling events for the ActionListener interface.
*
* @param e java.awt.event.ActionEvent
*/
public void actionPerformed(ActionEvent e) {
// Query whether CLTimer triggered.
if (e.getSource() == cLTimer1) {
// If YES, read values from the PLC.
// Reading is triggered by the processGet() method
// of S7Variable bean.
// If the new values exist, the S7Variable bean triggers a
// PropertyChangeEvent.
s7Variable1.processGet();
}
}
}
Obrigado,preciso de ajuda !!!
EDIT - Por favor, use as tags [ code ]