關於我自己

我的相片
Welcome to discuss about : Chinese Traditional Medicine and Acupuncture Please send me the email: tccnchsu@gmail.com Chih-Yu Hsu

最新消息

總瀏覽量

2011年2月17日 星期四

逢甲大學 物件導向程式設計_JAVA


奉獻與感動


富爸爸富小孩 為什麼我要學系這些課程



激勵演講

"我什麼都會" .......這傢伙當服務員太可惜了......超強模仿秀


90后CEO余佳文如何獲得馬云千萬美元風投 下 看后必轉

Speech: Never Give Up on Your Dreams 董丽娜《别把梦想逼上绝路》

【就是創意】朱學恒:關於夢想


永不放棄(繁體版)

夢想.激勵人心的演說

服務學習課程


《愛的真諦》 北京儿童合唱团 (1 Corinthians 13:4-8) Tippi 

最強激勵影片8分鐘

08年奧運舉重冠軍施泰納令人感動的故事


尼克 Nick Vujicic(life without limbs)_為生命喝采

讓整個世界都沉默了的激勵演講



如何使用C#存取MySQL資料庫



4月17日上課
4月24日 2點30 分 檢查部落格
5月1日 不上課

java button array event e

java 整數轉字串

=================================================================

ActionListener on array of JButtons


JAVA 如何取/產生亂數 (大學程式設計 第三課)


Action Listener for an Array of Buttons. Help



======================================================================
期末考




思维影响行为,行为形成习惯,习惯产生性格,性格决定命运!思维方式是可以培养和调整的,我们的命运掌握在自己手中。 


来劲工作指标图




google app studio 教學  Android Studio 40


=======================================================================

=======================================================================
第十三週

import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class Calculator extends JFrame implements 
ActionListener{
int space;
JButton button[]=new JButton[10];

public static void main(String[]args){

new Calculator();
}


public Calculator()
{
String s;
int myrand;
int[] a = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int[] aresult;
int temp;
Random ran = new Random();
/*
for (int i = 0; i < 9; i++)
{
 System.out.println(a[i]);
}
*/

for (int i = 0; i < 9; i++)
{
 myrand=ran.nextInt(9-i);
temp=a[8-i];
a[8-i]=a[myrand];
a[myrand]=temp;
}

for (int i = 0; i < 9; i++)
{
 System.out.println(a[i]);
}

JFrame window=new JFrame("Calculator");

window.setDefaultLookAndFeelDecorated(true);


window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

window.setLayout(new GridLayout(3,3));

JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));


//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";

for (int i = 0; i < 9; i++)
{
button[i] = new JButton();


button[i].setActionCommand(s);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(a[i]));

jplPanel.add(button[i]);
if ( Integer.valueOf(button[i].getText())== 0)   
  {
                space=i;
                System.out.println(i)     ;
  }

}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);


}




public void actionPerformed(ActionEvent e) {
 for(int i=0; i <=8; i++)
{

if(e.getSource() == button[i]){
 //if( Integer.valueOf(button[i].getText())== 0)
String tempsting;
if (i==space-1)
{
tempsting=button[i].getText();
button[i].setText(button[i+1].getText());
button[i+1].setText(tempsting);
System.out.println(i+button[i].getText());
}
}


}

}

}




=====================================================================
第十二週

import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class Calculator extends JFrame implements 
ActionListener{

JButton button[]=new JButton[10];

public static void main(String[]args){

new Calculator();
}


public Calculator()
{
String s;
int myrand;
int[] a = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int[] aresult;
int temp;
Random ran = new Random();
for (int i = 0; i < 9; i++)
{
 System.out.println(a[i]);
}
for (int i = 0; i < 9; i++)
{
 myrand=ran.nextInt(9-i);
temp=a[8-i];
a[8-i]=a[myrand];
a[myrand]=temp;
}

for (int i = 0; i < 9; i++)
{
 System.out.println(a[i]);
}

JFrame window=new JFrame("Calculator");

window.setDefaultLookAndFeelDecorated(true);


window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

window.setLayout(new GridLayout(3,3));

JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));


//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";

for (int i = 0; i < 9; i++)
{
button[i] = new JButton();


button[i].setActionCommand(s);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(a[i]));

jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);


}




public void actionPerformed(ActionEvent e) {
     

for(int i=1; i <= 9; i++)
{
          if(e.getSource() == button[i]){
              System.out.println(i);
          }
    }

}


}


=======================================================================
第十一週

import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class Calculator extends JFrame implements
ActionListener{

JButton button[]=new JButton[10];

public static void main(String[]args){

new Calculator();
}


public Calculator()
{
String s;
JFrame window=new JFrame("Calculator");

window.setDefaultLookAndFeelDecorated(true);


window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

window.setLayout(new GridLayout(3,3));

JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));


//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";
int myrand;
for (int i = 1; i <= 9; i++)
{
button[i] = new JButton();
Random ran = new Random();
 myrand=ran.nextInt(9)+1;

button[i].setActionCommand(s);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(myrand));

jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);


}




public void actionPerformed(ActionEvent e) {
   

for(int i=1; i <= 9; i++)
{
          if(e.getSource() == button[i]){
              System.out.println(i);
          }
    }

}

}





=======================================================================
第十週  按鈕顯示亂數

