TP03 fin ; TP04
This commit is contained in:
BIN
APL2.1/TP03/Rose/Rose.class
Normal file
BIN
APL2.1/TP03/Rose/Rose.class
Normal file
Binary file not shown.
30
APL2.1/TP03/Rose/Rose.java
Normal file
30
APL2.1/TP03/Rose/Rose.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Rose {
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame("Rose");
|
||||
fenetre.setSize(300, 200);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
GridLayout grid = new GridLayout(3, 3);
|
||||
fenetre.setLayout(grid);
|
||||
|
||||
String[] nameList = new String[] {"Mystral", "Tramontane", "Grec", "Ponant", "", "Levant", "Libeccio", "Marin", "Sirocco"};
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
JLabel label = new JLabel(nameList[i]);
|
||||
if (i % 3 == 0) label.setHorizontalAlignment(SwingConstants.LEFT);
|
||||
else if (i % 3 == 1) label.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
else label.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
|
||||
if (i < 3) label.setVerticalAlignment(SwingConstants.TOP);
|
||||
else if (i > 5) label.setVerticalAlignment(SwingConstants.BOTTOM);
|
||||
|
||||
fenetre.add(label);
|
||||
}
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user