ログインウィンドウは一般的に非常に一般的ですので、自分で書いてみましょう!
PS:いくつかのカテゴリで書いており、個別にインポートする必要があるため、多くの輸入品が重複しています。
// QQログインウィンドウをシミュレートするJava.awt。*;インポートjava.io。*; Import java.awt.event。*; import javax.swing。プライベートJlabel Pwdla; Private Jlabel Vercodela; //検証コードprivate jtextfield usertxt;プライベートjPasswordfield pwdtxt; private jtextfield vercodetxt; //検証コードprivate jbutton surebt;プライベートJbutton Quitbt;プライベートマイパネルMP; //構築方法public qqgui(){init(); } public void init(){frame frame = new Frame( "qq login"); //コントロールオブジェクトを作成します(上記が宣言されていて実際のスペースが与えられないため)//ユーザーテキストuserla = new Jlabel(); userla.settext( "user name:"); userla.setsize(60、50); userla.setlocation(100、80); //パスワードテキストpwdla = new Jlabel(); pwdla.settext( "password:"); pwdla.setsize(50、50); pwdla.setlocation(100、120); //ユーザー入力ボックスusertxt = new jtextfield(); usertxt.setsize(100、20); //this.setsize(width、height)usertxt.setlocation(170、95); //パスワード入力ボックスpwdtxt = new JPassWordField(); pwdtxt.setsize(100、20); pwdtxt.setlocation(170、135); // Buttonを確認するSureBT = new JButton( "Login"); SureBt.Setsize(60、25); SureBt.SetLocation(135、260); // exitボタンquitbt = new jbutton( "exit"); quitbt.setsize(60、25); quitbt.setlocation(240、260); //検証コードテキストvercodela = new Jlabel(); vercodela.settext( "検証コード:"); vercodela.setsize(60、50); vercodela.setlocation(100、165); //検証コードテキストボックスvercodetxt = new jtextfield(); vercodetxt.setsize(100、20); vercodetxt.setlocation(170、180); //検証コードmp = new mypanel(); mp.setsize(100、30); mp.setlocation(280、175); //ログインメソッド選択ボックスjcombobox xlk = new jcombobox(); xlk.setsize(60、20); xlk.setlocation(250、220); xlk.additem( "online"); xlk.additem( "Invisible"); xlk.additem( "leave"); this.setlayout(null); this.setsize(500、400); this.add(userla); this.add(pwdla); this.add(usertxt); this.add(surebt); this.add(quitbt); this.add(vercodela); this.add(vercodetxt); this.add(mp); this.add(xlk); SureBt.AddActionListener(this); quitbt.addactionlistener(this); this.setVisible(true); } //特定のイベントの処理public void ActionPerformed(actionEvent e){//イベントソースキャストjbutton bt =(jbutton)e.getSource(); //ボタンに表示されるテキストを取得しますstring str = bt.getText(); if(str.equals( "login")){if(!checkisnull()){// user string user = usertxt.getText()。trim()によって入力されたユーザー名を取得します。 //ユーザー文字列で入力されたパスワードを取得しますpwd = pwdtxt.getText()。trim(); if(checkuserandpwd(user、pwd)){//現在のログインウィンドウthis.setVisible(false); //メインウィンドウが正常に作成されていることを確認しますMainFrame Frame = new MainFrame(); } else {//間違っている場合、ディスプレイボックスがJoptionPane Pane = new JoptionPane( "ユーザーまたはパスワードエラー")をポップアップします。 jdialogダイアログ= pane.createdialog(this、 "警告"); dialog.show(); }}} else {//システムクラスの1つを呼び出してSystem.Exit(0)を終了するには; }} private boolean checkisnull(){boolean flag = false; if(usertxt.getText()。trim()。equals( ")){flag = true;} else {if(pwdtxt.getText()。trim()。equals(")){flag = true; }} return flag; } private boolean checkuserandpwd(string user、string pwd){boolean result = false; try {fileReader file = new fileReader( "d:// workspaces // myeclipse 8.5 // testgui.txt"); BufferedReader BRE = new BufferedReader(file); string str = bre.readline(); while(str!= null){string [] strs = str.split( "、"); if(strs [0] .equals(user)){if(strs [1] .equals(pwd))result = true; } str = bre.readline(); } file.close(); } catch(Exception ex){system.out.print( ""); } return result; }} // mainframeクラスインポートjavax.swing。*; public class mainframeはjframe {public mainframe(){this.setsize(300、300); this.setVisible(true); }} //検証コードの生成java.awt。*;インポートjava.util。*; public class mypanel extendsパネル{public void paint(graphics g){int height = 50; int width = 90; //検証コードボックスの背景色G.SetColor(color.light_gray); //検証コードの背景G.FillRect(0、0、幅、高さ)を入力します。 g.setcolor(color.black); G.drawrect(0、0、width-1、height-1);ランダムr = new Random(); //(int i = 0; i <100; i ++){int x = r.nextint(width)-1;の干渉点を設定します。 int y = r.nextint(height)-1; G.drawoval(x、y、2、2); } g.setFont(new Font( "Bold"、font.bold、20)); //検証コードフォントとサイズG.SetColor(color.red)を設定します。 //検証コードフォントカラーを設定する//ランダム検証コードchar [] tmp =( "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ")。 stringbuilder sb = new StringBuilder(); for(int i = 0; i <4; i ++){int pos = r.nextint(tmp.length); char c = tmp [pos]; sb.append(c + ""); } g.drawstring(sb.tostring()、10、15); //書き込み検証コード}} //ドロップダウンボックスの実装java.awt。 // jPanelパネル= new jPanel(); // jPanelパネルComboBox = new JComboBox();を作成します。 combobox.additem( "online"); combobox.additem( "Invisible"); combobox.additem( "leave"); this.add(combobox); //this.add(panel); this.setsize(200、100); this.setDefaultCloseoperation(jframe.exit_on_close); this.setVisible(true); }} // public Public class testqqgui {/** * @param args */public static void main(string [] args){// todo auto-feenated method stub qqgui frame = new qqgui(); }}上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。