mardi 14 juin 2016

JDialog cannot be converted to frame

I want to make applcation where you can add students and then assign to each one of them 20 books.

I have 3 windows: Main windows (JFrame) List of books (JDialog) Add a book (JDialog)

I have JFrame where I can see list of all students, then I click on "List of books" where I can see the list of all books in database (.txt file). So when I click on that button in JFrame, I open JDialog, that works fine. But now I want to add some books to the list, so I click on button "Add a book" in "List of Books" JDialog. So I just want to open another JDialog a top of previous JDialog.

So I the window "List of books" (which I opened from Main window) I want to open windows "Add a book".

Now when I do it by the same method as I open JDialog from JFrame, it shows error :

private void pridatKnihuJButtonActionPerformed(java.awt.event.ActionEvent evt) {                                                   
    addBookJDialog newwindow = new addBookJDialog(this, true);
    newwindow.setLocationRelativeTo(null);
    newwindow.setVisible(true);
}  

It shows :

Incompatible types: addBookJDialog cannot be converted to Frame.

Is there a simple way to do this ? I'm creating those windows in NetBeans design function.

I found a few topics about opening some JDialog on another JDialog, but I didnt understand how to do it :/ There are 3 lines of code that opens another JDialog. Is there a way to just simple open it ?

Thanks.

Aucun commentaire:

Enregistrer un commentaire