mateus | tien voila le code
Code :
- package gui;
- import java.applet.Applet;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.GridBagLayout;
- import java.awt.GridLayout;
- import java.awt.Image;
- import java.awt.Toolkit;
- import java.awt.event.WindowEvent;
- import java.awt.event.WindowListener;
- import java.awt.geom.Point2D;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import core.Circle;
- /**
- * @author Mathieu
- */
- public class AppletWindow extends JFrame implements WindowListener{
- private Circle circle;
- private Applet parent;
- /**
- * @param a:
- * the {
- * @link IntranetBrowser } which create this classes
- */
- public AppletWindow(Applet a) {
- super();
- this.setSize(Toolkit.getDefaultToolkit().getScreenSize().width/2,Toolkit.getDefaultToolkit().getScreenSize().height/2);
- parent = a;
- this.setTitle("IntranetBrowser" );
- this.updateCircle();
- this.show();
- getContentPane().setLayout(null);
- }
- /**
- *
- */
- private void updateCircle() {
- int radius;
- if (getHeight() > getWidth())
- radius = (getWidth() / 2) - 50;
- else
- radius = (getHeight() / 2) - 50;
- circle = new Circle(this.getWidth() / 2, this.getHeight() / 2, radius);
- }
- public void paint(Graphics g) {
- updateCircle();
- g.setColor(Color.LIGHT_GRAY);
- g.fillRect(0,0,this.getWidth(),this.getHeight());
- g.setColor(Color.BLACK);
- JLabel jl=new JLabel("plop" );
- jl.setBounds(10,10,jl.getHeight(),jl.getWidth());
- Point2D.Double[] p = circle.splitCircle(10);
- for (int i = 0; i < p.length; i++) {
- jl=new JLabel("passage:"+i);
- jl.setBounds((int) p[i].x,(int) p[i].y,jl.getHeight(),jl.getWidth());
- this.getContentPane().add(jl);
- }
- }
|
|