五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網 會員登陸 & 注冊

Java

2023-02-20 14:54 作者:宮城_7777  | 我要投稿

第四題 import javax.swing.*; import java.awt.*; public class Login extends JFrame { ??// 定義組件 ??JLabel jl1, jl2; ??JTextField jtf; ??JPasswordField jpf; ??JButton jb; ??public Login() { ????// 創(chuàng)建組件 ????jl1 = new JLabel("用戶名:"); ????jl2 = new JLabel("密碼:"); ????jtf = new JTextField(10); ????jpf = new JPasswordField(10); ????jb = new JButton("登錄"); ????// 設置布局為 GridLayout ????this.setLayout(new GridLayout(3, 2)); ????// 添加組件 ????this.add(jl1); ????this.add(jtf); ????this.add(jl2); ????this.add(jpf); ????this.add(jb); ????// 設置窗口屬性 ????this.setTitle("用戶登錄"); ????this.setSize(300, 150); ????this.setLocationRelativeTo(null); ????this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ????this.setVisible(true); ????// 為登錄按鈕添加事件監(jiān)聽器 ????jb.addActionListener(e -> { ??????// 獲取用戶名和密碼 ??????String username = jtf.getText(); ??????char[] password = jpf.getPassword(); ??????// 判斷用戶名和密碼是否正確 ??????if ("王恒".equals(username) && "202009280120".equals(new String(password))) { ????????JOptionPane.showMessageDialog(this, "登錄成功!"); ??????} else { ????????JOptionPane.showMessageDialog(this, "用戶名或密碼錯誤!"); ??????} ????}); ??} ??public static void main(String[] args) { ????new Login(); ??} } 第五題 import java.io.*; public class Test5 { ??public static void main(String[] args) { ????File source = new File("d:\\test1.txt"); ????File target = new File("d:\\test2.txt"); ????if (!source.exists()) { ??????return; ????} ????if (!target.getParentFile().exists()) { ??????target.getParentFile().mkdirs(); ????} ????BufferedReader in = null; ????BufferedWriter out = null; ????try { ??????in = new BufferedReader(new FileReader(source)); ??????out = new BufferedWriter(new FileWriter(target)); ??????String temp = null; ??????while ((temp = in.readLine()) != null) { ????????//輸出到文件 ????????out.write(temp + "\n"); ??????} ????} catch (Exception e) { ??????e.printStackTrace(); ????} finally { ??????//關閉流 ??????try { ????????if (in != null) { ??????????in.close(); ????????} ????????if (out != null) { ??????????out.close(); ????????} ??????} catch (IOException e) { ????????e.printStackTrace(); ??????} ????} ??} }

Java的評論 (共 條)

分享到微博請遵守國家法律
灵石县| 来宾市| 赫章县| 卢湾区| 龙井市| 乐安县| 抚顺县| 辽宁省| 通城县| 宜章县| 福泉市| 化德县| 唐山市| 湘阴县| 孝感市| 莱州市| 漠河县| 乡城县| 寿阳县| 武定县| 九龙城区| 诸城市| 五常市| 北碚区| 大冶市| 梨树县| 平利县| 登封市| 沅陵县| 沙湾县| 平邑县| 紫云| 阳东县| 永春县| 布尔津县| 乐东| 大埔县| 清水县| 宣城市| 道孚县| 阿拉善盟|