import java.awt.*;
import java.awt.event.*;
import java.util.Random;
import javax.swing.*;
public class Calculator extends JFrame implements ActionListener{

JButton button[]=new JButton[10];

public static void main(String[]args){

new Calculator();
}


public Calculator()
{
String s;
JFrame window=new JFrame("Calculator");

window.setDefaultLookAndFeelDecorated(true);


window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

window.setLayout(new GridLayout(3,3));

JPanel jplPanel = new JPanel();
jplPanel.setLayout(new GridLayout(3,3));


//s=Integer.toString(1);
s=String.valueOf(1);
//System.out.println(s);
//s="1";
int myrand;
for (int i = 1; i <= 9; i++)
{
button[i] = new JButton();
Random ran = new Random();
 myrand=ran.nextInt(9)+1;

button[i].setActionCommand(s);
button[i].addActionListener(this);
button[i].setSize(50,50);
button[i].setText(Integer.toString(myrand));

jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);


}




public void actionPerformed(ActionEvent e) {
     
for(int i=1; i

 第六週
==================================================================


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Calculator extends JFrame{
public static void main(String[]args){
JFrame window=new JFrame("Calculator");
JPanel jplPanel = new JPanel();

JButton button[]=new JButton[10];

for (i = 1; i <= 9; i++)

{

button[i] = new JButton();

button[i].setSize(50,50);
button[i].setText(Integer.toString(i+1));
jplPanel.add(button[i]);
}
window.getContentPane().add(jplPanel, BorderLayout.CENTER);
window.setSize(500,500);
window.setVisible(true);
}}
======================================================================
多個按鈕



How to create objects (JButton) array?


JButton Source Code


 第四週

=============================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Test
{


public static void main(String[] args)
{
JFrame jtfMainFrame = new JFrame("Which Button Demo");
jtfMainFrame.setSize(450, 150);
JButton  jbnButton1 = new JButton("Button 1");
JPanel jplPanel = new JPanel();
jplPanel.add(jbnButton1);
jtfMainFrame.getContentPane().add(jplPanel, BorderLayout.CENTER);
jtfMainFrame.setVisible(true);
System.out.print("chih-yu hsu");
}
}

============================================================

作業


http://socket.io/demos/chat/
A simple chat demo for socket.io

Two way communication between server and client on socket.io node.js

1.  第二週 
1.  第一週 (2011年2月18日)


1.
製作自己的學習部落格blog
回答下列問題
1.為何why要選修這門課?(動機)
2.希忘從這門課獲得那些知識?(目標)
3.我要如何修習這一門課?(態度與方法)
who, when, where 

實作



class Test
{
public static void main(String[] args)
{
System.out.println("_____*_____");
System.out.println("____***____");
System.out.println("___*****___");
System.out.println("__*******__");
System.out.println("_____*_____");
System.out.println("_____*_____");
}
}



回答問題: 請問您畢業後,如果找不到工作,您會花錢去上 "Java程式設計實力精修班" 課程嗎? 為甚麼?請您說明原因,100個字以上。
  

3. 下載並安裝 Java Platform (JDK)  Java SE Downloads 並 參考網頁 "Hello World!" for Microsoft Windows 執行程式 ,使結果出現 Hello World!


參考網址

java 下載 與 安裝 執行 hellow

http://tccnchsu.blogspot.com/2010/02/java.html

google blog css

同學的部落格

學號   姓名    網址
D9735878 劉哲宇 http://nicejava-java.blogspot.com/
D9785801 張鶴櫪 http://d9785801.blogspot.com/
D9735780 劉華瑋 http://alan5820.blogspot.com/
D9735851 彭凱頎 http://bleakmirage.blogspot.com/
D9735818 蕭銘宏 http://sean80221123.blogspot.com/
D9735937 汪筠捷 http://tony11206.blogspot.com/
D9785934李虹毅http://responsible10.blogspot.com/
D9785862王志明  http://j12345741258.blogspot.com/
D9790384吳育全 http://gary1424.blogspot.com/
D9785760莊桂軒http://www.wretch.cc/blog/onlyyazu

D9785917 謝翰嶔 http://jack10169.blogspot.com/

D9785790 詹宏茂 http://rfdg8546.blogspot.com/

D9726464 吳昱鋒 http://www.wretch.cc/blog/jk15478
D9642313 黃俊隆http://loganlearninglog.blogspot.com/
D9785578 汪聖凱http://www.wretch.cc/blog/bho2980112sa
D9726481 黃建志 http://s10024157.blogspot.com/
D9681524 郭政霖 http://www.wretch.cc/blog/charlie0525
d9643522  林哲瑜 http://www.wretch.cc/blog/warbobobo
d9726327 陳政瑜 http://www.wretch.cc/blog/jc1113
D9681200 廖崇閔http://www.wretch.cc/blog/kobe770201
D9681483 孫子策http://www.wretch.cc/blog/qoopooguy
D9681609劉駿賢http://www.wretch.cc/blog/chi2980119nn
D9735970顏三峻http://www.wretch.cc/blog/ysj78113
D9681139林俊德http://www.wretch.cc/blog/YFU385
D9786107郭榮浩http://swsy10301.blogspot.com/
D9681452吳智閔http://tw.myblog.yahoo.com/jw!zJVuSkGFBQBrxXRQDPohWf1w5209
D9681231劉晏君http://www.wretch.cc/blog/postre
D9642433柯志陽http://www.wretch.cc/blog/s2463715s
D9681316郭宗賢http://kuohome123.blogspot.com/

Interactive HTML5 Math Web Apps for Mobile Learning

Google Web Designer



C程式語言2010

程式MATLAB設計





If you need detail notes, please refer to the fallowing blogs.
But they are written in Chinese. If you have any questions, please email to me. 
Chih-Yu Hsu, tccnhsu@gmail.com 
  

勵志文章  Article to encourage you!

醫生的反省

不要佔人便宜
弟子規 全文

我們的未來 你知道嗎?



創意與感動

以專注力度過2012

Be passion of focusing on life to fly over 2012.


程式設計就如同作文一樣,唯有感動才能創作。老師所能帶領同學分享地就是如何體驗感動,產生創作的熱情!
As a teacher I am, what I can do is only to lead students to fell surprise with full passion to be creative! 



課程筆記請參考同學的部落格
If you need detail notes, please refer to the fallowing blogs.
But they are written in Chinese. If you have any questions, please email to me. 
Chih-Yu Hsu, tccnhsu@gmail.com 
  

 影片介紹 (Movies help you to encourage you!)

The Secret 每日自我激勵短片
震撼全人類的視頻,看完這個你們有什 感受
心中的小星星
三個傻瓜

3 Idiots - Official Trailer




最能抓住財富創造方式的人,是很會製造東西的人,常被稱作工匠、師傅。他們的手工藝品成為商店的手工商品,隨著工業化的程度增加,工匠日漸消失,遺留下來的最大族群,叫做電腦程式設計師。
-------------------------------------------
經濟學的角度,"創新"可以視為將人的一生經歷壓縮至短短數年中,與其庸庸碌碌地工作40年,還不如盡全力工作4年。科技產業中,這份衝勁將帶來豐厚的回報,快速工作帶來額外報酬。
--------------------------------------------
要賺到100萬必須忍受100萬價值的痛苦。在郵局工作一輩子,存下的每一分錢最後可以得壹百萬,但必須承受在郵局待 50年所承受壓力。創業家是把50年份的壓力濃縮於數年間體驗,承受與經濟價值相等的痛苦後,通常能取得報酬,這是基本定律。
書名:駭客與畫家 O'Reilly

類神經網路的數學模式在分類問題之應用

http://tccnchsuneuralnetwork.blogspot.com/2008/11/blog-post.html


公告

報名4/15(五)、16、17在朝陽科大2011 TiC100 中區TTT創造力教育探索營

逢甲大學與台中市政府共同舉辦「2011國際綠色生活創意競賽」已正式起跑,報名時間自即日起至4月30日

2011年全球設計大賽Electrolux Design Lab



 http://www.electrolux.com/designlab


100年04月14日四9 期中考試(14-20日)


機器人
http://tiltedtwister.com/
http://www.youtube.com/watch?v=3QOvEG27Gt4

LEGO Mindstorms Sudoku Solver



雲淡風輕: 使用NXC撰寫NXT程式---第一章Hello NXC




LEGO NXT-G 教學 - 登入- Yahoo!奇摩


Secret

Java 系列電子書

第十八週 (2011年6月17日)
學期分數計算並上網
第十七週 (2011年6月10日)
http://cooking-java.blogspot.com/search/label/Android

期末考
1. Run 現有的Android 程式 50%
2. 自己的程式  50%
==============================================================
ClientAndroid中的ip用10.0.2.2是本機模擬器的ip

http://www.javaworld.com.tw/jute/post/view?bid=26&id=283396
參考

http://developer.android.com/guide/developing/tools/emulator.html#networkaddresses

ServerClientAndroid.rar (85.68k)


==============================================================
模擬器不支援Camera


架Server用Socket送圖檔過去

可以參考

http://www.tomgibara.com/android/camera-source

版本是android比較舊的版本

需做一點修改

在android 2.1的版本有跑過是OK的



==============================================================

imageview
Resize and Rotate Image - Example


=================================================================

package edu.cyut.chsu;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;

public class Mybitmaptest extends Activity {
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        LinearLayout linLayout = new LinearLayout(this);
       
        // load the origial BitMap (500 x 500 px)
        Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),
               R.drawable.android);
       
        int width = bitmapOrg.getWidth();
        int height = bitmapOrg.getHeight();
        int newWidth = 200;
        int newHeight = 200;
       
        // calculate the scale - in this case = 0.4f
        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
       
        // createa matrix for the manipulation
        Matrix matrix = new Matrix();
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
        // rotate the Bitmap
        matrix.postRotate(45);
        // recreate the new Bitmap
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrg, 0, 0,
                          width, height, matrix, true);
   
