/*1er CODIGO*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class FArreglo extends Frame{
static final int HORIZONTAL_TAMANO = 600;
static final int VERTICAL_TAMANO = 200;
public FArreglo() {
super( "Arreglo en Frame..." );
pack();
resize( HORIZONTAL_TAMANO,VERTICAL_TAMANO );
show();
}
public void paint( Graphics g ) {
int a[] = new int[10];
int x = 80;
int y = 80;
//g.drawString( "El arreglo es: ",30,50 );
for(int i = 0; i < 10; i++)
{
a[i] = i;
g.drawString("El Contenido de este Arreglo es: " , 50, 50);
g.drawString(" " + a[i] , x, y);
x += 20;
}
}
public static void main( String args[] ) {
FArreglo a = new FArreglo();
a.addWindowListener(
new WindowAdapter(){
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
});
}
}
/*2do CODIGO*/
import java.awt.*;
import java.awt.event.*;
/**
* Sample application using Frame.
*
* @author
* @version 1.00 07/09/13
*/
public class FArregloFrame extends Frame {
/**
* The constructor.
*/
public FArregloFrame() {
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu();
MenuItem menuFileExit = new MenuItem();
menuFile.setLabel("File");
menuFileExit.setLabel("Exit");
// Add action listener.for the menu button
menuFileExit.addActionListener
(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
FArregloFrame.this.windowClosed();
}
}
);
menuFile.add(menuFileExit);
menuBar.add(menuFile);
setTitle("FArreglo");
setMenuBar(menuBar);
setSize(new Dimension(400, 400));
// Add window listener.
this.addWindowListener
(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
FArregloFrame.this.windowClosed();
}
}
);
}
|