JAVA AWT ET JAVAX SWING awt =1ère boite à outil de java Éléments de base Component (et Graphics) Container Layout (LayoutManager)
Previous PDF | Next PDF |
[PDF] Présentation PowerPoint - cloudfrontnet
Un composant : est la partie "visible" de l'interface utilisateur Java • C'est une sous-classe de la classe abstraite java awt Component • Exemple : les boutons
[PDF] Présentation PowerPoint
Le package java awt est encore utilisé pour la gestion d' Java Foundation Classes (JFC) = Swing – Un ensemble de classes qui inclut les composants GUI
[PDF] Présentation PowerPoint - INFORMATIQUE — Université Nice
JAVA AWT ET JAVAX SWING awt =1ère boite à outil de java Éléments de base Component (et Graphics) Container Layout (LayoutManager)
[PDF] The AWT, Applets, and Swing
q Must import java awt * and same AWT components – new event model q Java 1 2 – new fancy Swing q The parent class of many of the AWT classes
[PDF] Java swing components ppt - f-static
Java SwingThe origins of the Swing - AWT components use native code resources and are called heavy goods vehicles The native use of peers has led to
[PDF] Programmation événementielle & interfaces graphiques Java Swing
repose sur AWT Components mais pas la même chose – attention : JButton = car les Listeners sont des interfaces (au sens du langage Java) • Listener :
[PDF] AWT - FACULTY OF MEDICAL SCIENCES
In this PPT, you will learn to: ❖Explain ❖Describe Swing Container components ❖JFrame In Java AWT, TextArea and TextField are the subclass of a) List
[PDF] GUI Components: Part 1
Class Component (package java awt) is a superclass that declares the common features of GUI components in packages java awt and javax swing Any object
[PDF] CSC3461
Swing component UI delegate 12 Who called the method "setSelectedItem"? java awt EventDispatchThread run(EventDispatchThread java:110) java awt
[PDF] Preview AWT Tutorial - Tutorialspoint
Abstract Window Toolkit (AWT) is a set of APIs used by Java programmers to In this tutorial, we will learn how to use AWT to create AWT Component Class
[PDF] awt components in java tutorial point
[PDF] awt components in javatpoint
[PDF] awt controls in java
[PDF] ay tax airline
[PDF] azure devops command line
[PDF] azure fortigate pricing
[PDF] a^nb^n is not regular
[PDF] baby bar essays
[PDF] baby boom 1950
[PDF] baby boom chart?
[PDF] baby boom france 1945
[PDF] baby boom france 2000
[PDF] baby boom france 2018
[PDF] baby boom france 2019
PROJET DE LICENCE :
INTERFACE GRAPHIQUE (1)
Intro ² Développement Interface Graphique (Swing)8Q SUHPLHU PRXU G·ORUL]RQ FRPSRVMQP *UMSOLTXH
Layout, Event
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 2 / 113 Université Nice Sophia Antipolis
JAVA.AWT ET JAVAX.SWING
´awt =1ère boite à outil de java
´Éléments de base
"Component (et Graphics) "Container "Layout (LayoutManager) ´VRLQJ H[PHQVLRQ G·MNRUG -)F SXLV LQPpJUHU depuis jdk 1.2) ´swing : faire que tout fonctionne de manière identique partoutL3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 3 / 113 Université Nice Sophia Antipolis
JAVA.AWT.COMPONENT
´Élément de base
´GpILQLP XQ pOpPHQP JUMSOLTXH TXL VHUM MIILŃOp GMQV" avec des propriétés (et des getters / setters)
"Une Size (class Dimension avec .width et .height) "Une Location (Position) (class Point avec .x et .y) "Coordonnées²Origine au coin supérieur gauche
²x (width) vers la droite et y (height) vers le bas "Visible (boolean) ; Opaque (boolean) "8QH ŃRXOHXU GH IRQG NMŃNJURXQG HP XQH ŃRXOHXU G·pŃULPXUH (foreground) "Etc.´Méthode public void paint(Graphics g)
(0,0) x yL3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 4 / 113 Université Nice Sophia Antipolis
JAVA.AWT.GRAPHICS
´Contexte graphique (" PRUŃHMX G·pŃUMQ »)´Permet de dessiner
"Changer de crayon : setColor "drawRect, drawOval, drawPolygon, drawString, fillRect, fillOval "drawImage(img, x, y, ImageObserver) ´Obtenu automatiquement (repaint(), redimensionnement, etc.)´Grapgics2D : vue plus " complète »
"Transformation géométrique (translate, rotate) "Effets graphiques ²g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);²g.setStroke(new BasicStroke(epaisseur));
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 5 / 113 Université Nice Sophia Antipolis
JAVA.AWT.COLOR
´Couleur additive
´4 octets (0-255)
"Rouge (getRed) "Vert (getGreen) "Bleu (getBlue) "Transparence (getAlpha)´.darker() ; .brighter()
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 6 / 113 Université Nice Sophia Antipolis
JAVA.AWT.CONTAINER
´Hérite de Component
´Pattern Composite
´3RUPH G·MXPUHV Component (y compris des Container)´Organisation
"LayoutManager "add / remove G·XQ Component ²GLIIpUHQP P\SH G·add, en fonction du Layout "getComponents retourne un tableau de tous ceux inclus "Unicité de lieu (un add ailleurs => déplacement) "Indice des componentsComponent
Containter
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 7 / 113 Université Nice Sophia Antipolis
LAYOUTMANAGER
´GpILQLP O·RUJMQLVMPLRQ
´Basé sur une des tailles (preferred, minum, PM[LPXP RX XQH PM[LPLVMPLRQ GH O·pOpPHQP´BorderLayout
"par défaut dans une fenêtre "ajout en précisant la zone "add("North" , comp)´FlowLayout : en ligne
´GridLayout : en tableau
´GridBagLayout : avec des contraintes
´etc.
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 8 / 113 Université Nice Sophia Antipolis
APERÇU DU BOXLAYOUT
´Organisation
"Vertical : container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); "Horizontal : ligne. setLayout(new BoxLayout(ligne, BoxLayout.LINE_AXIS)); "Généralement basé sur la taille maximum (dépend du component)´Alignement des bords :
"setAlignmentX(Component.LEFT_ALIGNMENT); pour aligner les bords gauches ´Insertion de " blancs » pour remplir (séparation) "ligne.add(Box.createHorizontalGlue());´HQVHUPLRQ GH ´blancsµ pour combler
´Insertion de " blancs ª SRXU HVSMŃHU"
"container.add(Box.createRigidArea(new Dimension(5,5)));L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 9 / 113 Université Nice Sophia Antipolis
SANS LAYOUT
´setLayout(null)
´3MV G·LQPHOOLJHQŃH MX SOMŃHPHQP C
dimensionnement´Chaque component doit
"Avoir une taille (setSize) "Avoir une position (setLocation)´3RVLPLRQQHPHQP MX SL[HO"
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 10 / 113 Université Nice Sophia Antipolis
EXEMPLE DE LAYOUT
Colonne
(Jpanel) enBoxLayout
Sousélément
enBoxLayout
Fenêtre en
BorderLayout
Un JPanel
sansLayout
(Layout null)L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 11 / 113 Université Nice Sophia Antipolis
ARBRE DE COMPOSANTS GRAPHIQUES
fenêtre contentPane zoneOutilsBouton
" Aucune »Bouton
" Rectangle »Bouton
" Ellipse » " West » 1 2 3Ellipse
zoneDessinEllipse
Rectangle
Rectangle
Rectangle
" Center » 1 2 3 4 5L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 12 / 113 Université Nice Sophia Antipolis
MÉTHODES À CONNAÎTRE
´repaint() ! validate() !
´setEnabled(true / false) : activé / désactivé ´(Rectangle) getBounds / setBounds(x,y, w, h) : positionne et dimensionne´getWidth() : largeur / getHeight() : hauteur
´getX() et getY() : obtenir une coordonnée
´setVisible(true / false)
´getBackground et setBackground [objet Color, définition RGB]´Certaines sont de JComponent"
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 13 / 113 Université Nice Sophia Antipolis
FENÊTRE : CONTAINER DE HAUT NIVEAU
´JFrame (Frame, Window Container)
"getRootPane () zone de la fenêtre sous le titre "getLayeredPane() zone où sont cachés les panneaux non visibles "getContentPane () zone où les éléments sont ajoutés "getGlassPane () zone transparente dessinée au-dessus du JRootPane utilisé pour afficher des pop-up menus´Forward de méthode sur le contentPane
´contentPane avec un BorderLayout par défautNMVp VXU XQ PUMQVSMUHQP G·$XGUH\ Occello
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 14 / 113 Université Nice Sophia Antipolis
JFRAME : QUELQUES MÉTHODES
´setVisible( boolean )
´8QH SRVLPLRQ VXU O·pŃUMQ
´%HVRLQ G·XQH PMLOOH
"Méthode pack( ) : calcul de la taille optimale (basée sur les layouts)´WindowListener ou setDefaultCloseOperation
"Par défaut, fermer la fenêtre revient à la cacherAPERÇU DE JAVAX.SWING
NMVp VXU XQ PUMQVSMUHQP G·$XGUH\ Occello
L3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 16 / 113 Université Nice Sophia Antipolis
JCOMPONENT
´Hérite de Container
´Méthodes de commodité
"setPreferredSize, setMaximumSize, setMinimumSize "setDoubleBuffered(true/false) / isDoubleBuffered() " setOpaque(true / false)´GHVVLQ j O·pŃUMQ paint appel
"paintComponent "paintBorder "paintChildren "Surcharge en général de paintComponent, appel au superL3 Informatique ² Projet de Licence ² dev UI ² Philippe Renevier Gonin 17 / 113 Université Nice Sophia Antipolis