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

مشكلة بال JInternalFrame

مغلق
بدأه صلاح الثبيتي في 30 يونيو 2003 · 2 رد · 678 مشاهدة · في JavaSE
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

عرفت الخطأ و حليت المشكله..

** ما قدرت احذف الموضوع

السلام عليكم..

كله من مدني . هو يقول لي استخدم JInternalFrame بدل الـ JDialog و سمعت كلامه و اخرتها مشكله مع الفريمات :(

هذا هو الكود ..

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

public class addBooks extends JInternalFrame {
	private Connection connection = null;
	private Statement statement = null;
	private ResultSet resultset = null;

	private JPanel northPanel = new JPanel();
	private JLabel northLabel = new JLabel("Add the information for the book...");

	private JPanel centerPanel = new JPanel();

	private JLabel bookIDLabel;
	private JTextField bookIDTextField = new JTextField();
	private String bookID = null;

	private JLabel titleLabel;
	private JTextField titleTextField = new JTextField();
	private String title = null;

	private JLabel autherLabel;
	private JTextField autherTextField = new JTextField();
	private String authers = null;

	private JLabel publisherLabel;
	private JTextField publisherTextField = new JTextField();
	private String publisher = null;

	private JLabel editionNumberLabel;
	private JTextField editionNumberTextField = new JTextField();
	private String editionNumber = null;

	private JLabel copyrightLabel;
	private JTextField copyrightTextField = new JTextField();
	private String copyrightYear = null;

	private JLabel pagesLabel;
	private JTextField pagesTextField = new JTextField();
	private String pages = null;

	private JLabel ISBNLabel;
	private JTextField ISBNTextField = new JTextField();
	private String ISBN = null;

	private JPanel southPanel = new JPanel();
	private JPanel insertInformationButtonSouthPanel= new JPanel();
	private JPanel OKButtonSouthPanel = new JPanel();
	private JButton insertInformationButton = new JButton("Insert the Information");
	private JButton OKButton = new JButton("                 Exit                 ");




	static int openFrameCount = 0;
    static final int xOffset = 30, yOffset = 30;
	/*private JLibrary l;

	public addBooks(JLibrary l) {
		this.l = l;
	}*/
	//public void addBooks(Frame frame, String _title, boolean model) {
		//setTitle(_title);
	public addBooks() {
		super("Add Book", false, true, false, true);
		Container cp = getContentPane();

		northPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
		northLabel.setFont(new Font("Tahoma", Font.BOLD, 16));
		northPanel.add(northLabel);
		cp.add("North", northPanel);

		centerPanel.setLayout(new GridLayout(8,8,1,1));
		centerPanel.add(bookIDLabel = new JLabel("  Write the Book ID:"));
		centerPanel.add(bookIDTextField);
		centerPanel.add(titleLabel = new JLabel("  Write the title:"));
		centerPanel.add(titleTextField);
		centerPanel.add(autherLabel = new JLabel("  Write the name of the auther:"));
		centerPanel.add(autherTextField);
		centerPanel.add(publisherLabel = new JLabel("  Write the name of the publisher:"));
		centerPanel.add(publisherTextField);
		centerPanel.add(editionNumberLabel = new JLabel("  Write the Edition Number:"));
		centerPanel.add(editionNumberTextField);
		centerPanel.add(copyrightLabel = new JLabel("  Write the copyright for the book:"));
		centerPanel.add(copyrightTextField);
		centerPanel.add(pagesLabel = new JLabel("  Write the number of pages:"));
		centerPanel.add(pagesTextField);
		centerPanel.add(ISBNLabel = new JLabel("  Write ISBN for the book:"));
		centerPanel.add(ISBNTextField);
		cp.add("Center", centerPanel);

		southPanel.setLayout(new BorderLayout());
		cp.add("South", southPanel);

		insertInformationButtonSouthPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		insertInformationButtonSouthPanel.add(insertInformationButton);
		southPanel.add("North", insertInformationButtonSouthPanel);

		OKButtonSouthPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
		OKButtonSouthPanel.add(OKButton);
		southPanel.add("Center", OKButtonSouthPanel);

		insertInformationButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				bookID = "'" + bookIDTextField.getText() + "'";
				title = "'" + titleTextField.getText() + "'";
				authers = "'" + autherTextField.getText() + "'";
				publisher = "'" + publisherTextField.getText() + "'";
				editionNumber = "'" + editionNumberTextField.getText() + "'";
				copyrightYear = "'" + copyrightTextField.getText() + "'";
				pages = "'" + pagesTextField.getText() + "'";
				ISBN = "'" + ISBNTextField.getText() + "'";
				try {
					Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				}
				catch(Exception e) {
					System.out.println(e.toString());
				}
				try {
					connection = DriverManager.getConnection("jdbc:odbc:Library");
					statement  = connection.createStatement();
					statement.executeUpdate("INSERT INTO Books (bookID,Title,authers,"+
					"publisher,editionNumber,copyrightYear,Pages,ISBN) VALUES ("+bookID+","+title+","+authers+","+
					publisher+","+editionNumber+","+copyrightYear+","+pages+","+ISBN+")");
					statement.close();
					connection.close();
				}
				catch(SQLException SQLe) {
					System.out.println(SQLe.toString());
				}
			}
		});
		OKButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent ae) {
				dispose();
			}
		});
		//setResizable(false);
		//setVisible(true);
		setSize(300,300);
		setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
		//pack();
	}
}

