Download presentation
Presentation is loading. Please wait.
Published byEmil Higgins Modified over 9 years ago
1
Deliver Information, not Just Data Design displays carefully –Visual order and user focus (control contrast) –Match the medium (mixed metaphors) –Attention to detail (don’t assume anyone can do the job—team approach) Screen belongs to User (avoid trying to help the user manage the screen) Preserve display inertia (localize the response to user action—wait for Return to reposition list) –Don’t respond too quickly –Warn the user of proposed change—make change predictable and appropriate (measured) response
2
Custom Painting As we should by now realize the Swing library is divided between containers and components. We have used JPanel components for grouping. Now will will use them for drawing. The coordinate systems for ANY component makes the upper lefthand corner (0,0), so the lower right hand corner is (width-1, height-1) where units are pixels. Any border width comes out of the dimensions of the component (more accurately, the visible area of the component is decreased (inset) by the pixels assigned to its border). getInsets() obtains a component’s border width, getWidth() and getHeight() obtains the component’s outer dimensions.
3
Repaint() When invoked, the componet schedules itself to be refreshed in graphics memory. With no arguments, the whole component is repainted, but with four arguments, only that rectangular portion is refreshed. (g.getClipBounds() tells you what region of your component is visible on the screen) Example Code –CoordinateDemo (p. 861)CoordinateDemo –SelectionDemo (p.879)SelectionDemo
4
The Graphics Object When component.repaint() is invoked the paintComponent(Graphics g) method for that component is called and it employs a default color, font, etc. to do the custom painting. After painting the background of the component (because of a call to super.paintComponent) the method does the drawing requested, then invokes paintBorder and finally paintChildren so that any components internal to the component will also repaint themselves. Graphics
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.