I do not know how to go further from here, please help.
[constructor Book in class Book cannot be applied to this given type]I attached a picture of the area of concern.thanks
[constructor Book in class Book cannot be applied to this given type]I attached a picture of the area of concern.thanks
Code:
import java.awt.*; import java.io.*; import java.util.*; import java.text.*; import javax.swing.*; import java.awt.event.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import net.miginfocom.swing.*; public class AddBooks extends JPanel { static JLabel productId, isbn, bookName, author, numberOfPages, yearOfPublication, publishingHouse, cost; static JButton back, addNewBook; static JTextField productIdTF, isbnTF, bookNameTF, authorTF, numberOfPagesTF, yearOfPublicationTF, publishingHouseTF, costTF; static JPanel mainPanel, buttonsPanel; static CardLayout cardLayout; private BufferedImage wallpaper; @SuppressWarnings("unchecked") // gets rid of the unchecked or unsafe warning public AddBooks(){ final String dir = System.getProperty("user.dir"); Color labelColor = new Color(76,0,153); Color textFieldColor = new Color(255,0,0); //------------------------ WALLPAPER ---------------------// try { wallpaper = ImageIO.read(new File(dir + "/Images/AddBookBG.png")); } catch(IOException e) { e.printStackTrace(); } //******************** END OF WALLPAPER ***********************// setLayout(new MigLayout("")); productId = new JLabel("ProductId"); productId.setFont(new Font("Arial Black", Font.PLAIN, 12)); productId.setForeground(labelColor); productIdTF = new JTextField(20); productIdTF.setForeground(textFieldColor); productIdTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); isbn = new JLabel("BOOK ISBN"); isbn.setFont(new Font("Arial Black", Font.PLAIN, 12)); isbn.setForeground(labelColor); isbnTF = new JTextField(20); isbnTF.setForeground(textFieldColor); isbnTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); bookName = new JLabel("BOOK NAME"); bookName.setFont(new Font("Arial Black", Font.PLAIN, 12)); bookName.setForeground(labelColor); bookNameTF = new JTextField(20); bookNameTF.setForeground(textFieldColor); bookNameTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); author = new JLabel("BOOK AUTHOR"); author.setFont(new Font("Arial Black", Font.PLAIN, 12)); author.setForeground(labelColor); authorTF = new JTextField(20); authorTF.setForeground(textFieldColor); authorTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); numberOfPages = new JLabel("No. OF PAGES"); numberOfPages.setFont(new Font("Arial Black", Font.PLAIN, 12)); numberOfPages.setForeground(labelColor); numberOfPagesTF = new JTextField(20); numberOfPagesTF.setForeground(textFieldColor); numberOfPagesTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); yearOfPublication = new JLabel("yearOfPublication"); yearOfPublication.setFont(new Font("Arial Black", Font.PLAIN, 12)); yearOfPublication.setForeground(labelColor); yearOfPublicationTF = new JTextField(20); yearOfPublicationTF.setForeground(textFieldColor); yearOfPublicationTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); publishingHouse = new JLabel("PUBLISHED publishingHouse"); publishingHouse.setFont(new Font("Arial Black", Font.PLAIN, 12)); publishingHouse.setForeground(labelColor); publishingHouseTF = new JTextField(20); publishingHouseTF.setForeground(textFieldColor); publishingHouseTF.setFont(new Font("Arial Black", Font.PLAIN, 14)); cost = new JLabel("PRICE"); cost.setFont(new Font("Arial Black", Font.PLAIN, 12)); cost.setForeground(labelColor); costTF = new JTextField(20); costTF.setForeground(textFieldColor); costTF.setFont(new Font("Arial Black", Font.PLAIN, 12)); back = new JButton(""); back.setFont(new Font("Arial Black", Font.PLAIN, 10)); back.setBorder(BorderFactory.createEmptyBorder()); // remove button border back.setContentAreaFilled(false); // remove the filled area of the button back.setIcon(new ImageIcon(dir + "/Images/back.png")); back.setRolloverIcon(new ImageIcon (dir + "/Images/backG.png"));// adding roolover image back.setVerticalTextPosition(SwingConstants.BOTTOM); // Setting button text to buttom of the image back.setHorizontalTextPosition(SwingConstants.CENTER); // centerizing the text of the button addNewBook = new JButton(""); addNewBook.setFont(new Font("Arial Black", Font.PLAIN, 12)); addNewBook.setBorder(BorderFactory.createEmptyBorder()); // remove border from button addNewBook.setContentAreaFilled(false); // remove the filled are from button addNewBook.setIcon(new ImageIcon(dir + "/Images/addBK.png")); addNewBook.setRolloverIcon(new ImageIcon (dir + "//Images/addBKG.png"));// adding roolover image addNewBook.setVerticalTextPosition(SwingConstants.BOTTOM); // Setting button text to buttom of the image addNewBook.setHorizontalTextPosition(SwingConstants.CENTER); // centerizing the text of the button //------------------ END OF CREATING BUTTONS ------------------\\ productIdTF.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char n = e.getKeyChar(); if (!((n >= '0') && (n <= '9') || (n == KeyEvent.VK_BACK_SPACE) || (n == KeyEvent.VK_DELETE))) { getToolkit().beep(); e.consume(); JOptionPane.showMessageDialog(null,"Only numbers allowed!", "Info", JOptionPane.YES_NO_OPTION); } } }); yearOfPublicationTF.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char n = e.getKeyChar(); if (!((n >= '0') && (n <= '9') || (n == KeyEvent.VK_BACK_SPACE) || (n == KeyEvent.VK_DELETE))) { getToolkit().beep(); e.consume(); JOptionPane.showMessageDialog(null,"Only yearOfPublication allowed!\ne.g 1990", "Info", JOptionPane.YES_NO_OPTION); } } }); costTF.addKeyListener(new KeyAdapter() { public void keyTyped(KeyEvent e) { char n = e.getKeyChar(); if (!((n >= '0') && (n <= '9') || (n == KeyEvent.VK_BACK_SPACE) || (n == KeyEvent.VK_DELETE))) { getToolkit().beep(); e.consume(); JOptionPane.showMessageDialog(null,"Only numbers allowed!", "Info", JOptionPane.YES_NO_OPTION); } } }); back.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0){ AlphaApp.cardLayout.show( AlphaApp.cards, "Main Menu"); } }); addNewBook.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent arg0){ int productID = Integer.parseInt(productIdTF.getText()); String productName = bookNameTF.getText().toUpperCase().trim(); double productCost = Double.parseDouble(costTF.getText()); int productyearOfPublication = Integer.parseInt(yearOfPublicationTF.getText()); String productpublishingHouse = publishingHouseTF.getText().toUpperCase().trim(); String productAuthor = authorTF.getText().toUpperCase().trim(); String Isbn = isbnTF.getText().toUpperCase().trim(); String numberOfPages = numberOfPagesTF.getText().toUpperCase().trim(); MainMenu.bookList.add(new Book( productID, productName, cost,yearOfPublication, publishingHouse, author, Isbn, numberOfPages)); productIdTF.setText(""); isbnTF.setText(""); bookNameTF.setText(""); authorTF.setText(""); numberOfPagesTF.setText(""); yearOfPublicationTF.setText(""); publishingHouseTF.setText(""); costTF.setText(""); JOptionPane.showMessageDialog(null, "NEW BOOK ADDED"); AlphaApp.cardLayout.show(AlphaApp.cards, "Main Menu"); } }); //****************** ADDING COMPONENT TO PANEL *****************\\ add(productIdTF, " sg label, gapTop 140, split 2"); add(productIdTF, "sg TF, wrap"); add(isbn, " sg label, gapTop 10, split 2"); add(isbnTF, "sg TF, wrap"); add(bookName, " sg label, gapTop 10, split 2"); add(bookNameTF, "sg TF, wrap"); add(author, " sg label, gapTop 10, split 2"); add(authorTF, "sg TF, wrap"); add(numOfPages, " sg label, gapTop 10, split 2"); add(numOfPagesTF, "sg TF, wrap"); add(publishingHouse, " sg label, gapTop 10, split 2"); add(publishingHouseTF, "sg TF, wrap"); add(yearOfPublication, " sg label, gapTop 10, split 2"); add(yearOfPublicationTF, "sg TF, wrap"); add(cost, " sg label, gapTop 10, split 2"); add(costTF, "sg TF, wrap"); add(back, "center, sg a, gapTop 70, gapRight 60, split 2"); add(addNewBook, "sg a, gapTop 70, wrap"); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); // paint the background image and scale it to fill the entire space g.drawImage(wallpaper, 0, 0, getWidth(), getHeight(), this); } }
Comment