        // make a Drawable from Bitmap to allow to set the BitMap
        // to the ImageView, ImageButton or what ever
        BitmapDrawable bmd = new BitmapDrawable(resizedBitmap);
       
        ImageView imageView = new ImageView(this);
       
        // set the Drawable on the ImageView
        imageView.setImageDrawable(bmd);
    
        // center the Image
        imageView.setScaleType(ScaleType.CENTER);
       
        // add ImageView to the Layout
        linLayout.addView(imageView,
         new LinearLayout.LayoutParams(
                      LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT
                )
        );
       
        // set LinearLayout as ContentView
        setContentView(linLayout);
    }
}


===============================================================




第十五週 (2011年5月27日)
=============================================================================


  EX203

  匯率換算



=======================================================================

/*
 * ed1 = 匯率
 * ed2 = 台幣
 * 計算公式: 美金 = 台幣/匯率  => ed2/ed1
 * 
 * 學習重點:
 * 0) context.findViewById 即 EX203.this (ClassName.this)
 * 1) setOn XXX Listener(),建立按鈕事件處理
 * 2) new Widget.OnClickListener(){} (口訣:小括號 大括號,最末小括號後分號)
 * 3) 滑鼠游標移置紅色文字線上 Add unimplemented methods
 * 4) 數學換算,與資料型別轉換 in Java
 * 5) 覆寫 Activity 的 onPause() 或 onStop(),將 匯率 儲存下來 (SharePreference物件)
 * 6) 覆寫 Activity 的 onResume(),將  匯率 讀取出來 (SharePreference物件)
*/
package irdc.ex203;

import java.text.NumberFormat;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class EX203 extends Activity
{
  private EditText ed1, ed2;
  private Button btn1;
  private TextView tv1;
  public static final String MY_PREFS = "mSharedPreferences01";
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    
    ed1 = (EditText)EX203.this.findViewById(R.id.editText1);  // 匯率
    ed2 = (EditText)EX203.this.findViewById(R.id.editText2);  // 台幣
    btn1 = (Button)EX203.this.findViewById(R.id.button1);
    tv1 = (TextView)EX203.this.findViewById(R.id.textView3);
    
    ed1.setText("33.5");
    ed2.setText("10000");
    
    btn1.setOnClickListener(new Button.OnClickListener()
    {
      @Override
      public void onClick(View arg0)
      {
        // 按鈕事件,處理數學換算的語法
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits( 2 );
        
        double d = Double.parseDouble(ed2.getText().toString()) / Double.parseDouble(ed1.getText().toString());
        
        tv1.setText( EX203.this.getResources().getString(R.string.str3) + ":" + nf.format(d) );
        
      }
    });
    
  }/*End: onCreate()*/

  @Override
  protected void onResume()
  {
    // TODO Auto-generated method stub
    
    SharedPreferences mySharedPreferences = getSharedPreferences(MY_PREFS, Activity.MODE_PRIVATE);
    // 第二個參數為 假若 "rate" 不存在,程式為第一次執行的話,要以什麼值取代
    String previousInputRate = mySharedPreferences.getString("rate", "");
    ed1.setText(previousInputRate);
    super.onResume();
  }

  @Override
  protected void onStop()
  {
    // TODO Auto-generated method stub
    SharedPreferences mySharedPreferences = getSharedPreferences(MY_PREFS, Activity.MODE_PRIVATE);
    SharedPreferences.Editor ed = mySharedPreferences.edit();
    ed.putString("rate", ed1.getText().toString() );
    ed.commit();
    
    super.onStop();
  }
 }

================================================================================
第十三週 (2011年5月13日)

DICOM java source

Index of /ij/download/examples/DicomViewer


作業
=================================================
rem Compiles and runs the DicomViewer example program
rem assumes ij.dir is in the current folder
rem SET PATH=C:\jdk1.2\bin;%PATH%
set CLASSPATH=ij.jar;.
javac -deprecation DicomViewer.java
java DicomViewer 000006.dcm

第十二週 (2011年5月6日)
===========================================================
import ij.*;
import java.applet.*;
import java.awt.*;
import ij.process.*;
/**Simple applet that demonstrates how to use ImageJ's ImageProcessor class.*/
public class IPDemo extends Applet {
 String name;
 Image img;
 ImageProcessor ip = null;
 public void init() {
  setLayout(new BorderLayout());
  Panel p = new Panel();
  p.setLayout(new GridLayout(5, 3));
/*
  p.add(new Button("Reset"));
  p.add(new Button("Flip"));
  p.add(new Button("Invert"));
  p.add(new Button("Lighten"));
  p.add(new Button("Darken"));
  p.add(new Button("Rotate"));
  p.add(new Button("Zoom In"));
  p.add(new Button("Zoom Out"));
  p.add(new Button("Threshsold"));
  p.add(new Button("Smooth"));
  p.add(new Button("Sharpen"));
  p.add(new Button("Find Edges"));
  p.add(new Button("Macro 1"));
  p.add(new Button("Macro 2"));
  p.add(new Button("Add Noise"));
*/
  add("South", p);
  name = getParameter("img");
  img = getImage(getDocumentBase(), name);
  MediaTracker tracker = new MediaTracker(this);
  tracker.addImage(img, 0);
  try {tracker.waitForID(0);}
  catch (InterruptedException e){}
  if (name.endsWith("jpg"))
   ip = new ColorProcessor(img);
  else
   ip = new ByteProcessor(img);
                              
                 ip.snapshot();
                                ip.noise(20);
                                img = ip.createImage();
                 repaint();
 }