و هذا كود الـ JLibrary..

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

public class JLibrary extends JFrame {
	private JMenuBar menubar = new JMenuBar();
	private JMenu bookMenu, memberMenu, searchMenu, loanMenu, helpMenu;
	private JMenuItem addBook,listBook,listAvailbleBook,listBorrowedBook,addMember,removeMember,listMember,
						searchBook, searchMember, borrowBook, returnBook, help, about;
	private JToolBar toolbar = new JToolBar("Tool Bar");
	private JDesktopPane desktop;

    //private listBook list = null;
    //private addBooks   add = null;
    //private addBooks add = new addBooks();
	public JLibrary() {
		super("Library System");
		setSize(800,600);

        setJMenuBar(menubar    = new JMenuBar());
        menubar.add(bookMenu   = new JMenu("Books"));
        menubar.add(memberMenu = new JMenu("Members"));
        menubar.add(searchMenu = new JMenu("Search"));
        menubar.add(loanMenu   = new JMenu("Loan"));
        menubar.add(helpMenu   = new JMenu("Help"));

        bookMenu.add(addBook  = new JMenuItem("Add Book"));
        bookMenu.add(listBook = new JMenuItem("List All Books"));
        bookMenu.add(listAvailbleBook = new JMenuItem("List Availble Books"));
        bookMenu.add(listBorrowedBook = new JMenuItem("List Borrowed Books"));

        memberMenu.add(addMember    = new JMenuItem("Add Member"));
        memberMenu.add(listMember   = new JMenuItem("List All Members"));
        memberMenu.add(removeMember = new JMenuItem("Remove Member"));

        searchMenu.add(searchBook   = new JMenuItem("Search Books"));
        searchMenu.add(searchMember = new JMenuItem("Search Members"));

        loanMenu.add(borrowBook = new JMenuItem("Borrow a Book"));
        loanMenu.add(returnBook = new JMenuItem("Return a Book"));

        helpMenu.add(help = new JMenuItem("Help"));
        helpMenu.add(about= new JMenuItem("About"));

        desktop = new JDesktopPane();
        setContentPane(desktop);
        desktop.putClientProperty("JDesktopPane.dragMode", "outline");

        addBook.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
            	addBooks add = new addBooks();
            	desktop.add(add);
            	setVisible(true);
            	try {
            		add.setSelected(true);
            	} 
            	catch (java.beans.PropertyVetoException e) {}
            }
        });
        /*listBook.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
            	list = new listBook(null);
	            list.listBook(null, "List The Books", false);
            }
        });*/
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				System.exit(0);
			}
		});
		show();
	}
	public static void main(String[] args) {
		new JLibrary();
	}
}

اضغط على الـ MenuItem ما يطلع لي الـ JInternalFrame و لا يطلع عندي خطأ ..

اي توضيحات :)

#3

:)

هذا الموضوع مغلق.

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