السلام عليكم ورحمة الله وبركاته
ارجو توضيح الاختلاف بين
this.add
و
this.getContentPane().add
من حيث الاستخدام (اي متي استخدم كل منهما)
وجزاكم الله خيرا
السلام عليكم ورحمة الله وبركاته
ارجو توضيح الاختلاف بين
this.add
و
this.getContentPane().add
من حيث الاستخدام (اي متي استخدم كل منهما)
وجزاكم الله خيرا
على ماعتقد انه مافي اختلاف بين الاثنين
this.getContentPane().add()
في الاكواد القديمه تجدها عادة ،
السلام عليكم ورحمة الله و بركاته
أعتقد ان
this.add
تقوم باضافة الشي على الفريم مباشرة
أما
this.getContentPane().add
فهي تقوم باضافة الشي على الcontainer
و الله اعلم
الأولي تعمل مع java.applet.Applet, java.awt.Frame
الثانيه تعمل مع java.swing.JFrame
أخي jfriend ، بشكل ضمني يتم مناداة getContentPane.add
للتسهيل فقط تستطيع كتابة JFrame.add
السلام عليكم ورحمة الله وبركاته
جزاكم الله خيرا لاهتمامكم والرد على الموضوع
اخي مبتدئ جافا لقد استخدمت الطريقتين مع الـ JFrame وكانت تعمل تمام جدا
السلام عليكم ورحمة الله وبركاته
شكرا أخي على هذه المعلومه القيمه
In previous versions of Java, components could not be added
directly to frames. Instead, they were placed in the container’s
content pane. Though this technique is no longer necessary,
you’re likely to encounter it in code.
Complex containers are divided into panes, a kind of container
within a container, and components are added to the container’s
content pane.
You can use a panel to represent a frame’s content pane, adding
components to it with the panel’s add(Component) method. After the
panel has been filled, call the frame’s setContentPane(Container)
method with the panel as the argument. This makes it the frame’s
content pane, which also can be done with windows.
BEST REGARDS
SIMO.
هذا الموضوع مغلق.