FMR Hunter Sleeping one | je me suis repenché un peu dessus today pendant un break
Code :
- public class Main
- {
- public static void main(String[] args)
- {
- InputForm input01 = new InputForm();
- input01.ShowForm();
- System.out.println("start" );
- }
- }
|
Code :
- import java.awt.*;
- import java.awt.event.*;
- public class BaseForm
- {
- public Frame f = new Frame();
- BaseForm ()
- {
- WindowAdapter wa = new WindowAdapter()
- { public void windowClosing(WindowEvent event)
- {
- System.out.println("fermeture" );
- System.exit(0);
- }
- };
- f.addWindowListener(wa);
- }
- BaseForm (String name)
- {
- f.setTitle(name);
- }
- public void ShowForm()
- {
- f.setVisible(true);
- }
- }
|
Code :
- import java.awt.*;
- import java.awt.event.*;
- public class InputForm extends BaseForm
- {
- private Button button01 = new Button();
- private Button button02 = new Button();
- private Label label01 = new Label();
- private TextField text01 = new TextField();
- InputForm()
- {
- super("Form01" );
- GridLayout MyLayout = new GridLayout(2,1,5,5);
- f.setLayout(MyLayout);
- label01.setText("Saisie" );
- ActionListener but01_al = new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- Button01_click();
- }
- };
- button01.addActionListener(but01_al);
- button01.setLabel("Valider" );
- ActionListener but02_al = new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- Button02_click();
- }
- };
- button02.addActionListener(but02_al);
- button02.setLabel("Annuler" );
- Panel panel01 = new Panel();
- panel01.setLayout(new FlowLayout());
- Panel panel02 = new Panel();
- panel02.setLayout(new FlowLayout());
- panel01.add(label01);
- panel01.add(text01);
- panel02.add(button01);
- panel02.add(button02);
- f.add(panel01);
- f.add(panel02);
- f.setLocation(400,400);
- f.pack();
- }
- private void Button01_click()
- {
- MsgForm msg01 = new MsgForm(this.getText01Text(),"message" );
- msg01.ShowForm();
- }
- private void Button02_click()
- {
- System.out.println("fermeture" );
- System.exit(0);
- }
- public String getText01Text()
- {
- return text01.getText();
- }
- }
|
Code :
- import java.awt.*;
- import java.awt.event.*;
- public class MsgForm extends BaseForm
- {
- private Button button01 = new Button();
- private Label label01 = new Label();
- MsgForm (String Prompt,String Title)
- {
- super(Title);
- GridLayout MyLayout = new GridLayout(2,2,5,5);
- f.setLayout(MyLayout);
- label01.setText(Prompt);
- ActionListener but01_al = new ActionListener()
- {
- public void actionPerformed(ActionEvent event)
- {
- Button01_click();
- }
- };
- button01.addActionListener(but01_al);
- button01.setLabel("OK" );
- f.add(label01);
- f.add(button01);
- f.setLocation(600,400);
- f.pack();
- }
- private void Button01_click()
- {
- f.setVisible(false);
- }
- }
| ---------------
I think...
|