PREVIOUS UP   Technologies Internet et Education, © TECFA
  3. L'exemple Weatherchart

3. L'exemple Weatherchart

Un petit programme qui permet d'ouvrir un fichier texte pour lire et afficher graphiquement les données pluviométriques d'une ville sur plusieurs années.

3.1 Layout

TheAboutDialog = new AboutDialog();

TheAboutDialog.setVisible(false);

/* The windows can be drawn with the data from the file. */

this.setSize(400,450);

// we use a border Layout (default would be flow)

this.setLayout(new BorderLayout());

// Top Panel

// first row (open, Savanna Label, about)

TheTopPanel = new Panel();

TheOpenCloseButton = new Button("Open...");

TheOpenCloseButton.addActionListener(this);

TheTopPanel.add(TheOpenCloseButton);

TheTopPanel.add(new Label("Savanna Rainfall Chart:"));

TheAboutButton = new Button("About...");

TheAboutButton.addActionListener(this);

TheTopPanel.add(TheAboutButton);

this.add(TheTopPanel, "North");

// Canvas Line

TheChartCanvas = new ChartCanvas();

this.add(TheChartCanvas, "Center");

// Display commands

TheFirstButton = new Button("First");

TheFirstButton.addActionListener(this);

ThePreviousButton = new Button("Previous");

ThePreviousButton.addActionListener(this);

TheGoToButton = new Button("Go To...");

TheGoToButton.addActionListener(this);

TheNextButton = new Button("Next");

TheNextButton.addActionListener(this);

TheLastButton = new Button("Last");

TheLastButton.addActionListener(this);

TheBottomPanel = new Panel();

TheBottomPanel.add(TheFirstButton);

TheBottomPanel.add(ThePreviousButton);

TheBottomPanel.add(TheGoToButton);

TheBottomPanel.add(TheNextButton);

TheBottomPanel.add(TheLastButton);

this.add(TheBottomPanel, "South");

... à suivre ....

Voir le AWT Tutorial de Sun


PREVIOUS UP -- TIE