Java注冊(cè)界面設(shè)計(jì)_第1頁(yè)
Java注冊(cè)界面設(shè)計(jì)_第2頁(yè)
Java注冊(cè)界面設(shè)計(jì)_第3頁(yè)
Java注冊(cè)界面設(shè)計(jì)_第4頁(yè)
Java注冊(cè)界面設(shè)計(jì)_第5頁(yè)
免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Java注冊(cè)界面設(shè)計(jì)P ackage test;import java.awt .ponent;import java.awt.Dime nsion;import java.awt.F ont;import java.awt.GridBagC on stra in ts;import java.awt.GridBagLayout; import java.awt.Toolkit;import java.awt.eve nt.Act ion Eve nt; import java.awt.eve nt.Act ion Liste ner; import javax.swi ng.BorderFa

2、ctory; import javax.sw in g.Box;import javax.sw in g.Butt onGroup;import javax.sw in g.JButt on;import javax.sw in g.JboBox;import javax.swi ng.JFrame;import javax.sw in g.JLabel;import javax.swi ng.JO ptio nPane; import javax.sw in g.J Pan el;import javax.sw in g.J PasswordField; import javax.sw in

3、 g.JRadioButt on;import javax.swi ng.JTextField; import javax.sw in g.border.Border;import java.util.Vector;p ublic class Register_GUI p ublic Register_GUI() RegisterFrame rf = new RegisterFrame(); rf.setVisible(true);框架類p ublic static void main( Stri ng args) new Register_GUI();class RegisterFrame

4、exte nds JFrame /*/private static fin al lo ng serialVersio nUID = -3779096743730354383L; p rivate Toolkit tool;p ublic RegisterFrame() setTitle("用戶注冊(cè)"); tool = Toolkit.getDefaultToolkit(); Dime nsion ds = tool.getScree nSize(); int w = ds.width;int h = ds.height;setBou nds(w - 300) / 2, (

5、h - 300) / 2, 300, 300); setResizable(false);Register Panel rp = new Register Pan el(this); add(rp);容器類class Register Panel exte nds JPanel impi eme nts Action Liste ner /*/p rivate static fin al lo ng serialVers ionUID =-7078727217525013349L;p rivate JLabel titlelabel, n amelabel, p wdlabel1, p wdl

6、abel2, sexlabel, agelabel, classlabel;p rivate JTextField n amefield, agefield;p rivate JP asswordField p wdfield1, p wdfield2;p rivate JButt on mitbt n, resetbt n, can celbt n;private JRadioButt on rbtn1, rbtn2;p rivate JboBox bo;p rivate Vector<Stri ng> v;p rivate GridBagLayout gbl;p rivate

7、GridBagC on stra ints gbc;p rivate JPanel pan el;p rivate Box box;p rivate JFrame iframe;Register Pan el(JFrame frame) iframe = frame; titlelabel = new JLabel(" titlelabel.setFo nt(new Fo nt(” n amelabel = new JLabel(" p wdlabel1 = new JLabel(" p wdlabel2 = new JLabel(" sexlabel

8、= new JLabel(" agelabel = new JLabel(" classlabel = new JLabel("用戶注冊(cè)");華文彩云",Font.BOLD, 24);用戶名:”);密確認(rèn)密碼:性年所屬班級(jí):碼:");”);別:”);齡:”);");n amefield = new JTextField(16); p wdfield1 = new JP asswordField(16); p wdfield1.setEchoChar('*');p wdfield2 = new JP asswo

