100 likes | 473 Views
JAVA GUI BASICS. Basic Java GUI Components java.awt.Component , java.awt.Container , javax.swing.JComponent , … Event handling packages java.awt.event and javax.swing.event Creating UI layouts using and creating layout managers java.awt.LayoutManager and java.awt.LayoutManager2
E N D
JAVA GUI BASICS • Basic Java GUI Components • java.awt.Component, java.awt.Container, javax.swing.JComponent, … • Event handling • packages java.awt.event and javax.swing.event • Creating UI layouts • using and creating layout managers • java.awt.LayoutManager and java.awt.LayoutManager2 • Using resources • using resource bundles for different locales • java.util.ResourceBundle
COMPONENTS Component addMouseListener()addKeyListener()...getBounds()getComponentAt()...void paint(Graphics) AWT Swing Container Button add(Component)remove(Component)setLayoutManager()... JComponent setBorder()setUI()... Canvas Label ... Panel Box Window ... Swing Components
WINDOWS & FRAMES Container Window add(Component)remove(Component)setLayoutManager()... addWindowListener()pack()show()... MenuContainer Frame Dialog JWindow setIconImage()setMenuBar()setTitle()... setModal()setTitle()... AWT Swing JFrame JDialog contentPane contentPane getContentPane()setJMenuBar()... getContentPane()...
LAYOUT Container LayoutManager layoutManager addLayoutComponent(name, component)removeLayoutComponent(component)preferredLayoutSizer()minimumLayoutSize()layoutContainer(container) add(component)add(component, constraints)add(name, component)remove(Component)setLayoutManager()validate()doLayout()... LayoutManager2 FlowLayout GridLayout addLayoutComponent(comp, constraints)invalidateLayout()maximumLayoutSize()... ...layoutManager.layoutContainer(this);... BoxLayout CardLayout OverlayLayout GridBagLayout BorderLayout
EVENTS Component EventListener listenerList addMouseListener(listener)removeMouseListener(listener)processMouseEvent(mouseEvent)... MouseListener MouseMotionListener mouseClicked(mouseEvent)mousePressed(mouseEvent)mouseReleased(mouseEvent)mouseEntered(mouseEvent)mouseExited(mouseEvent) KeyListener ActionListener mouseEvent( MOUSE_PRESSED, 123, 456) MouseEvent getX()getY()getClickCount()
EVENTS cont’d AWTEvent EventObject getID() getSource() ComponentEvent ActionEvent other AWT events many notification event types getComponent() InputEvent FocusEvent WindowEvent getModifiers()getWhen() ContainerEvent PaintEvent MouseEvent KeyEvent getX()getY()getClickCount()