no i jest problem z dispose_on_close
This commit is contained in:
parent
da3f9a0f1b
commit
57172c7a72
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -236,7 +236,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="allAlbumsShow1" max="32767" attributes="0"/>
|
||||
<Component id="allAlbumsShow" max="32767" attributes="0"/>
|
||||
<Component id="allMovieShow" max="32767" attributes="0"/>
|
||||
<Component id="allBooksShow" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@ -279,7 +279,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="allAlbumsShow1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="allAlbumsShow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="allMovieShow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -299,12 +299,12 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allMovieShowActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="allAlbumsShow1">
|
||||
<Component class="javax.swing.JButton" name="allAlbumsShow">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Wszyskie albumy"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allAlbumsShow1ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allAlbumsShowActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="allBooksShow">
|
||||
@ -361,11 +361,23 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" alignment="0" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="0" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfBooks" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="66" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -373,11 +385,20 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfBooks" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="25" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -386,12 +407,12 @@
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ilość albumów:"/>
|
||||
<Property name="text" type="java.lang.String" value="Ilość książek:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ilość książek:"/>
|
||||
<Property name="text" type="java.lang.String" value="Ilość albumów:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
@ -399,6 +420,36 @@
|
||||
<Property name="text" type="java.lang.String" value="Ilość filmów:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfBooks">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="String n = new Integer(d.countAll("books")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfAlbums">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll("albums")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfAlbums1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll("movies")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
|
||||
|
@ -14,6 +14,7 @@ public class Album extends Item {
|
||||
Album() {
|
||||
|
||||
}
|
||||
public Database d = new Database();
|
||||
|
||||
Album(int id, String n, String m, int y, String c) {
|
||||
this.setName(n);
|
||||
@ -34,7 +35,7 @@ public class Album extends Item {
|
||||
|
||||
@Override
|
||||
public void insertToDB() {
|
||||
// String query = "INSERT INTO albums VALUES(NULL, '" +this.getName() + "', '" + this.getMusican() + "', '" + this.getYear() + "', '"+ this.getCategory() + "');";
|
||||
d.insertAlbumQ(this);
|
||||
}
|
||||
|
||||
;
|
||||
|
@ -17,6 +17,7 @@ public class AlbumFieldPattern extends javax.swing.JFrame {
|
||||
/**
|
||||
* Creates new form bookFieldPattern
|
||||
*/
|
||||
|
||||
public AlbumFieldPattern() {
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
initComponents();
|
||||
|
@ -89,7 +89,7 @@ public class Database {
|
||||
public void insertBookQ(Book b) {
|
||||
try {
|
||||
PreparedStatement prepStmt = conn.prepareStatement(
|
||||
"INSERT INTO books VALUES (NULL, ?, ?, ?, ?, ?, ?, ?);");
|
||||
"INSERT INTO books VALUES (NULL, '?', '?', '?', '?', ?, '?', '?');");
|
||||
prepStmt.setString(1, b.getName());
|
||||
prepStmt.setString(2, b.getAuthorName());
|
||||
prepStmt.setString(3, b.getAuthorSurname());
|
||||
@ -99,9 +99,11 @@ public class Database {
|
||||
prepStmt.setString(7, b.getCategory());
|
||||
prepStmt.execute();
|
||||
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
|
||||
|
||||
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
@ -109,15 +111,17 @@ public class Database {
|
||||
public void insertAlbumQ(Album a) {
|
||||
try {
|
||||
PreparedStatement prepStmt = conn.prepareStatement(
|
||||
"INSERT INTO albums VALUES (NULL, ?, ?, ?, ?);");
|
||||
"INSERT INTO albums VALUES (NULL, '?', '?', ?, '?');");
|
||||
prepStmt.setString(1, a.getName());
|
||||
prepStmt.setString(2, a.getMusican());
|
||||
prepStmt.setInt(3, a.getYear());
|
||||
prepStmt.setString(4, a.getCategory());
|
||||
prepStmt.execute();
|
||||
System.out.println(prepStmt);
|
||||
JOptionPane.showMessageDialog(null, "Dodano poprawnie.", "Informacja:", JOptionPane.INFORMATION_MESSAGE);
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy dodawaniu albumu do bazy", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
@ -125,7 +129,7 @@ public class Database {
|
||||
public void insertMovieQ(Movie m) {
|
||||
try {
|
||||
PreparedStatement prepStmt = conn.prepareStatement(
|
||||
"INSER INTO movies VALUES (NULL, ?, ?, ?, ?);");
|
||||
"INSER INTO movies VALUES (NULL, '?', '?', ?, '?');");
|
||||
prepStmt.setString(1, m.getName());
|
||||
prepStmt.setString(2, m.getDirector());
|
||||
prepStmt.setInt(3, m.getYear());
|
||||
@ -202,31 +206,52 @@ public class Database {
|
||||
}
|
||||
return movies;
|
||||
}
|
||||
//Metoda generyczna
|
||||
// public Object[][] convertToTable(List<?> l, Class<?> clazz){
|
||||
|
||||
public int countAll(String tableName) {
|
||||
try {
|
||||
int count = 0;
|
||||
String query = "SELECT COUNT (*) FROM " + tableName + ";";
|
||||
PreparedStatement prepStmt = conn.prepareStatement(query);
|
||||
ResultSet rs = prepStmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
count = rs.getInt(1);
|
||||
}
|
||||
return count;
|
||||
|
||||
} catch (SQLException e) {
|
||||
JOptionPane.showMessageDialog(null, "Błąd przy odczycie ilości.", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public Object[][] convertToTable(List<?> l) {
|
||||
Object first = l.get(0);
|
||||
String type = first.getClass().getName();
|
||||
int i = l.size();
|
||||
if (type.equals("library.Book")) {
|
||||
Object tab[][] = new Object[i][8];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Book.insertRowToTable(tab, y, (Book)l.get(y));
|
||||
try {
|
||||
Object first = l.get(0);
|
||||
String type = first.getClass().getName();
|
||||
int i = l.size();
|
||||
if (type.equals("library.Book")) {
|
||||
Object tab[][] = new Object[i][8];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Book.insertRowToTable(tab, y, (Book) l.get(y));
|
||||
}
|
||||
return tab;
|
||||
} else if (type.equals("library.Album")) {
|
||||
Object tab[][] = new Object[i][5];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Album.insertRowToTable(tab, y, (Album) l.get(y));
|
||||
}
|
||||
return tab;
|
||||
} else if (type.equals("library.Movie")) {
|
||||
Object tab[][] = new Object[i][5];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Movie.insertRowToTable(tab, y, (Movie) l.get(y));
|
||||
}
|
||||
return tab;
|
||||
}
|
||||
return tab;
|
||||
} else if (type.equals("library.Album")) {
|
||||
Object tab[][] = new Object[i][5];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Album.insertRowToTable(tab, y, (Album)l.get(y));
|
||||
}
|
||||
return tab;
|
||||
} else if (type.equals("library.Movie")) {
|
||||
Object tab[][] = new Object[i][5];
|
||||
for (int y = 0; y < i; y++) { //kolejne wiersze danych
|
||||
tab = Movie.insertRowToTable(tab, y, (Movie) l.get(y));
|
||||
}
|
||||
return tab;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
JOptionPane.showMessageDialog(null, "Baza danych pusta", "Error:", JOptionPane.INFORMATION_MESSAGE);
|
||||
throw new IndexOutOfBoundsException("Nie mozna dzielić przez 0");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -7,6 +7,7 @@ package library;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -24,6 +25,7 @@ public class ListResult extends javax.swing.JFrame {
|
||||
rows = rowData;
|
||||
columnsNames = colNam;
|
||||
initComponents();
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="allAlbumsShow1" max="32767" attributes="0"/>
|
||||
<Component id="allAlbumsShow" max="32767" attributes="0"/>
|
||||
<Component id="allMovieShow" max="32767" attributes="0"/>
|
||||
<Component id="allBooksShow" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
@ -279,7 +279,7 @@
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="allBooksShow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="allAlbumsShow1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="allAlbumsShow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="allMovieShow" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@ -299,12 +299,12 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allMovieShowActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="allAlbumsShow1">
|
||||
<Component class="javax.swing.JButton" name="allAlbumsShow">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Wszyskie albumy"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allAlbumsShow1ActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="allAlbumsShowActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="allBooksShow">
|
||||
@ -361,11 +361,23 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" alignment="0" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" alignment="0" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel2" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfBooks" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel4" min="-2" pref="125" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="0" pref="66" max="32767" attributes="0"/>
|
||||
<EmptySpace min="0" pref="23" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -373,11 +385,20 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfBooks" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="numberOfAlbums1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="25" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -386,12 +407,12 @@
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ilość albumów:"/>
|
||||
<Property name="text" type="java.lang.String" value="Ilość książek:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ilość książek:"/>
|
||||
<Property name="text" type="java.lang.String" value="Ilość albumów:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel4">
|
||||
@ -399,6 +420,36 @@
|
||||
<Property name="text" type="java.lang.String" value="Ilość filmów:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfBooks">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="String n = new Integer(d.countAll("books")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfAlbums">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll("albums")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="numberOfAlbums1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code="n" type="code"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_InitCodePre" type="java.lang.String" value="n = new Integer(d.countAll("movies")).toString();"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JToggleButton" name="jToggleButton1">
|
||||
|
@ -21,6 +21,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
public MainMenu() {
|
||||
initComponents();
|
||||
}
|
||||
public Database d = new Database();
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
@ -44,7 +45,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
radioBSearch = new javax.swing.JRadioButton();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
allMovieShow = new javax.swing.JButton();
|
||||
allAlbumsShow1 = new javax.swing.JButton();
|
||||
allAlbumsShow = new javax.swing.JButton();
|
||||
allBooksShow = new javax.swing.JButton();
|
||||
newestBook = new javax.swing.JButton();
|
||||
newestMovie = new javax.swing.JButton();
|
||||
@ -56,6 +57,9 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
numberOfBooks = new javax.swing.JLabel();
|
||||
numberOfAlbums = new javax.swing.JLabel();
|
||||
numberOfAlbums1 = new javax.swing.JLabel();
|
||||
jToggleButton1 = new javax.swing.JToggleButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
@ -170,10 +174,10 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
allAlbumsShow1.setText("Wszyskie albumy");
|
||||
allAlbumsShow1.addActionListener(new java.awt.event.ActionListener() {
|
||||
allAlbumsShow.setText("Wszyskie albumy");
|
||||
allAlbumsShow.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
allAlbumsShow1ActionPerformed(evt);
|
||||
allAlbumsShowActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
@ -203,7 +207,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(allAlbumsShow1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(allAlbumsShow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(allMovieShow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(allBooksShow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(31, 31, 31)
|
||||
@ -239,7 +243,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addComponent(allBooksShow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(allAlbumsShow1)
|
||||
.addComponent(allAlbumsShow)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(allMovieShow))))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
@ -247,32 +251,56 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
|
||||
jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
|
||||
|
||||
jLabel2.setText("Ilość albumów:");
|
||||
jLabel2.setText("Ilość książek:");
|
||||
|
||||
jLabel3.setText("Ilość książek:");
|
||||
jLabel3.setText("Ilość albumów:");
|
||||
|
||||
jLabel4.setText("Ilość filmów:");
|
||||
|
||||
String n = new Integer(d.countAll("books")).toString();
|
||||
numberOfBooks.setText(n);
|
||||
|
||||
n = new Integer(d.countAll("albums")).toString();
|
||||
numberOfAlbums.setText(n);
|
||||
|
||||
n = new Integer(d.countAll("movies")).toString();
|
||||
numberOfAlbums1.setText(n);
|
||||
|
||||
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
|
||||
jPanel2.setLayout(jPanel2Layout);
|
||||
jPanel2Layout.setHorizontalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(0, 66, Short.MAX_VALUE))
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(numberOfBooks))
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(numberOfAlbums))
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(numberOfAlbums1)))
|
||||
.addGap(0, 23, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jLabel2)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(numberOfBooks))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel3)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(numberOfAlbums))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel4)
|
||||
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(numberOfAlbums1))
|
||||
.addContainerGap(25, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
@ -346,7 +374,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
private void bAlbumActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bAlbumActionPerformed
|
||||
|
||||
if (radioBAdd.getModel().isSelected()) {
|
||||
AlbumFieldPattern b = new AlbumFieldPattern(true);
|
||||
AlbumFieldPattern b = new AlbumFieldPattern();
|
||||
b.setVisible(true);
|
||||
b.add = true;
|
||||
}
|
||||
@ -398,35 +426,70 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_radioBDelete1ActionPerformed
|
||||
|
||||
private void allBooksShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allBooksShowActionPerformed
|
||||
try {
|
||||
|
||||
Database d = new Database();
|
||||
List<Book> books = new LinkedList<>();
|
||||
books = d.selectBooks();
|
||||
/*System.out.println("Lista książek:");
|
||||
List<Book> books = new LinkedList<>();
|
||||
books = d.selectBooks();
|
||||
/*System.out.println("Lista książek:");
|
||||
for (Book k : books) {
|
||||
//
|
||||
}*/
|
||||
Object[][] data = d.convertToTable(books);
|
||||
String[] columnNames = {"ID",
|
||||
"Tytuł",
|
||||
"Imię Autora",
|
||||
"Nazwisko Autora",
|
||||
"Rok",
|
||||
"ISBN",
|
||||
"Wydawnictwo",
|
||||
"Kategoria"};
|
||||
ListResult table = new ListResult(data, columnNames);
|
||||
|
||||
table.setVisible(true);
|
||||
Object[][] data = d.convertToTable(books);
|
||||
String[] columnNames = {"ID",
|
||||
"Tytuł",
|
||||
"Imię Autora",
|
||||
"Nazwisko Autora",
|
||||
"Rok",
|
||||
"ISBN",
|
||||
"Wydawnictwo",
|
||||
"Kategoria"};
|
||||
ListResult table = new ListResult(data, columnNames);
|
||||
|
||||
table.setVisible(true);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
//nothing to do here
|
||||
}
|
||||
}//GEN-LAST:event_allBooksShowActionPerformed
|
||||
|
||||
private void allMovieShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allMovieShowActionPerformed
|
||||
// TODO add your handling code here:
|
||||
try {
|
||||
List<Movie> movies = new LinkedList<>();
|
||||
movies = d.selectMovies();
|
||||
Object[][] data = d.convertToTable(movies);
|
||||
String[] columnNames = {
|
||||
"ID",
|
||||
"Tytuł",
|
||||
"Reżyser",
|
||||
"Rok",
|
||||
"Kategoria"};
|
||||
ListResult table = new ListResult(data, columnNames);
|
||||
|
||||
table.setVisible(true);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
//nothing to do here
|
||||
}
|
||||
}//GEN-LAST:event_allMovieShowActionPerformed
|
||||
|
||||
private void allAlbumsShow1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allAlbumsShow1ActionPerformed
|
||||
// TODO add your handling code here:
|
||||
}//GEN-LAST:event_allAlbumsShow1ActionPerformed
|
||||
private void allAlbumsShowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_allAlbumsShowActionPerformed
|
||||
|
||||
try {
|
||||
List<Album> albums = new LinkedList<>();
|
||||
albums = d.selectAlbums();
|
||||
Object[][] data = d.convertToTable(albums);
|
||||
String[] columnNames = {
|
||||
"ID",
|
||||
"Tytuł",
|
||||
"Muzyk/Zespół",
|
||||
"Rok",
|
||||
"Kategoria"};
|
||||
ListResult table = new ListResult(data, columnNames);
|
||||
|
||||
table.setVisible(true);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
//nothing to do here
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_allAlbumsShowActionPerformed
|
||||
|
||||
/**
|
||||
* @param args the command line arguments
|
||||
@ -463,7 +526,7 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
}
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton allAlbumsShow1;
|
||||
private javax.swing.JButton allAlbumsShow;
|
||||
private javax.swing.JButton allBooksShow;
|
||||
private javax.swing.JButton allMovieShow;
|
||||
private javax.swing.JButton bAlbum;
|
||||
@ -483,6 +546,9 @@ public class MainMenu extends javax.swing.JFrame {
|
||||
private javax.swing.JButton newestBook1;
|
||||
private javax.swing.JButton newestMovie;
|
||||
private javax.swing.JButton newestMovie1;
|
||||
private javax.swing.JLabel numberOfAlbums;
|
||||
private javax.swing.JLabel numberOfAlbums1;
|
||||
private javax.swing.JLabel numberOfBooks;
|
||||
private javax.swing.JLabel programTitle;
|
||||
private javax.swing.JRadioButton radioBAdd;
|
||||
private javax.swing.JRadioButton radioBDelete1;
|
||||
|
Loading…
Reference in New Issue
Block a user