1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
package com.meteostation;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Window extends JFrame {
protected static JLabel tempMin;
protected static JLabel tempMax;
private JTextField text;
public Window(String station_météo) {
setSize(600, 400);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
JPanel panel = new JPanel();
JPanel otherInfo = new JPanel(new GridLayout(2, 2));
tempMin = new JLabel("Température minimale", SwingConstants.CENTER);
tempMin.setBorder(BorderFactory.createEmptyBorder(-50, 0, 0, 0));
tempMax = new JLabel("Température maximale", SwingConstants.CENTER);
tempMax.setBorder(BorderFactory.createEmptyBorder(-50, 0, 0, 0));
otherInfo.add(tempMin);
otherInfo.add(tempMax);
add(panel, BorderLayout.NORTH);
add(otherInfo, BorderLayout.CENTER);
text = new JTextField();
text.setPreferredSize(new Dimension(150, 60));
panel.add(text);
Api api = new Api();
JButton button1 = new JButton("OK");
button1.setPreferredSize(new Dimension(100, 60));
button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
api.getMeteo(text.getText());
}
});
panel.add(button1);
}
} |
Partager