 public void update(Graphics g) {
  paint(g);
 }
 public void paint(Graphics g) {
  g.drawImage(img, 0, 0, this);
 }
 public boolean action(Event e, Object arg) {
  if (e.target instanceof Button) {
   String label = (String)arg;
   if (label.equals("Reset"))
    ip.reset();
   else if (label.equals("Flip"))
    ip.flipVertical();
   else if (label.equals("Invert"))
    ip.invert();
   else if (label.equals("Lighten"))
    ip.multiply(1.1);
   else if (label.equals("Darken"))
    ip.multiply(0.9);
   else if (label.equals("Rotate"))
    ip.rotate(30);
   else if (label.equals("Zoom In"))
    ip.scale(1.2, 1.2);
   else if (label.equals("Zoom Out"))
    ip.scale(0.8, 0.8);
   else if (label.equals("Threshsold"))
    ip.autoThreshold();
   else if (label.equals("Smooth"))
    ip.smooth();
   else if (label.equals("Sharpen"))
    ip.sharpen();
   else if (label.equals("Find Edges"))
    ip.findEdges();
   else if (label.equals("Macro 1"))
    macro1();
   else if (label.equals("Macro 2"))
    macro2();
   else if (label.equals("Add Noise"))
    ip.noise(20);
   img = ip.createImage();
   repaint();
   return true;
  }
  return false;
 }

 void updateAndDraw() {
  img.flush();
  img = ip.createImage();
  getGraphics().drawImage(img, 0, 0, this);
 }
 void macro1() {
  for (int i=10; i<=360; i+=10) {
   ip.reset();
   ip.rotate(i);
   updateAndDraw();
  }
 }

 void macro2() {
  double scale = 1, m = 1.2;
  for (int i=0; i<20; i++) {
   ip.reset();
   scale *= m;
   ip.scale(scale, scale);
   updateAndDraw();
  }
  for (int i=0; i <20; i++) {
   ip.reset();
   scale /= m;
   ip.scale(scale, scale);
   updateAndDraw();
  }
 }

}

=====================================================

ImageJ

ImageJ Tutorial

http://rsb.info.nih.gov/ij/download/examples/

java classpath

java appletviewer

Fiji is easy to install

==================================================================

1.3 Setting up your Environment
For running ImageJ you need the ImageJ class and configuration files, a Java Runtime Environment
(JRE) and—for compiling your own plugins—a Java compiler with the required
libraries, as for example included in the Java 2 SDK Standard Edition (J2SE) from Sun
Microsystems. Depending on the ImageJ distribution you are using, some or all of this may
already be included.
1.3.1 Installing ImageJ
The latest distribution of ImageJ can be downloaded from http://rsb.info.nih.gov/ij/download.
html.
In the following the installation of ImageJ will be described briefly for different operating
systems. More detailed and up-to-date installation instructions can be found at http://rsb/.
info.nih.gov/ij/docs/install.
If you already have a JRE (and a Java compiler) installed on your computer and you are
familiar with Java, you just need to download the ImageJ class and configuration files which
are available as a ZIP archive. To run ImageJ, add ij.jar to your classpath and execute class
ij.ImageJ. This also works for all operating systems for which there is no specific ImageJ
distribution but for which a Java runtime environment is available.
Windows
The Windows version is available with installer, both with and without a Java Runtime
Environment (JRE).

==================================================================

Chromosomes

java 繼承
例: extends Applet

java applet tutorial



====================================================================
import ij.*;
import java.applet.*;
import java.awt.*;
import ij.process.*;
/**Simple applet that demonstrates how to use ImageJ's ImageProcessor class.*/
public class IPDemo extends Applet {
 String name;
 Image img;
 ImageProcessor ip = null;
 public void init() {
  setLayout(new BorderLayout());
  Panel p = new Panel();
  p.setLayout(new GridLayout(5, 3));
  p.add(new Button("Reset"));
  p.add(new Button("Flip"));
  p.add(new Button("Invert"));
  p.add(new Button("Lighten"));
  p.add(new Button("Darken"));
  p.add(new Button("Rotate"));
  p.add(new Button("Zoom In"));
  p.add(new Button("Zoom Out"));
  p.add(new Button("Threshsold"));
  p.add(new Button("Smooth"));
  p.add(new Button("Sharpen"));
  p.add(new Button("Find Edges"));
  p.add(new Button("Macro 1"));
  p.add(new Button("Macro 2"));
  p.add(new Button("Add Noise"));
  add("South", p);
  name = getParameter("img");
  img = getImage(getDocumentBase(), name);
  MediaTracker tracker = new MediaTracker(this);
  tracker.addImage(img, 0);
  try {tracker.waitForID(0);}
  catch (InterruptedException e){}
  if (name.endsWith("jpg"))
   ip = new ColorProcessor(img);
  else
   ip = new ByteProcessor(img);
  ip.snapshot();
 }

 public void update(Graphics g) {
  paint(g);
 }
 public void paint(Graphics g) {
  g.drawImage(img, 0, 0, this);
 }
 public boolean action(Event e, Object arg) {
  if (e.target instanceof Button) {
   String label = (String)arg;
   if (label.equals("Reset"))
    ip.reset();
   else if (label.equals("Flip"))
    ip.flipVertical();
   else if (label.equals("Invert"))
    ip.invert();
   else if (label.equals("Lighten"))
    ip.multiply(1.1);
   else if (label.equals("Darken"))
    ip.multiply(0.9);
   else if (label.equals("Rotate"))
    ip.rotate(30);
   else if (label.equals("Zoom In"))
    ip.scale(1.2, 1.2);
   else if (label.equals("Zoom Out"))
    ip.scale(0.8, 0.8);
   else if (label.equals("Threshsold"))
    ip.autoThreshold();
   else if (label.equals("Smooth"))
    ip.smooth();
   else if (label.equals("Sharpen"))
    ip.sharpen();
   else if (label.equals("Find Edges"))
    ip.findEdges();
   else if (label.equals("Macro 1"))
    macro1();
   else if (label.equals("Macro 2"))
    macro2();
   else if (label.equals("Add Noise"))
    ip.noise(20);
   img = ip.createImage();
   repaint();
   return true;
  }
  return false;
 }

 void updateAndDraw() {
  img.flush();
  img = ip.createImage();
  getGraphics().drawImage(img, 0, 0, this);
 }
 void macro1() {
  for (int i=10; i<=360; i+=10) {
   ip.reset();
   ip.rotate(i);
   updateAndDraw();
  }
 }

 void macro2() {
  double scale = 1, m = 1.2;
  for (int i=0; i<20; i++) {
   ip.reset();
   scale *= m;
   ip.scale(scale, scale);
   updateAndDraw();
  }
  for (int i=0; i <20; i++) {
   ip.reset();
   scale /= m;
   ip.scale(scale, scale);
   updateAndDraw();
  }
 }

}
====================================================================
例: extends JFrame
====================================================================
import javax.swing.Timer;
import java.awt.event.*;
import java.util.*;
import java.awt.*;
import javax.swing.*;
public class TimerDemo extends JFrame implements ActionListener {
static JTextField tbx1=new JTextField(10); // 建立1文字方塊物件
  Timer t = new Timer(1000,this);
  TimerDemo() {
    t.start();
    }
  public static void main(String args[]) {
    TimerDemo td = new TimerDemo();
   
    GridLayout grid33= new GridLayout(3,3);
    td.setLayout(grid33);
    td.setSize(450,450);
    JPanel p1 = new JPanel(grid33); //實作  panel 1
    p1.add(tbx1);
    td.add(p1); // 在視窗myfrm 內加入 panel 1
    td.setVisible(true);

    // create a dummy frame to keep the JVM running
    //  (for demonstation purpose)
    //    java.awt.Frame dummy = new java.awt.Frame();
    // dummy.setVisible(true);
    }
  public void actionPerformed(ActionEvent e) {
    if (e.getSource() == t) {
      //System.out.println
      //  ("Being ticked " + Calendar.getInstance().getTime());
     // Date mydate=Calendar.getInstance().getTime();
     // tbx1.setText(mydate.toString());
     tbx1.setText(" "+Calendar.getInstance().getTime());
      }
    }
}

