聚會時間公告: 因應COSCUP 2011, Kalug 8月份休會一次

七月 6, 2011
» Java Swing basics

In Java Swing system, below are a few basic concepts you need to understand:
  1. Everything appears on screen is basically a component. JComponent is the Swing superclass of all things that draw on screen. For example, JLabel is a built-in JComponent that displays little text string. What you usually do is to create components objects and install it onto screen or their container.
  2. Frames (JFrame) are the outermost components. A JFrame represents a single window. Each JFrame component has a "content pane" JComponent that contains all components in the frame. You can use frame.getContentPane() to get the content pane. Content pane uses a Layout Manager to size and position its components. Frame has a convenience add() and setLayout() that go to its content pane.
  3. Components are placed inside other components which form a nesting hierarchy from outer to inner components. And each container is behind the components it contains. Layout Manager sizes and places those components according to some 'policies' or 'intents' of the layout. Don't call setSize() yourself, the layout manager controls that! Instead, do call setMinimumSize(), setMaximumSize() or setPreferredSize(), to register a preference before the layout manager lays everything out (before calling pack() / setVisible()).
  4. Three basic layout manager: FlowLayout, BoxLayout, BorderLayout. Flow layout arranges components left-right, top-down like text. Box layout aligns components in a line, either vertically or horizontally. Border layout puts main content in the center and decorate with 4 things around the outsize -- north, south, east, west.
  5. Swing thread, or Event-dispatch thread, Composite pattern and Observer/Observable patterns basically form the underlying architecture of Swing GUI system.
  6. A common technique in Java GUI code is to use an anonymous inner class to create a 'listener' class object and register it using addXXXListener() method to a Observable, e.g a button, on the fly.

五月 23, 2011
» The Gap theory of UI Design


Webstock '11: John Gruber - The Gap Theory of UI Design from Webstock on Vimeo.

二月 23, 2011
» [Technotes] Android UI - Dialogs

First of all, what is a dialog?

"A dialog is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction." - Android Dev Guide

Android UI API has some native Dialog objects for you to use. For most general purposes, AlertDialog is sufficient.

Read this page yourself before creating dialogs boxes in your Android application. The sections I think is useful for learning and application development is the following:

» [Technotes] Java Inner classes

First thing first, there is some terminology that needs to be explained.

In Java, you can define a class inside another class; such a class is called nested class. Nested classes can be divided into two categories: static or non-static. Static nested classes are simply called static nested classes. Non-static nested classes are called inner classes.

As for nested classes' privileges, inner classes have access to other members of the enclosing class, even if they are declared private. Static nested classes do not have access to other members of the enclosing class, instead, it can only access to static methods and members of the enclosing (parent) class.

To make the story even more complex, there are 2 other flavors of 'inner classes': local classes and anonymous classes (also called anonymous inner classes). You get to see lots of these two special kinds of inner classes in GUI codes. So you must understand and master them to be able to do GUI programming in Java. To see some concrete examples of these two classes, check out here and there.

In addition, you'd better read the following three web pages carefully before using inner or nested classes:

http://bit.ly/fPoJad - Nested classes introduction
http://bit.ly/dQzVvD - Inner class code example
http://bit.ly/e8h9uR - Summary

Finally, to instantiate an inner class, you must first instantiate the outer class. Then, create the inner object within the outer object with this syntax:

OuterClass.InnerClass innerObject = outerObject.new InnerClass();

二月 18, 2011
» [Technotes] invalidate() method

In android system, the class View (android.view.View) is an important interface for rendering UI objects. Inside it, a method called invalidate() plays a key role.

The function of invalidate is simple, it marks a region on the view to be 'dirty', which tells the android system that region must be redrawn soon in the near future. The region can be the whole View or just a designated region passed to invalidate. And obviously, invalidating only a small portion of the view can have some performance advantages for the UI system. Therefore, make sure you use invalidate() wisely!

Also, an important point: never call any drawing functions except in the onDraw( ) method (a method of class View). Instead, you use the invalidate( ) method to mark rectangles as dirty. The window manager will combine all the dirty rectangles at some point in the future and call onDraw( ) again for you. The dirty rectangles become the clip region, so screen updates are optimized to only those areas that change.

二月 6, 2011
» [Tech notes] What is Anti-aliasing?

Basically it is a technique to make your image/graphics smoother or reduce jagged edges of your graphics.

See the references below:

http://www.pantherproducts.co.uk/Articles/Graphics/anti_aliasing.shtml
http://en.wikipedia.org/wiki/Spatial_anti-aliasing

二月 5, 2011
» What is focus in computing?

'In computing, the focus indicates the component of the graphical user interface which is currently selected to receive input. Moving the focus away from a specific user interface element is known as a blur event in relation to this element.'

By convention, the tab key is used to move the focus to the next focusable component and shift + tab to the previous one.

There are several window management policies for focus:

Click to focus

On most mainstream user-interfaces, such as ones made by Microsoft and Apple, where one must click the mouse inside of the window for that window to gain focus.

Focus follows pointer

Another common policy on UNIX systems using X11 is the "focus follows mouse" policy (or FFM), where the focus automatically follows the current placement of the pointer.

support:

biggo.com.tw

A Django site.