Dark Horse programmer Android video tutorial _ preface dark horse programmer Android video tutorial _ building an Android Development Environment dark horse programmer Android video tutorial _ creating and starting a mobile phone simulator and learning to use the ANDROID operating system dark horse programmer Android video tutorial _ development and running (unload) first ANDROID app dark horse programmer Android video tutorial _ project directory structure and installation and Startup Process Analysis dark horse programmer Android video tutorial _ phone dial-up hacker programmer Android video tutorial _ view application output error information how to deploy the app to a real mobile phone dark horse programmer Android video tutorial _ SMS transmitter dark horse programmer Android video tutorial _ deep understanding of various layout techniques dark horse programmer Android video tutorial _ unit test on the app dark horse programmer Android video tutorial _ view and output log information dark horse programmer Android video tutorial _ file storage and reading dark horse programmer Android video tutorial _ file operation mode dark horse programmer Android video tutorial _ store files in SDCard dark Horse programmer Android video tutorial _ using Pull parser to parse and generate XML content dark horse programmer Android video tutorial _ using SharedPreferences to save user preferences setting parameters dark horse programmer Android video tutorial _ creating a database and adding data black Horse programmer Android video tutorial _ using transactions in SQLite black horse programmer Android video tutorial _ using ListView to display the data list black horse programmer Android video tutorial _ using ContentProvider to share data black horse programmer Android video tutorial _ listening for data changes in ContentProvider Android communication webpage source code viewer dark horse programmer Android video tutorial _ network communication information client dark horse programmer Android video tutorial _ returning data in JSON format to the Information client dark horse programmer Android video tutorial _ network communication through GET and POST Methods submit parameters to the web application dark horse programmer Android video tutorial _ network communication through the HTTP protocol uploads dark horse programmer Android video tutorial _ Send xml data and call webservice dark horse programmer Android video tutorial _ multi-thread download principle dark horse programmer Android video tutorial _ multi-thread resumable download dark horse programmer Android video tutorial _ file resumable upload dark horse programmer Android video tutorial _ add multiple activities for the application and pass parameters to the dark horse programmer Android video tutorial _ Activity Startup Mode dark horse programmer Android video tutorial _ Intent deep anatomy dark horse programmer Android video tutorial _ Activity life cycle dark horse programmer Android video tutorial _ using Broadcast receiver to implement short message qie listening dark Horse programmer Android video tutorial _ using Broadcast receiver to intercept outgoing calls and features dark horse programmer Android video tutorial _ using Service to implement phone qie listener dark horse programmer Android video tutorial _ enabling access with visitors communication local service dark horse programmer Android video tutorial _ Process Communication Using AIDL dark horse programmer Android video tutorial _ service life cycle dark horse programmer Android video tutorial _ music player dark horse programmer Android video tutorial _ online Video Player dark horse programmer Android video tutorial _ camera dark horse programmer Android video tutorial _ video burning dark horse programmer Android video tutorial _ Gesture Recognition dark horse programmer Android video tutorial _ implement Software Internationalization dark horse programmer Android video tutorial _ screen adaptation to dark horse programmer Android video tutorial _ style and theme dark horse programmer Android video tutorial _ coding implementation software interface dark horse programmer Android video tutorial _ sending status bar notice dark horse programmer Android video tutorial _ Webpage Design software Interface dark horse programmer Android video tutorial _ tween animation dark horse programmer Android video tutorial _ frame animation implementation dark horse programmer Android video tutorial _ activity switching animation and page switching animation dark horse programmer Android video tutorial _ Use orientation Sensor for compass
Http://edu.csdn.net/heima/heimaline.html
Package com. wiworld. thinkingjava. worldclock;
Import java. awt. BorderLayout;
Import java. awt. Color;
Import java. awt. Container;
Import java. awt. Graphics;
Import java. awt. Graphics2D;
Import java. awt. event. ActionEvent;
Import java. awt. event. ActionListener;
Import java. awt. geom. Line2D;
Import java. util. Date;
Import java. util. TimeZone;
Import javax. swing. Box;
Import javax. swing. BoxLayout;
Import javax. swing. JButton;
Import javax. swing. JFrame;
Import javax. swing. JLabel;
Import javax. swing. JPanel;
Import javax. swing. JSplitPane;
Import javax. swing. JTextField;
Import sun. awt. HorizBagLayout;
Public class ClockFrame extends JFrame {
Private static final int WIDTH = 600;
Private static final int HEIGHT = 600;
Final JPanel panel = new JPanel ();
Private static final String places [] = {"E1", "E2", "E3", "E4", "E5", "E6", "E7 ", "E8", "E9", "E10", "E11", "E12 ",
"W12", "W11", "W10", "W9", "W8", "W7", "W6", "W5", "W4", "W3 ", "W2", "W1 "};
Private boolean bolFirstDraw = true;
Public ClockFrame (){
InitData ();
Container contentContainer = getContentPane ();
Panel. setBackground (new Color (0x909090 ));
ContentContainer. add (panel, BorderLayout. CENTER );
JButton startButton = new JButton ("Start Draw ");
ContentContainer. add (startButton, BorderLayout. SOUTH );
StartButton. addActionListener (new ActionListener (){
Public void actionreceivmed (ActionEvent event ){
BolFirstDraw = true;
InitData ();
New Thread (){
Public void run (){
While (true/* index <TIMES */){
Try {
Thread. sleep (1000 );
BolFirstDraw = true;
} Catch (InterruptedException e ){
// TODO Auto-generated catch block
E. printStackTrace ();
}
Draw (panel. getGraphics ());
// Index ++;
}
}
}. Start ();
}
});
SetSize (WIDTH, HEIGHT + 100 );
Setdefaclocloseoperation (JFrame. EXIT_ON_CLOSE );
SetVisible (true );
}
Private void initData (){
}
Public void draw (Graphics g ){
If (g = null ){
System. out. println ("Panel. paint. Graphics is null ");
Return;
}
// If (bolFirstDraw ){
// G. clipRect (0, 0, WIDTH, HEIGHT );
// G. clearRect (0, 0, WIDTH, HEIGHT );
// G. setColor (new Color (0x909090 ));
// G. fillRect (0, 0, WIDTH, HEIGHT );
//}
// Draw chess base
If (bolFirstDraw ){
BolFirstDraw = false;
Int startX = 50;
Int startY = 50;
Int clockW = 500;
Int clockH = 500;
Int arcangles = 360;
Int size = 24;
Int startOffset = 50;
Int clockOffset =-startOffset * 2;
Int sectionAngle = arcAngle/size;
Date today = new Date ();
Int hour = today. getHours ();
Int min = today. getMinutes ();
Int second = today. getSeconds ();
Int timeZone = today. getTimezoneOffset ()/60;
Int currentTimeAngle = timeZone * 360/24 + hour * 360/24 + min * sectionAngle/60;
// Draw time zone
For (int I = 0; I <size; I ++ ){
If (I % 2 = 0 ){
G. setColor (Color. black );
} Else {
G. setColor (Color. white );
}
G. fillArc (startX, startY, clockW, clockH, I * sectionAngle, sectionAngle );
}
// Draw world zone
For (int I = 0; I <size; I ++ ){
If (I % 2 = 0 ){
G. setColor (Color. red );
} Else {
G. setColor (Color. blue );
}
G. fillArc (startX + startOffset, startY + startOffset, clockW + clockOffset, clockH + clockOffset, I * sectionAngle + currentTimeAngle, sectionAngle );
}
// Draw 24 time
For (int I = 0; I <size; I ++ ){
G. setColor (Color. green );
G. drawString ("" + (I + 1), (int) (startX + clockW/2 + clockW/2 * Math. sin (I * sectionAngle * Math. PI/180), (int) (startY + clockH/2 + clockH/2 * Math. cos (I * sectionAngle * Math. PI/180 )));
}
// Draw 24 place
For (int I = 0; I <size; I ++ ){
G. setColor (Color. pink );
G. drawString (places [I], (int) (startX + startOffset + (clockW + clockOffset)/2 + (clockW + clockOffset)/2 * Math. sin (I * sectionAngle + currentTimeAngle) * Math. PI/180), (int) (startY + startOffset + (clockH + clockOffset)/2 + (clockH + clockOffset)/2 * Math. cos (I * sectionAngle + currentTimeAngle) * Math. PI/180 )));
}
G. setColor (Color. yellow );
// G. fillArc (startX + startOffset, startY + startOffset, clockW + clockOffset, clockH + clockOffset, second * 6, 1 );
G. drawLine (startX + startOffset + (clockW + clockOffset)/2, startY + startOffset + (clockH + clockOffset)/2, (int) (startX + startOffset + (clockW + clockOffset) /2 + (clockW + clockOffset)/2 * Math. sin (-second * 6) * Math. PI/180), (int) (startY + startOffset + (clockH + clockOffset)/2 + (clockH + clockOffset)/2 * Math. cos (-second * 6) * Math. PI/180 )));
}
G. clipRect (0, 0, WIDTH, HEIGHT );
}
Private int getRandomX (){
Return (int) (Math. random () * WIDTH );
}
Private int getRandomY (){
Return (int) (Math. random () * HEIGHT );
}
Private int getRandomWidth (){
Return (int) (Math. random () * (WIDTH/7 ));
}
Private int getRandomHeight (){
Return (int) (Math. random () * (HEIGHT/7 ));
}
Public static void main (String [] args ){
ClockFrame client = new ClockFrame ();
}
}