==================================================================

第十一週 (2011年4月29日)

作業

Create a Timer object

參考

java class timer

 

封裝, 建構子

==================================================================

//主檔案

class Object1 {
    public static void main(String args[]) {
        Person1 p1 = new Person1("大雄", 50);
        Person1 p2 = new Person1("胖虎", 80);
        Person1 p3 = new Person1();
        p1.checkWeight();
        p2.checkWeight();
        p2.weight = 68;
        p1.checkWeight();
        p2.checkWeight();
        p3.checkWeight();
    }
}
 

===================================================================
//另一類別檔
class Person1 {
    String name;
    int weight;

//建構子
    Person1(String pName, int pWeight) {
        name   = pName;
        weight = pWeight;
    }
     Person1() {
        name   = "0";
        weight = 1;
    }

    void checkWeight() {
        System.out.print(name+"體重 "+weight+" 公斤,");
        if (weight < 70)
            System.out.println("很苗條!");
        else
            System.out.println("很穩重!");
    }
}


====================================================================
=====================================================



// with event

//Swing, JButton類別 有ActionListener

//Swing, JButton類別

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;


public class SwingEightPuzzleEvent extends JFrame implements ActionListener

{

//static JFrame myfrm=new JFrame("JButton class"); // Java Class JFrame

//static AwtTestEvent myfrm=new AwtTestEvent("JFrame 1 "); // Java Class JFrame


static JTextField tbx1=new JTextField(2); // 建立1文字方塊物件

static JButton buttons[]=new JButton[10];

static JLabel labels[]=new JLabel [10];


public SwingEightPuzzleEvent()

{






}









public static void main(String args[])

{

SwingEightPuzzleEvent myfrm=new SwingEightPuzzleEvent();


String numbers[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};


FlowLayout flow=new FlowLayout();

GridLayout grid12= new GridLayout(1,2);

GridLayout grid33= new GridLayout(3,3);


myfrm.setLayout(grid12);

myfrm.setSize(450,450);


JPanel p1 = new JPanel(grid33); //實作 panel 1


for (int i = 0; i < numbers.length; i++)

{

buttons[i] = new JButton(numbers[i]); // create buttons

p1.add(buttons[i], grid33); // 在 panel 1內加入按鈕陣列

}






myfrm.add(p1); // 在視窗myfrm 內加入 panel 1


JPanel p3 = new JPanel(grid33); //實作 panel 3


for (int i = 0; i < numbers.length; i++)

{

labels[i] = new JLabel(); // create labels

p3.add(labels[i], grid33); // 在 panel 1內加入按鈕陣列

}

myfrm.add(p3); // 在視窗myfrm 內加入 panel 3





JPanel p2 = new JPanel(flow); //實作 panel 2


JButton btn1=new JButton("JButton 1"); // 建立按鈕物件 btn1

btn1.addActionListener(myfrm);


p2.add(tbx1); // 在 panel 2內加入文字方塊


p2.add(btn1); // 在 panel 2內加入按鈕





myfrm.add(p2); // 在視窗myfrm 內加入 panel 2










myfrm.setVisible(true);


}





public void actionPerformed(ActionEvent e)

{

String numbers[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};

//int rndno;

//String stringValue;

//stringValue=tbx1.getText();

//int intValue = Integer.parseInt(stringValue);

//System.out.println(intValue);


//labels[intValue].setText(stringValue);




/*

for (int j = 0; j < 9; j++)

{

//rndno=(int) (Math.random()*9);

//System.out.println(rndno);

//numbers[i]=String.valueOf(rndno);

//buttons[i].setLabel(numbers[i]);

}


*/





//tbx1.setText(numbers[0]);

//buttons[rndno].setBackground(Color.blue);

//labels[rndno].setText(numbers[0]);


}


}
====================================================

第十週 (2011年4月22日)


What is 8 puzzle?

=========================================================================// with event
//Swing, JButton類別 有ActionListener
//Swing, JButton類別
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingTestEvent extends JFrame implements ActionListener
{
//static JFrame myfrm=new JFrame("JButton class"); // Java Class JFrame
//static AwtTestEvent myfrm=new AwtTestEvent("JFrame 1 "); // Java Class JFrame

static JTextField tbx1=new JTextField(2); // 建立1文字方塊物件
static JButton buttons[]=new JButton[10];
static JLabel  labels[]=new JLabel [10];
public static void main(String args[])
{
SwingTestEvent myfrm=new SwingTestEvent();


String numbers[]  = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};
FlowLayout flow=new FlowLayout();
GridLayout grid12= new GridLayout(1,2);
GridLayout grid33= new GridLayout(3,3);
myfrm.setLayout(grid12);
myfrm.setSize(450,450);
JPanel p1 = new JPanel(grid33); //實作  panel 1
for (int i = 0; i < numbers.length; i++)
{
buttons[i] = new JButton(numbers[i]); // create buttons
p1.add(buttons[i], grid33); // 在 panel 1內加入按鈕陣列
}

myfrm.add(p1); // 在視窗myfrm 內加入 panel 1
JPanel p3 = new JPanel(grid33); //實作  panel 3
for (int i = 0; i < numbers.length; i++)
{
labels[i] = new JLabel(); // create labels
p3.add(labels[i], grid33); // 在 panel 1內加入按鈕陣列
}
myfrm.add(p3); // 在視窗myfrm 內加入 panel 3

JPanel p2 = new JPanel(flow); //實作  panel 2
JButton btn1=new JButton("JButton 1"); // 建立按鈕物件 btn1
btn1.addActionListener(myfrm);
p2.add(tbx1); // 在 panel 2內加入文字方塊
p2.add(btn1); // 在 panel 2內加入按鈕

myfrm.add(p2); // 在視窗myfrm 內加入 panel 2


myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
//String numbers[]  = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};
String numbers[]=new String[101];
for (int i = 0; i <100; i++)
{
numbers[i]=String.valueOf(i);
}
int rndno;
String stringValue;
String tmp;
//stringValue=tbx1.getText();
//int intValue = Integer.parseInt(stringValue);
//System.out.println(intValue);
//labels[intValue].setText(stringValue);

for (int i = 0; i < 9; i++)
{
int j=8-i;
rndno=(int) (Math.random()*(j+1));
System.out.println(rndno);
tmp=numbers[j];
numbers[j]=numbers[rndno];
numbers[rndno]=tmp;
}
for (int i = 0; i < 9; i++)
{
System.out.println(numbers[i]);
buttons[i].setLabel(numbers[i]);
}
//tbx1.setText(numbers[0]);
//buttons[rndno].setBackground(Color.blue);
//labels[rndno].setText(numbers[0]);
}
}
=========================================================================
作業  bingo card


