程式設計工藝大師 :http://tccnchsu.blogspot.com/
import java.awt.*;
import java.awt.event.*;
public class awt2 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");
static TextField tbx1=new TextField("TextField 1");
static TextField tbx2=new TextField("TextField 2");
static TextField tbx3=new TextField("TextField 3");
static TextField tbx4=new TextField("TextField 4");
static TextField tbx5=new TextField("TextField 5");
static TextField tbx6=new TextField("TextField 6");
static TextField tbx7=new TextField("TextField 7");
public static void main(String args[])
{
awt2 myfrm=new awt2();
FlowLayout flow=new FlowLayout();
myfrm.setLayout(flow);
myfrm.setSize(500,200);
btn1.addActionListener(myfrm);
myfrm.add(btn1, flow.LEFT);
myfrm.add(tbx1, flow.LEFT);
myfrm.add(tbx2, flow.LEFT);
myfrm.add(tbx3, flow.LEFT);
myfrm.add(tbx4, flow.LEFT);
myfrm.add(tbx5, flow.LEFT);
myfrm.add(tbx6, flow.LEFT);
myfrm.add(tbx7, flow.LEFT);
myfrm.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
int rm1,rm2,rm3,rm4,rm5,rm6,rm7;
rm1 =(int)((Math.random()*49)+1);
rm2 =(int)((Math.random()*49)+1);
rm3 =(int)((Math.random()*49)+1);
rm4 =(int)((Math.random()*49)+1);
rm5 =(int)((Math.random()*49)+1);
rm6 =(int)((Math.random()*49)+1);
rm7 =(int)((Math.random()*49)+1);
String stringValue1 = Integer.toString(rm1);
String stringValue2= Integer.toString(rm2);
String stringValue3 = Integer.toString(rm3);
String stringValue4 = Integer.toString(rm4);
String stringValue5 = Integer.toString(rm5);
String stringValue6 = Integer.toString(rm6);
String stringValue7 = Integer.toString(rm7);
tbx1.setText( stringValue1 );
tbx2.setText( stringValue2 );
tbx3.setText( stringValue3 );
tbx4.setText( stringValue4 );
tbx5.setText( stringValue5 );
tbx6.setText( stringValue6 );
tbx7.setText( stringValue7 );
}
}
2011年3月25日 星期五
2011年3月24日 星期四
樂透+強
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ButtonText extends JFrame
implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText ()
{
Frame frame=new Frame("Button Frame");
Button button1 = new Button("Submit");
Button button2 = new Button("Submit");
button1.addActionListener(this);
frame.add(button1);
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(200,100);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
int loto[ ]=new int[7];
for(int i=0;i<loto.length;i++)
{
int a;
a=(int) (Math.random()*49+1) ;
loto[i]=a;
if(i==6)
System.out.println("特別號:"+loto[i]);
else
System.out.println("第"+(i+1)+"個開獎號碼:"+loto[i]);
}
}
}
import javax.swing.*;
import java.awt.event.*;
public class ButtonText extends JFrame
implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText ()
{
Frame frame=new Frame("Button Frame");
Button button1 = new Button("Submit");
Button button2 = new Button("Submit");
button1.addActionListener(this);
frame.add(button1);
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(200,100);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
int loto[ ]=new int[7];
for(int i=0;i<loto.length;i++)
{
int a;
a=(int) (Math.random()*49+1) ;
loto[i]=a;
if(i==6)
System.out.println("特別號:"+loto[i]);
else
System.out.println("第"+(i+1)+"個開獎號碼:"+loto[i]);
}
}
}
2011年3月18日 星期五
49 樂透
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ButtonText extends JFrame
implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText ()
{
Frame frame=new Frame("Button Frame");
Button button1 = new Button("Submit");
Button button2 = new Button("Submit");
button1.addActionListener(this);
frame.add(button1);
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(200,100);
frame.setVisible(true);
//System.out.println("123");
// System.exit(0);
}
public void actionPerformed(ActionEvent e)
{
int a ;
int b ;
int c ;
int d ;
int v ;
int f ;
int g ;
a=(int) (Math.random()*49+1) ;
b=(int) (Math.random()*49+1) ;
c=(int) (Math.random()*49+1) ;
d=(int) (Math.random()*49+1) ;
v=(int) (Math.random()*49+1) ;
f=(int) (Math.random()*49+1) ;
g=(int) (Math.random()*49+1) ;
import javax.swing.*;
import java.awt.event.*;
public class ButtonText extends JFrame
implements ActionListener {
public static void main(String[] args) {
ButtonText test = new ButtonText();
}
ButtonText ()
{
Frame frame=new Frame("Button Frame");
Button button1 = new Button("Submit");
Button button2 = new Button("Submit");
button1.addActionListener(this);
frame.add(button1);
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(200,100);
frame.setVisible(true);
//System.out.println("123");
// System.exit(0);
}
public void actionPerformed(ActionEvent e)
{
int a ;
int b ;
int c ;
int d ;
int v ;
int f ;
int g ;
a=(int) (Math.random()*49+1) ;
b=(int) (Math.random()*49+1) ;
c=(int) (Math.random()*49+1) ;
d=(int) (Math.random()*49+1) ;
v=(int) (Math.random()*49+1) ;
f=(int) (Math.random()*49+1) ;
g=(int) (Math.random()*49+1) ;
System.out.println(a );
System.out.println(b );
System.out.println(c );
System.out.println(d );
System.out.println(v );
System.out.println(f );
System.out.println(g );}
}
2011年3月11日 星期五
check botton
//import javax.swing.*;
import java.awt.*;
import java.awt.event.*; // 要處理事件必須 import 此套件
public class Work2 extends Frame
implements ActionListener
{
/**
* @param args
*/
//int act = 0; // 用來記錄按鈕被次數的變數
int SizeW = 2100;
int SizeH = 700;
public static void main(String[] args)
{
//Work2 test = new Work2();
Frame frame= new Frame("Checkbox");
Checkbox check=new Checkbox("4");
frame.add(check);
Checkbox check1=new Checkbox("3");
frame.add(check1);
// Frame frame=new Frame("Button Frame");
Button button1 = new Button("2");
frame.add(button1);
frame.setLayout(new FlowLayout());
Button button2 = new Button("1");
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(600,300);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
// 用建構方法來建立元件、將元件加入視窗、顯示視窗
//public Work2()
{
//setTitle("Listener 示範"); // 設定視窗標題
//JButton mybutton = new JButton("換個標題");
// 通知按鈕物件:本物件要當傾聽者
//mybutton.addActionListener(this);
//getContentPane().add(mybutton);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setSize(SizeW,SizeH);
//setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
//SizeW = (int) (SizeW * 0.5);
//SizeH = (int) (SizeH * 0.5);
//setSize(SizeW,SizeH);
}
}
import java.awt.*;
import java.awt.event.*; // 要處理事件必須 import 此套件
public class Work2 extends Frame
implements ActionListener
{
/**
* @param args
*/
//int act = 0; // 用來記錄按鈕被次數的變數
int SizeW = 2100;
int SizeH = 700;
public static void main(String[] args)
{
//Work2 test = new Work2();
Frame frame= new Frame("Checkbox");
Checkbox check=new Checkbox("4");
frame.add(check);
Checkbox check1=new Checkbox("3");
frame.add(check1);
// Frame frame=new Frame("Button Frame");
Button button1 = new Button("2");
frame.add(button1);
frame.setLayout(new FlowLayout());
Button button2 = new Button("1");
frame.add(button2);
frame.setLayout(new FlowLayout());
frame.setSize(600,300);
frame.setVisible(true);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
}
// 用建構方法來建立元件、將元件加入視窗、顯示視窗
//public Work2()
{
//setTitle("Listener 示範"); // 設定視窗標題
//JButton mybutton = new JButton("換個標題");
// 通知按鈕物件:本物件要當傾聽者
//mybutton.addActionListener(this);
//getContentPane().add(mybutton);
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//setSize(SizeW,SizeH);
//setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
//SizeW = (int) (SizeW * 0.5);
//SizeH = (int) (SizeH * 0.5);
//setSize(SizeW,SizeH);
}
}
2011年3月3日 星期四
訂閱:
文章 (Atom)