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
|
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.lang.*;
public class test extends JFrame {
JPanel pan = new JPanel();
JPanel jPanel2 = new JPanel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
public test() {
setTitle(" fenetre ");
this.setResizable(false);
this.setSize(650, 650);
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
private void jbInit() throws Exception {
this.getContentPane().setLayout(null);
JPanel1 pan = new JPanel1();
pan.setBounds(new Rectangle(0, 29, 487, 93));
pan.setLayout(null);
jPanel2.setBounds(new Rectangle(48, 264, 386, 45));
jButton1.setText("jButton1");
jButton2.setBounds(new Rectangle(287, 37, 71, 23));
jButton2.setText("jButton2");
this.getContentPane().add(pan, null);
pan.add(jButton2, null);
this.getContentPane().add(jPanel2, null);
jPanel2.add(jButton1, null);
}
public static void main(String[] args) {
test fenetre = new test();
fenetre.setVisible(true);
}
class JPanel1 extends JPanel{
public JPanel1( ){
}
// la methode paint
public void paint(Graphics g)
{
// Tracer une ligne rouge entre les points (x=5, y=30) et (x=50, y=70)
g.setColor(Color.red);
g.drawLine(5, 30, 50, 70);
}
}
} |
Partager