4/28/2023 0 Comments Java bluej tutorialsJButton searchButton = new JButton ("Search") general listener for all JButton addButton = new JButton ("Add a Book") OK in general there are two main ways how to setup actionListener for buttonsġ. Void returnButton_actionPerformed(ActionEvent e) Void borrowingButton_actionPerformed(ActionEvent e) Void searchButton_actionPerformed(ActionEvent e) This.addItem(new Item(theTitle,userID)) //create a new object of the class Item Void addButton_actionPerformed(ActionEvent e) If (e.getID() = WindowEvent.WINDOW_CLOSING) Protected void processWindowEvent(WindowEvent e) Overridden so we can exit when window is closed ReturnButton.addActionListener (new ()ĬontentPane.add(centrePanel, BorderLayout.CENTER) ĬontentPane.add(southPanel, BorderLayout.SOUTH) ĬontentPane.add(northPanel, BorderLayout.NORTH) Public void actionPerformed(ActionEvent e)īorrowingButton.addActionListener (new () Public void actionPerformed (ActionEvent e) JButton borrowingButton = new JButton () ĬontentPane = (JPanel) this.getContentPane () ĪddButton.addActionListener (new () JTextField IDTextField = new JTextField () JTextField titleTextField = new JTextField () Public class Librar圜atalog extends JFrameīorderLayout borderLayout1 = new BorderLayout () I have actually created the layout, but I dont know how to add actions to the buttons.įor the search button which is searching for list of book that contain within their description whatever is in the description text field and/ or is currently on loan to the borrower matching the number in the borrow text field. I was trying to build a library catalogue with GUI (Graphic User Interface) which consists of two text boxes and four buttons.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |