Download presentation
Presentation is loading. Please wait.
1
Final project
2
Design your own user interface, but the project has to include the following components and event handlers JFrame JPanel JButton JCheckBox JTextField JMenuBar, JMenu, JMenuItem Either ActionListener, ItemListener or MouseListener
3
Remarks Make the GUI pleasant-looking, clear and clean.
DO NOT COPY from anywhere or anybody. Do your own work.
4
example
5
ItemListener Refer to the slide slide06-0moreGUI
6
MouseListener Done on the class level 5 methods have to be implemented
public class <ClassName> implements MouseListner{.. 5 methods have to be implemented public void mousePressed(MouseEvent evt); public void mouseReleased(MouseEvent evt); public void mouseClicked(MouseEvent evt); public void mouseEntered(MouseEvent evt); public void mouseExited(MouseEvent evt); you can leave the body of a method empty if you don’t want to implement the method.
7
MouseListener Done on the component’s level
Still need to implement all 5 methods, leave the body of a method empty if you don’t want to implement the method Next slide show how it is done
8
txtLog.addMouseListener(new MouseListener() {
public void mouseEntered(java.awt.event.MouseEvent evt) { System.out.println("mouse entered”); } public void mouseExited(java.awt.event.MouseEvent evt) { System.out.println("mouse exit..“); } public void mouseClicked(MouseEvent evt){ System.out.println("mouse clicked”); } public void mouseReleased(MouseEvent evt){ System.out.println("mouse released”); } public void mousePressed(MouseEvent evt){ System.out.println(“mouse pressed..“); float hue = (float)Math.random(); txtLog.setBackground( Color.getHSBColor(hue, 1.0F, 1.0F) ); }
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.