第八週 (2011年4月8日)

1. penel 1 with 3x3 JButton
2. penel 2 3x3 JLabel
3. penel 3 1x2 JTextField
4. penel 4  1 JButton
5. INPUT Number to 2 JTextFields
6. Change the colors of  JButton and JLabel

====================================================================
// with event
//Swing, JButton類別 有ActionListener
//Swing, JButton類別
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingTestEvent extends JFrame implements ActionListener
{
//static JFrame myfrm=new JFrame("JButton class"); // Java Class JFrame
//static AwtTestEvent myfrm=new AwtTestEvent("JFrame 1 "); // Java Class JFrame
static JTextField tbx1=new JTextField(2); // 建立1文字方塊物件
static JButton buttons[]=new JButton[10];
static JLabel  labels[]=new JLabel [10];
public static void main(String args[])
{
SwingTestEvent myfrm=new SwingTestEvent();

String numbers[]  = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};
FlowLayout flow=new FlowLayout();
GridLayout grid12= new GridLayout(1,2);
GridLayout grid33= new GridLayout(3,3);
myfrm.setLayout(grid12);
myfrm.setSize(450,450);
JPanel p1 = new JPanel(grid33); //實作  panel 1
for (int i = 0; i < numbers.length; i++)
{
buttons[i] = new JButton(numbers[i]); // create buttons
p1.add(buttons[i], grid33); // 在 panel 1內加入按鈕陣列
}

myfrm.add(p1); // 在視窗myfrm 內加入 panel 1
JPanel p3 = new JPanel(grid33); //實作  panel 3
for (int i = 0; i < numbers.length; i++)
{
labels[i] = new JLabel(); // create labels
p3.add(labels[i], grid33); // 在 panel 1內加入按鈕陣列
}
myfrm.add(p3); // 在視窗myfrm 內加入 panel 3

JPanel p2 = new JPanel(flow); //實作  panel 2
JButton btn1=new JButton("JButton 1"); // 建立按鈕物件 btn1
btn1.addActionListener(myfrm);
p2.add(tbx1); // 在 panel 2內加入文字方塊
p2.add(btn1); // 在 panel 2內加入按鈕

myfrm.add(p2); // 在視窗myfrm 內加入 panel 2


myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String stringValue;
stringValue=tbx1.getText();
int intValue = Integer.parseInt(stringValue);
System.out.println(intValue);
buttons[intValue].setBackground(Color.blue);
labels[intValue].setText(stringValue);

}
}


=====================================================================

第七週 (2011年4月1日)
GOOGLE Search
keywords
1. java for
2. java Class FlowLayout
3. java Class ActionEvent
4. java Class Button

(1) AWT 換成Swing
      1.全部物件加J
      2.import swing
=======================================================================
//AWT, Button Class
import java.awt.*;
import java.awt.event.*;

public class AwtTest extends Frame
{
static Frame myfrm=new Frame("Button class"); // Java Class Frame
static Button btn1=new Button("Button 1"); // 建立1按鈕物件
static Button btn2=new Button("Button 2"); // 建立2按鈕物件
static TextField tbx1=new TextField("TextField  1"); // 建立1文字方塊物件

public static void main(String args[])
{
BorderLayout border=new BorderLayout();
myfrm.setLayout(border);
myfrm.setSize(250,150);
myfrm.add(btn1, border.EAST); // 在視窗內加入按鈕1
myfrm.add(btn2, border.CENTER); // 在視窗內加入按鈕2
myfrm.add(tbx1, border.WEST); // 在視窗內加入按鈕2
myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
int rn;
rn=(int) (Math.random()*49) ;
System.out.println(rn );
}
}
======================================================================





GridLayout border= new GridLayout(0,2);


==============================================================


(2) 利用 for 和  物件陣列產生多個按鈕並用GridLayout排列
==============================================================

//AWT, JButton類別
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import javax.swing.JButton;

public class SwingTest extends JFrame
{
static JFrame myfrm=new JFrame("JButton class"); // Java Class JFrame
static JTextField tbx1=new JTextField("JTextField  1"); // 建立1文字方塊物件
/*
// goes on to 26JButtons[] buttons = new JButton(numbers.length)
// create instance of each buttonfor (int i = 0; i < numbers.length; i++){buttons[i] = new JButton(numbers[i]);
// create buttons } String[] numbers = {"0", "1", "2", "3", 4", "5", "6", "7", "8", "9"};
// goes on to 26
*/
public static void main(String args[])
{
JButton buttons[]=new JButton[10];
String numbers[]  = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};
//GridBagLayout  border=new GridBagLayout ();
GridLayout border= new GridLayout(3,3);
JPanel p = new JPanel(border); //PREFERRED!
for (int i = 0; i < numbers.length; i++)
{
buttons[i] = new JButton(numbers[i]); // create buttons
p.add(buttons[i], border); // 在視窗內加入按鈕1
}
myfrm.add(p);


myfrm.setLayout(border);
myfrm.setSize(250,150);
// create instance of each button
//FlowLayout flow= new  FlowLayout();
// myfrm.add(tbx1, flow); // 在視窗內加入文字方塊

myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
int rn;
rn=(int) (Math.random()*49) ;
System.out.println(rn );
}
}
==============================================================




================================================================

Google search



=================================================================

