Final project
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
Remarks Make the GUI pleasant-looking, clear and clean. DO NOT COPY from anywhere or anybody. Do your own work.
example
ItemListener Refer to the slide slide06-0moreGUI
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.
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
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) ); }