java实现通讯录系统全部源码.docVIP

  • 38
  • 0
  • 约6.79万字
  • 约 137页
  • 2020-08-01 发布于上海
  • 举报
Java实现《通讯录》 ? ??? ??? ?? 软件测试.094 ? ?? ? ??? ? 谭 又 中 2011/09/25 ? ? ?????   (共37页) ?登陆界面: 源码: package sources; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class LoginForm extends JFrame implements ActionListener { //声明组件 private JPanel jpanel1=new JPanel();    //声明面板容器 private JLabel[] arrayJLabel={new JLabel("用户名:),new JLabel(密  码:"),new JLabel()};   //声明包含三个标签的标签数组 ?private JTextField userNameJTextField=new JTextField();                      //声明用户名文本域 ?private JPasswordField passwordJPasswordField=new JPasswordField();     //声明密码输入域 ?private JButton[] arrayJButton={new JButton(登  录),new JButton(注 册)};        //声明包含两个按钮数组 ? ?//构造函数 public LoginForm() ?{ ?//设置窗体相关属性 //设置标题栏显示图标 ??Image icon2=Toolkit.getDefaultToolkit().getImage(images\\ico.gif"); ?this.setIconImage(icon2); //设置窗口标题 ? this.setTitle(--登  录--); //设置窗口不可拖动大小 this.setResizable(false); ?//设置窗口大小 ? this.setSize(350,300); ?//获取屏幕尺寸 Dimension screenSize=Toolkit.getDefaultToolkit().getScreenSize(); int screenWidth=screenSize.width; ??int srceenHeight=screenSize.height; //设置窗口居于屏幕中央 ?setLocation((screenWidth-getWidth())/2,(srceenHeight-getHeight())/2); ?? ? //设置组件的相关属性 ?? //设置面板容器的布局策略为空 jpanel1.setLayout(null); //设置面板容器背景色 ?jpanel1.setBackground(Color.WHITE); ? ?//利用循环添加标签和按钮 ? for(int i=0;i2;i++) ? { ?//设置2个标签和2个按钮的位置及大小 ?arrayJLabel[i].setBounds(65, 164+i*35, 80, 26); ? arrayJButton[i].setBounds(60+i*135, 235, 90, 26); ? //设置2个标签和两个按钮的文本颜色 ?arrayJLabel[i].setForeground(Color.RED); ?arrayJButton[i].setForeground(Color.RED); ??? ?//设置2个标签和两个按钮的字体 ? arrayJLabel[i].setFont(new Font(宋体,Font.PLAIN,14)); ? arrayJButton[i].setFont(new Font(宋体",Font.PLAIN,15)); ??? ? ?//将2个标签和2个按钮添加到面板容器 ?? jpanel1.add(arrayJLabel[i]); ???jpanel1.add(arrayJButton[i]); ??      //为按钮添加动作事件监听器 ?arrayJButton[i].addActionListener(this); ??} ??//设置文本域和密码框的最大输入字符量 ?userNameJTextField.setCol

文档评论(0)

1亿VIP精品文档

相关文档