9、rdField(16); pwdfield2.setEchoChar('*');agefield = new JTextField(16);rbt n1 = new JRadioButto n("男”);rbt n2 = new JRadioButto n("女");rbt nl.setSelected(true);Butt onGroup bg = new Butt onGroup();bg.add(rbt n1);bg.add(rbt n2);v = new VectorvStri ng>();v.add("ACC P1&quo

10、t;);v.add("ACC P2");v.add("軟件開(kāi)發(fā)");v.add("網(wǎng)絡(luò)編程");v.add("計(jì)算機(jī)應(yīng)用");bo = new JboBox(v);mitbtn = new JButton(”注冊(cè)");mitbt n. addAct ion Liste ner(this);resetbt n = new JButto n(" 重置");resetbt n. addActi on Liste ner(this);cancelbtn = new JButton(” 取消&q

11、uot;);can celbt n. addAct ion Liste ner(this);panel = new JPan el();pan el.add(rbt n1);pan el.add(rbt n2);Border border = BorderFactory.createTitledBorder("");pan el.setBorder(border);box = Box.createHoriz on talBox();box.add(mitbt n);box.add(Box.createHorizo ntalStrut(30); box.add(resetbt

12、 n);box.add(Box.createHorizo ntalStrut(30);box.add(ca ncelbt n);gbl = new GridBagLayout();setLayout(gbl);gbc = new GridBagC on stra in ts();addpnen t(titlelabel, 0, 0, 4, 1);add(Box.createVerticalStrut(20);gbc.a nchor = GridBagCo nstrai nts.CENTER;gbc.fill = GridBagCo nstrai nts.HORIZONTAL; gbc.weig

13、htx = 0;gbc.weighty = 100;add pnent(n amelabel, 0, 1, 1, 1);add pnent(n amefield, 1, 1,4, 1);add pnen t( pwdlabel1,0, 2, 1, 1);add pnent(p wdfield1, 1,2, 4, 1);add pnen t( pwdlabel2, 0, 3, 1, 1);add pnent(p wdfield2, 1, 3, 4, 1);add pnen t(sexlabel, 0, 4, 1, 1);add pnent(pan el, 1,4, 1, 1);gbc.a nch

14、or = GridBagC on strai nts.EAST;gbc.fill = GridBagCo nstrai nts.NONE;add pnen t(agelabel, 2, 4, 1, 1);gbc.fill = GridBagCo nstrai nts.HORIZONTAL;add pnen t(agefield, 3, 4, 2, 1);add pnen t(classlabel, 0, 5, 4, 1);add pnen t(bo, 1,5, 4, 1);gbc.a nchor = GridBagCo nstrai nts.CENTER; gbc.fill = GridBag

15、Co nstrai nts.NONE;add pnen t(box, 0, 6, 4, 1);p ublic void add pnent(ponent c, int x, int y, int w, int h) gbc.gridx = x;gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; add(c, gbc);p ublic void actionP erformed(Acti onEvent e) Register rinfo = new Register();if (e.getSource() = mitbt n) rin f

16、o. name = n amefield.getText().trim();rinfo.p assword = new String(p wdfield1.get Password。); rin fo.sex = rbt n1.isSelected() ?"男”:"rin fo.age = agefield.getText().trim();rinfo.n class = bo.getSelectedItem().toStri ng();if (rinfo.n ame .len gth() = 0) 用戶名不能為空”);JOp tio nPan e.showMessageD

17、ialog( null, "t return;if (rinfo.p assword .len gth() = 0) 密碼不能為空");JOp tio nPan e.showMessageDialog( null, "t return;密碼兩次輸入不一致,請(qǐng)重新if (!ri nfo.p assword.equals( new String(p wdfield2.get Password。) JOp tio nPan e.showMessageDialog( null, ”輸入");return;if (rin fo.age.le ngth() = 0)

18、 JOp tio nPan e.showMessageDialog( null, "t return;int age = In teger. parse In t(ri nfo.age);if (age <= 0 | age > 100) JOp tio nPan e.showMessageDialog( null, "t return;JOp tio nPan e.showMessageDialog( nu II, 名:"++"n 性別:"+rinfo.sex+"n"+ri nfo.n class);if (e.getSource() = resetbt n) 年齡不能為空");年齡輸入不合法");"t年齡注冊(cè)成功!":"+ri nfo.age+"n+" n 姓班級(jí):n amefield.

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論