واجهتني مشكلة في تنفيذ احد البرامج ولذلك قررت ان ابحث عن منتدي يصحح لي اخطاءي وبحثت حتي وجدت منتداكم المهيب اشتركت وهذة اول مشاركة لي واتمني ان نستفيد من بعضنا البعض
السؤال كان عبارة عن رسم اشكال معينة بلغة الجافا يعني تحول الرسمة الي كود والرسمة المطلوب انتاجها هي الرسمة التالية :New_Bitmap_Image.bmp
وبعدين انا حاولت اعمل الكود المطلوب وكنت اتصور اني ليس عندي اخطاء وبالفعل المحول لم يشير الي اخطاء ولكن هناك جزئية من الرسمة لم تظهر لا اعلم لماذا وهذة هي النقطة المطلوب الأجابة عنها والكود الي انا كتبتة اهه ارجو المساعدة
// TestPanels.java: Use panels to group components
import java.awt.*;
import javax.swing.*;
public class TestPanels extends JFrame
{
// Default constructor
public TestPanels()
{
// Get the content pane of the frame
Container container = getContentPane();
// Set BorderLayout for the frame
container.setLayout(new BorderLayout(5,10));
// Create panel p1 for the buttons and set GridLayout
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(1, 5));
// Add buttons to the panel
for (int i=1; i<=5; i++)
{
p1.add(new JButton(" " + i));
}
//Add p1 and a button to the frame
container.add(p1, BorderLayout.SOUTH);
container.add(new JButton("Exit"),BorderLayout.CENTER);
container.add(new OvalsPanel(), BorderLayout.EAST);
container.add(new LinesPanel(), BorderLayout.WEST);
}
// Main method
public static void main(String[] args)
{
TestPanels frame = new TestPanels();
frame.setTitle("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500,500);
frame.setVisible(true);
}
}
// The class for drawing the ovals on a panel
class OvalsPanel extends JPanel
{
public OvalsPanel(){}
public void paintComponent(Graphics g)
{
super.paintComponents(g);
g.drawOval(10,30,100,60 );
g.drawOval(10,30,100,60) ;
g.drawOval(10,230,100,60);
}
}
class LinesPanel extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponents(g);
g.drawLine(200,30,150,60) ;
g.drawLine(200,130,150,60);
g.drawLine(200,230,150,60);
}
}
عملت كونتينر جعلت طريقة العرض فية بوردر في السنتر الزرار الكبير وفي الجنوب بانل وضعت فية الأزرار وفي اليمين وضعت الدوائر وعلي اليسار وضعت الخطوط وفجأة بعد لما عملت رن للبرنامج لم يجد اخطاء ولكنة لم يرسم الخطوط ولا الدوائر وهذة هي المشكلة ارجو التفاعل معي وحل المشكلة
وشكرا مقدما