// with event
//Swing, JButton類別 有ActionListener
//Swing, JButton類別
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class SwingTestEvent extends JFrame implements ActionListener
{
//static JFrame myfrm=new JFrame("JButton class"); // Java Class JFrame
//static AwtTestEvent myfrm=new AwtTestEvent("JFrame 1 "); // Java Class JFrame

static JTextField tbx1=new JTextField(2); // 建立1文字方塊物件
static JButton buttons[]=new JButton[10];
public static void main(String args[])
{
SwingTestEvent myfrm=new SwingTestEvent();


String numbers[]  = {"0", "1", "2", "3", "4", "5", "6", "7", "8"};

FlowLayout flow=new FlowLayout();
GridLayout grid12= new GridLayout(1,2);
GridLayout grid33= new GridLayout(3,3);

myfrm.setLayout(grid12);
myfrm.setSize(450,450);

JPanel p1 = new JPanel(grid33); //實作  panel 1

for (int i = 0; i < numbers.length; i++)
{
buttons[i] = new JButton(numbers[i]); // create buttons
p1.add(buttons[i], grid33); // 在 panel 1內加入按鈕陣列
}

myfrm.add(p1); // 在視窗myfrm 內加入 panel 1

JPanel p2 = new JPanel(flow); //實作  panel 2

JButton btn1=new JButton("JButton 1"); // 建立按鈕物件 btn1
btn1.addActionListener(myfrm);

p2.add(tbx1); // 在 panel 2內加入文字方塊

p2.add(btn1); // 在 panel 2內加入按鈕


myfrm.add(p2); // 在視窗myfrm 內加入 panel 2

myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{

String stringValue;
stringValue=tbx1.getText();
int intValue = Integer.parseInt(stringValue);
System.out.println(intValue);
buttons[intValue].setBackground(Color.blue);
}
}


================================================================
(3) ActionEvent e, 利用e.getSource()
   JButton btn=new JButton();
   btn=e.getSource()

   if (btn=btn1)
   {
    btn1.setBackground(Color.white);

   }  
   if (btn=btn2)

  {
   btn2.setBackground(Color.green);

   }


(4) 將main()變簡單,將藍色字移送到
1. 建構子方法
2. creatGUI()


public static void main(String args[])

{
BorderLayout border=new BorderLayout();
myfrm.setLayout(border);
myfrm.setSize(200,150);
myfrm.add(btn1, border.EAST); // 在視窗內加入按鈕1
myfrm.add(btn2, border.Center); // 在視窗內加入按鈕2
myfrm.add(tbx1, border.WEST); // 在視窗內加入按鈕2
myfrm.setVisible(true);
}






第六週 (2011年3月25日)
隨堂測驗

大樂透開獎號碼 7 個放入7個
文字方塊(當一個按鈕被按下時)


書到用時方恨少
只要Google 沒煩惱

Java 書當字典就好 (The java textbooks are only used as dictionaries )
Ex
Google
keywords


1. Basic Class Template of  AWT
======================================================================
//AWT, Button類別
import java.awt.*;
public class AwtTest
{
static Frame myfrm=new Frame("Button class"); // Java Class Frame
static Button btn1=new Button("Button 1"); // 建立1按鈕物件
static Button btn2=new Button("Button 2"); // 建立2按鈕物件
static TextField tbx1=new TextField("TextField  1"); // 建立1文字方塊物件

public static void main(String args[])
{
BorderLayout border=new BorderLayout();
myfrm.setLayout(border);
myfrm.setSize(200,150);
myfrm.add(btn1, border.EAST); // 在視窗內加入按鈕1
myfrm.add(btn2, border.Center); // 在視窗內加入按鈕2
myfrm.add(tbx1, border.WEST); // 在視窗內加入按鈕2
myfrm.setVisible(true);
}
}
===================================================================


===================================================================
// with event
//AWT, Button類別 有ActionListener
//AWT, Button類別
import java.awt.*;
import java.awt.event.*;
public class AwtTestEvent extends Frame implements ActionListener
{
//static Frame myfrm=new Frame("Button class"); // Java Class Frame
//static AwtTestEvent myfrm=new AwtTestEvent("Frame 1 "); // Java Class Frame
static Button btn1=new Button("Button 1"); // 建立1按鈕物件
static Button btn2=new Button("Button 2"); // 建立2按鈕物件
static TextField tbx1=new TextField("TextField  1"); // 建立1文字方塊物件

public static void main(String args[])
{
AwtTestEvent myfrm=new AwtTestEvent();
BorderLayout border=new BorderLayout();
myfrm.setLayout(border);
myfrm.setSize(250,150);
btn1.addActionListener(myfrm);
myfrm.add(btn1, border.WEST); // 在視窗內加入按鈕1
myfrm.add(btn2, border.CENTER); // 在視窗內加入按鈕2
myfrm.add(tbx1, border.EAST); // 在視窗內加入文字方塊1;
}
public void actionPerformed(ActionEvent e)
{
int rn;
rn=(int) (Math.random()*49) ;
String stringValue = Integer.toString(rn);
System.out.println(rn );
tbx1.setText( stringValue );
}
}
===================================================================
Why these two commends?
import java.awt.*;
import java.awt.event.*;

Because




===================================================================
2. Basic Class Template of  Swing

===================================================================
import java.awt.*;

import java.awt.event.*;
import javax.swing.*;
public class ButtonText extends JFrame implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText( )
{
JButton mybutton1 = new JButton("Submit");
JButton mybutton2 = new JButton("Submit");
mybutton1.addActionListener(this);
//Container contentPane = frame.getContentPane();
//contentPane.add(mybutton1);
//contentPane.add(mybutton2);
getContentPane().add(mybutton1);
getContentPane().add(mybutton2);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(200,100);
setVisible(true);
// System.out.println("wait");
//System.exit(0);
}
public void actionPerformed(ActionEvent e)
{
int rn;
rn=(int) (Math.random()*49) ;
System.out.println(rn );
}
}

======================================================================
// app17_8, Button類別
import java.awt.*;
public class app17_8
{
   static Frame frm=new Frame("Button class");
   static Button btn=new Button("Push Me!!");   // 建立按鈕物件
    
   public static void main(String args[])
   {
      frm.setSize(200,150);
      frm.add(btn);                             // 在視窗內加入按鈕
      frm.setVisible(true);    
   }
}

==============================================================


// app19_8, 對話方塊的實例應用
import java.awt.*;
import java.awt.event.*;
public class app19_8 extends Frame implements ActionListener
{
   static app19_8 frm=new app19_8();
   static Dialog dlg=new Dialog(frm);              // 建立Dialog物件dlg
   static Button Close_btn=new Button("Close");    // Close 按鈕
   static Button Cancel_btn=new Button("Cancel");  // Cancel按鈕
   static WinLis wlis=new WinLis();                // 建立傾聽者物件wlis

   public static void main(String args[])
   {
      frm.setTitle("Dialog Demo");
      frm.setSize(200,150);
      dlg.setTitle("Are you sure?");               // 設定對話方塊的標題
      dlg.setSize(140,100);                        // 設定對話方塊的大小
      dlg.setLayout(new FlowLayout(FlowLayout.CENTER,5,30));
      dlg.add(Close_btn);                          // 將Close_btn加入對話方塊中
      dlg.add(Cancel_btn);                         // 將Cancel_btn加入對話方塊中
      Cancel_btn.addActionListener(frm);           // 設定Cancel_btn的傾聽者
      Close_btn.addActionListener(frm);            // 設定Close_btn的傾聽者
      frm.addWindowListener(wlis);                 // 設定frm的傾聽者
      frm.setVisible(true);
   }

   static class WinLis extends WindowAdapter
   {
      public void windowClosing(WindowEvent e)     // 按下視窗關閉鈕時
      {
         dlg.setLocation(80,30);                   // 設定對話方塊的位置
         dlg.show();                               // 顯示對話方塊
      }
   }  

   public void actionPerformed(ActionEvent e)      // 按下對話方塊上的按鈕時
   {
      Button btn=(Button) e.getSource();           // 取得被按下的按鈕
      if(btn==Close_btn)                           // 如果是Close按鈕被按下
      {
         dlg.dispose();                            // 關閉對話方塊
         frm.dispose();                            // 關閉視窗
      }
      else if (btn==Cancel_btn)                    // 如果是Cancel按鈕被按下
         dlg.hide();                               // 隱藏對話方塊
   }
}



====================================================================




Google keywords
JAVA CLASS JTEXTBOX


大樂透開獎號碼

java random







第五週 (2011年3月18日)



Please google the keywords java class textbox

Please google the keywords VB event and Java event.

http://www.idevelopment.info/data/Programming/java/swing/AWTExample.java


