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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| public class ExFlowLayout extends JFrame implements ActionListener {
public ExFlowLayout()
{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-YYYY");
System.out.println(dateFormat.format(new Date()));
this.setTitle("Interface Graphique");
setLayout(null);
setSize(600,400);
setResizable(false);
JButton b1=new JButton("TEST 1");
b1.setSize(125,25);
b1.setLocation(175,10);
b1.setBackground(Color.gray);
b1.addActionListener(this);
add(b1);
JButton b2=new JButton("TEST 2");
b2.setSize(125,25);
b2.setLocation(175,100);
b2.addActionListener(this);
add(b2);
JLabel l1=new JLabel("Francis Sluiters");
l1.setSize(125,25);
l1.setLocation(0,0);
add(l1);
JTextField tf=new JTextField("Bonjour...nous sommes le "+dateFormat.format(new Date()));
tf.setLocation(0,50);
tf.setSize(250,30);
tf.setBackground(Color.orange);
tf.setBorder(null);
// tf.setCursor(getCursor());
add(tf);
String[] liste={"orange","pommes","poires"};
JList jl=new JList(liste);
JScrollPane jsp=new JScrollPane(jl,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
jsp.setLocation(300,150);
jsp.setSize(150,150);
add(jsp);
JPanel p=new JPanel();
p.setBounds(150,150,120,80);
p.setBackground(Color.BLUE);
add(p);
}
public void actionPerformed(ActionEvent ev)
{
Object source=ev.getSource();
if(source==b1)
System.out.println(".....");
else
if(source==b2)
System.out.println("....");
}
public static void main(String[] args)
{
ExFlowLayout f=new ExFlowLayout();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
} |
Partager