الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

The Frame Is Empty I Donot Know Why ?

بدأه eng_zeita في 19 مايو 2008 · 1 رد · 568 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

ارجوكم لقد احترت فى ايجاد الاجابه

لماذا لا يظهرلى شئ فى هذا الفيرام رغم اننى اضفت به اشياء كثيره جدا

افيدونى افادكم الله وجزاكم عنى خيرا

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class SummaryFrame extends JFrame implements ActionListener
{
 private RandomAccessFile raf;
 private JTabbedPane jtbSummaryInfo = new JTabbedPane();
 private JTextField jtfNumber,jtfNumTicketSold,jtfNumRemaining,jtfRevenue;
 private JButton jbtOk,jbtFindSummary;

 public SummaryFrame(RandomAccessFile raf)
 {
  this.raf = raf;

  setTitle("Summary information");
  setSize(400,300);
	 setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	 setVisible(true);

	 JTabbedPane jtbSummuryInfo =new JTabbedPane();
	 JPanel A1 =new JPanel();
  A1.setLayout(new BorderLayout());

  JPanel A2 =new JPanel();
  A2.setLayout(new BorderLayout());

  JPanel p1 = new JPanel();
  p1.setLayout(new GridLayout(3,1));
  p1.add(new JLabel("Number of Tickets"));
  p1.add(new JLabel("Number Ticket Sold"));
  p1.add(new JLabel("Number Remaining Ticket"));

  JPanel p2 = new JPanel();
  p2.setLayout(new GridLayout(3,1));
  p2.add(jtfNumber = new JTextField());
  p2.add(jtfNumTicketSold = new JTextField());
  p2.add(jtfNumRemaining = new JTextField());

  JPanel p3 = new JPanel();
  p3.setLayout(new BorderLayout());
  p3.add(p1,BorderLayout.WEST);
  p3.add(p2,BorderLayout.CENTER);

  JPanel jpButton = new JPanel();
  jpButton.setLayout(new FlowLayout());
  jpButton.add(jbtOk =new JButton("ok"));
  jpButton.add(jbtFindSummary =new JButton("Find suumury"));

  JPanel p4 =new JPanel();
  p4.setLayout(new FlowLayout());
  p4.add(new JLabel("Revenue"));
  p4.add(jtfRevenue = new JTextField());

  JPanel p5 =new JPanel();
  p5.setLayout(new FlowLayout());
  p5.add(jbtOk =new JButton("ok"));
  p5.add(jbtFindSummary =new JButton("Find suumury"));

  A1.add(p3,BorderLayout.CENTER);
  A1.add(jpButton,BorderLayout.SOUTH);

  A2.add(p4,BorderLayout.CENTER);
  A2.add(p5,BorderLayout.SOUTH);


  jtbSummaryInfo.add(A1,"Ticket");

  jtbSummaryInfo.add(A2,"Income");



  Container c = getContentPane();
  c.setLayout(new BorderLayout());
  c.add(jtbSummuryInfo,BorderLayout.CENTER);

  jtfRevenue.setEditable(false);
  jbtFindSummary.addActionListener(this);
 }
 public void actionPerformed(ActionEvent e)
 {
  if(e.getSource()== jbtFindSummary)
  {
   try
   {
	raf.seek(0);
   }
   catch(IOException ex)
   {
	System.out.println("error");
   }
  }
 }
 public static void main (String[] args) 
 {
	 SummaryFrame t  = new SummaryFrame(null);

	}
}
#2

المشكلة كان لديك سطر ناقص

ووضعت لك تعليق فوقه

//this is your missing line

 

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class SummaryFrame extends JFrame implements ActionListener {
    private RandomAccessFile raf;
    private JTabbedPane jtbSummaryInfo = new JTabbedPane();
    private JTextField jtfNumber, jtfNumTicketSold, jtfNumRemaining, jtfRevenue;
    private JButton jbtOk, jbtFindSummary;

    public SummaryFrame(RandomAccessFile raf) {
        this.raf = raf;

        setTitle("Summary information");
        setSize(400, 300);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);

        JTabbedPane jtbSummuryInfo = new JTabbedPane();
        JPanel A1 = new JPanel();
        A1.setLayout(new BorderLayout());

        JPanel A2 = new JPanel();
        A2.setLayout(new BorderLayout());

        JPanel p1 = new JPanel();
        p1.setLayout(new GridLayout(3, 1));
        p1.add(new JLabel("Number of Tickets"));
        p1.add(new JLabel("Number Ticket Sold"));
        p1.add(new JLabel("Number Remaining Ticket"));

        JPanel p2 = new JPanel();
        p2.setLayout(new GridLayout(3, 1));
        p2.add(jtfNumber = new JTextField());
        p2.add(jtfNumTicketSold = new JTextField());
        p2.add(jtfNumRemaining = new JTextField());

        JPanel p3 = new JPanel();
        p3.setLayout(new BorderLayout());
        p3.add(p1, BorderLayout.WEST);
        p3.add(p2, BorderLayout.CENTER);

        JPanel jpButton = new JPanel();
        jpButton.setLayout(new FlowLayout());
        jpButton.add(jbtOk = new JButton("ok"));
        jpButton.add(jbtFindSummary = new JButton("Find suumury"));

        JPanel p4 = new JPanel();
        p4.setLayout(new FlowLayout());
        p4.add(new JLabel("Revenue"));
        p4.add(jtfRevenue = new JTextField());

        JPanel p5 = new JPanel();
        p5.setLayout(new FlowLayout());
        p5.add(jbtOk = new JButton("ok"));
        p5.add(jbtFindSummary = new JButton("Find suumury"));

        A1.add(p3, BorderLayout.CENTER);
        A1.add(jpButton, BorderLayout.SOUTH);

        A2.add(p4, BorderLayout.CENTER);
        A2.add(p5, BorderLayout.SOUTH);

        jtbSummaryInfo.add(A1, "Ticket");

        jtbSummaryInfo.add(A2, "Income");

        Container c = getContentPane();
        c.setLayout(new BorderLayout());
        c.add(jtbSummuryInfo, BorderLayout.CENTER);

        jtfRevenue.setEditable(false);
        jbtFindSummary.addActionListener(this);

        //this is your missing line
        this.getContentPane().add(jtbSummaryInfo);
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == jbtFindSummary) {
            try {
                raf.seek(0);
            } catch (IOException ex) {
                System.out.println("error");
            }
        }
    }

    public static void main(String[] args) {
        SummaryFrame t = new SummaryFrame(null);

    }
}

ready to do full students projects

digitalscenter@hotmail.com

+966530357742

مواضيع مشابهة