|
|
AKDR
鍛鐵驢友
. 積分: 89
. 文章: 708
. 收花: 386 支
. 送花: 275 支
. 比例: 0.71
. 在線: 522 小時
. 瀏覽: 4240 頁
. 註冊: 8217 天
. 失蹤: 3060 天
|
|
|
|
|
|
|
#1 : 2006-6-15 08:09 PM
全部回覆
|
送花
(6)
送出中...
|
|
|
大概是這樣吧.不是我也沒辦了:lol
-------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
public class 王小明 extends Frame implements
ActionListener,AdjustmentListener
{
static 王小明 frm=new 王小明();
static Button btn1=new Button("我 的 姓 名");
static Button btn2=new Button("學 號");
static Button btn3=new Button("興 趣");
static Button btn4=new Button("自 傳 簡 介");
static Button btn5=new Button("清 除");
static Panel pnl=new Panel();
static Scrollbar scr1=new Scrollbar(Scrollbar.VERTICAL);
static Scrollbar scr2=new Scrollbar(Scrollbar.HORIZONTAL);
static TextArea txa=new TextArea("",8,14,TextArea.SCROLLBARS_VERTICAL_ONLY);
static WinLis wlis=new WinLis();
public static void main(String args[])
{
BorderLayout br=new BorderLayout(5,5);
scr1.addAdjustmentListener(frm);
scr1.setValues(20,4,26,150);
scr2.addAdjustmentListener(frm);
scr2.setValues(10,4,15,200);
btn1.addActionListener(frm);
btn2.addActionListener(frm);
btn3.addActionListener(frm);
btn4.addActionListener(frm);
btn5.addActionListener(frm);
frm.setTitle("A123456789 王小明");
frm.addWindowListener(wlis);
frm.setSize(500,450);
frm.setBackground(Color.yellow);
frm.add(scr1,br.EAST);
frm.add(scr2,br.SOUTH);
pnl.setLayout(null);
btn1.setSize(80,30);
btn2.setSize(80,30);
btn3.setSize(80,30);
btn4.setSize(80,30);
btn5.setSize(80,30);
txa.setSize(200,280);
btn1.setLocation(60,40);
btn2.setLocation(60,100);
btn3.setLocation(60,160);
btn4.setLocation(60,220);
btn5.setLocation(60,280);
txa.setLocation(200,40);
pnl.add(btn1);
pnl.add(btn2);
pnl.add(btn3);
pnl.add(btn4);
pnl.add(btn5);
pnl.add(txa);
frm.add(pnl,br.CENTER);
txa.setEditable(false);
frm.setVisible(true);
}
public void adjustmentValueChanged(AdjustmentEvent e)
{
int x=scr2.getValue();
int y=scr1.getValue();
pnl.setLocation(x,y);
}
public void actionPerformed(ActionEvent e)
{
Button btn=(Button) e.getSource();
if(btn==btn1)
txa.setText("王小明");
else if(btn==btn2)
txa.setText("B932011574");
else if(btn==btn3)
txa.setText("集郵、下棋");
else if(btn==btn4)
txa.setText("人家都叫我王小明,我以前在便利商店工作過");
else if(btn==btn5)
txa.setText("");
}
static class WinLis extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.out.println("windowClosing() called");
System.out.println("Closing window...");
frm.dispose();
System.out.println("window closed...");
}
public void windowClosed(WindowEvent e)
{
System.out.println("windowClosed() called");
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("windowDeactivated() called");
}
public void windowActivated(WindowEvent e)
{
System.out.println("windowActivated() called");
}
public void windowDeiconified(WindowEvent e)
{
System.out.println("windowDeiconified() called");
}
public void windowIconified(WindowEvent e)
{
System.out.println("windowIconified() called");
}
public void windowOpened(WindowEvent e)
{
System.out.println("windowOpened() called");
}
[如果你喜歡本文章,就按本文章之鮮花~送花給作者吧,你的支持就是別人的動力來源]
|
|