visualage for Java, Entry Edition - Taiwan.CNET.com - 下載專區



================================================================
import java.awt.*;


import java.awt.event.*;

import javax.swing.*;



public class ButtonText extends JFrame implements ActionListener {



public static void main(String[] args) {

ButtonText test = new ButtonText();

}



ButtonText( )

{

JButton mybutton1 = new JButton("Submit");

JButton mybutton2 = new JButton("Submit");

mybutton1.addActionListener(this);

//Container contentPane = frame.getContentPane();

//contentPane.add(mybutton1);

//contentPane.add(mybutton2);



getContentPane().add(mybutton1);

getContentPane().add(mybutton2);

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setLayout(new FlowLayout());





setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

setSize(200,100);

setVisible(true);



// System.out.println("wait");

//System.exit(0);



}

public void actionPerformed(ActionEvent e)

{

int rn;

rn=(int) (Math.random()*49) ;

System.out.println(rn );

}



}



=====================================================================



java layout




=============================================================



import java.awt.*;

import java.awt.event.*;
import javax.swing.*;
public class ButtonText extends JFrame implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText( )
{
// JButton mybutton1 = new JButton("Submit");
// JButton mybutton2 = new JButton("Submit");
//mybutton1.addActionListener(this);
//getContentPane().add(mybutton1);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/*
myframe.add(mybutton1);
myframe.add(mybutton2);
myframe.setLayout(new FlowLayout());
myframe.setSize(200,100);
myframe.setVisible(true);
// System.out.println("wait");
//System.exit(0);
*/
}


public void actionPerformed(ActionEvent e)
{

}

}





=============================================================
import java.awt.*;

import java.awt.event.*;
import javax.swing.*;
public class ButtonText{
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText( )
{
Frame myframe=new Frame("Button Frame");
Button mybutton1 = new Button("Submit");
Button mybutton2 = new Button("Submit");
mybutton1.addActionListener(this);
myframe.add(mybutton1);
myframe.add(mybutton2);
myframe.setLayout(new FlowLayout());
myframe.setSize(200,100);
myframe.setVisible(true);
/*


// System.out.println("wait");


//System.exit(0);


*/
}


}







import java.awt.*; 
import java.awt.event.*;
 

public class ButtonText 
  public static void main(String[] args) {
    Frame frame=new Frame("Button Frame");
    Button button = new Button("Submit")
    frame.add(button)
    frame.setLayout(new FlowLayout());
    frame.setSize(200,100);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter(){
      public void windowClosing(WindowEvent e){
        System.exit(0);
      }
    });
  }
}



第四週 (2011年3月11日)

java button



import java.awt.*;

Frame frame=new Frame("Button Frame");
Button button = new Button("Submit");
frame.add(button);
frame.setVisible(true);

An example to show how to use textboxs.



Please google the keywords VB event and Java event.




第四週 (2011年3月4日)

Vb button
It is easy to put a button on a VB form.
java button


Why it is so diffcult to put a button on a JAVA  frame?

Java Class button is easy to be extended to make your own button class, but VB is not so open for you to do your own buton.


Java double to int and Other Conversions




Please google keywords "Java Button" to find another example!
To know how to put a button on a frame!
The most important commands are as follows.


import java.awt.*;

Frame frame=new Frame("Button Frame");
Button button = new Button("Submit");
frame.add(button);
frame.setVisible(true);

How to Create Button on Frame,Create a Button in Java,Code to ...

The comment "import java.awt.*;" is related to the file src.zip.




How to Use Buttons, Check Boxes, and Radio Buttons


java class button

隨堂練習


放上一個 Check Boxes




第三週 (2011年3月4日)


隨堂練習

輸入四個數字,前兩個數字代表列向量,後兩個數字代表行向量,
輸出矩陣相乘計算的結果






Java String int




Java String










java return type required
















2. 第二週 (2011年2月25日)






課堂作業



1.  第一週 (2011年2月18日)

考試
1.

製作自己的學習部落格blog
回答下列問題
1.為何why要選修這門課?(動機)
2.希忘從這門課獲得那些知識?(目標)
3.我要如何修習這一門課?(態度與方法)
who, when, where 

回答問題: 請問您畢業後,如果找不到工作,您會花錢去上 "Java程式設計實力精修班" 課程嗎? 為甚麼?請您說明原因,100個字以上。
  

3. 下載並安裝 Java Platform (JDK)  Java SE Downloads 並 參考網頁 "Hello World!" for Microsoft Windows 執行程式 ,使結果出現 Hello World!


參考網址

java 下載 與 安裝 執行 hellow

http://tccnchsu.blogspot.com/2010/02/java.html

google blog css

同學的部落格

學號   姓名    網址
D9735878 劉哲宇 http://nicejava-java.blogspot.com/
D9785801 張鶴櫪 http://d9785801.blogspot.com/
D9735780 劉華瑋 http://alan5820.blogspot.com/
D9735851 彭凱頎 http://bleakmirage.blogspot.com/
D9735818 蕭銘宏 http://sean80221123.blogspot.com/
D9735937 汪筠捷 http://tony11206.blogspot.com/
D9785934李虹毅http://responsible10.blogspot.com/
D9785862王志明  http://j12345741258.blogspot.com/
D9790384吳育全 http://gary1424.blogspot.com/
D9785760莊桂軒http://www.wretch.cc/blog/onlyyazu

D9785917 謝翰嶔 http://jack10169.blogspot.com/

D9785790 詹宏茂 http://rfdg8546.blogspot.com/

D9726464 吳昱鋒 http://www.wretch.cc/blog/jk15478
D9642313 黃俊隆http://loganlearninglog.blogspot.com/
D9785578 汪聖凱http://www.wretch.cc/blog/bho2980112sa
D9726481 黃建志 http://s10024157.blogspot.com/
D9681524 郭政霖 http://www.wretch.cc/blog/charlie0525
d9643522  林哲瑜 http://www.wretch.cc/blog/warbobobo
d9726327 陳政瑜 http://www.wretch.cc/blog/jc1113
D9681200 廖崇閔http://www.wretch.cc/blog/kobe770201
D9681483 孫子策http://www.wretch.cc/blog/qoopooguy
D9681609劉駿賢http://www.wretch.cc/blog/chi2980119nn
D9735970顏三峻http://www.wretch.cc/blog/ysj78113
D9681139林俊德http://www.wretch.cc/blog/YFU385
D9786107郭榮浩http://swsy10301.blogspot.com/
D9681452吳智閔http://tw.myblog.yahoo.com/jw!zJVuSkGFBQBrxXRQDPohWf1w5209
D9681231劉晏君http://www.wretch.cc/blog/postre
D9642433柯志陽http://www.wretch.cc/blog/s2463715s
D9681316郭宗賢http://kuohome123.blogspot.com/


4 則留言:

學習日誌 提到...
作者已經移除這則留言。
學習日誌 提到...

http://www.youtube.com/watch?v=Xt7G4QA2Q8w&feature=player_embedded#at=38

匿名 提到...

this is soooooooooooooooooooooooo gorgeousbridal jacket

侯昀中 提到...

侯昀中