27-08-2011, 08:01 AM
|
#28
|
تاريخ التسجيل: Jun 2009
نوع الدراسة: إنتظام
المستوى: الخامس
الجنس: ذكر
المشاركات: 66
|
inheritance Implementation
inheritance Implementation
بعد استخدآمه في برنآمج الـبوردر لاي آوت ، كذآ بيصير
كود:
import java.awt.*;
import javax.swing.*;
1 class InheritanceBorderLayout extends JFrame {
/
* Constructor for the class
*/
2 public BorderLayoutDemo() {
3 JButton north = new JButton("North");
4 JButton east = new JButton("East");
5 JButton south = new JButton("South");
6 JButton west = new JButton("West");
7 JButton center = new JButton("Center");
8 JPanel panel = new JPanel();
9 panel.setLayout(new BorderLayout());
10 panel.add(north , BorderLayout.NORTH);
11 panel.add(east , BorderLayout.EAST);
12 panel.add(south ,BorderLayout.SOUTH);
13 panel.add(west , BorderLayout.WEST);
14 panel.add(center, BorderLayout.CENTER);
// frame method used directly
15 getContentPane().add(panel);
16 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
17 pack();
18 setVisible(true);
}
/
* Main Method to start the program
*/
19 public static void main(String[] args) {
InheritanceBorderLayout example = new InheritanceBorderLayout();
}
}
سطر 1
عرفـنآ الكلآس وعرفنا الورآثه وما احتجنآ انشآء
Object
استخدمنا الميثود حقت الفريم مبآشرهـ سطور 15-16-17-18
سطر 2
Constructor
عرفنآه للكلآس و وضعنا كل الكودآت فيهـ وهي الطريقة الي المفروض تستخدمهـآ
انا كنت قبل احط الكودآت في
Main method
لكن هآذي هي الطريقه الصحيحه ،
سطر 19
Main method
وهي يكون فيها استدعآء البرنآمج لتشغيله ، ومآ فيهآ اي كود
لان المين ميثود لما تشغل البرنآمج رآح تستدعي
Constructor
الي فيها الكودآت وتشغلها
|
|
سبحآن الله وبحمده سبحآن الله العظـيم
|
|
|
|