That example I understand it… but
setLayout() is a message of Applet. I need to center the text inside of a circle (or any other figure). How can I apply the Layout to a figure? Is there some method in
Graphics2D that helps me to center the text? With respect to the solution that I found, and it implements was this:
import java.awt.*;
import java.awt.event.*;
class FrameLine extends Frame {
private AppletDiagonal oneApplet; // One will be
public static void main( String[] s ) {
new FrameLine( 200, 230 );
}
public FrameLine( int wide, int length ) {
super(); // Constructor of Component
// A listener adds itself who closed the application
addWindowListener( new ListenerLine() );
// A diagonal applet is created
oneApplet=new AppletDiagonal();
oneApplet.init();
oneApplet.start();
// The applet in frame puts
add( oneApplet );
setSize(wide,length); // it fits frame
setVisible(true); // it shows frame
}
// Nested class
class ListenerLine extends WindowAdapter {
//I rewrite the method of “when window is closed”
public void windowClosing(WindowEvent e) {
oneApplet.stop();
oneApplet.destroy();
System.exit(0);
}
}
}
Marcus