⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog1.java

📁 俄罗斯方块游戏,大学时写的,支持单机及点对点网络对战!同时我还在里面加入了使用技能的功能!不过有一个缺点,呵呵好象代码写的不够严谨,所以现在性能很低,我一直也没有优化它!
💻 JAVA
字号:
package ct;

import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.net.*;
import java.applet.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2006</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class Dialog1 extends JDialog {
  Border border1;
  JPanel jPanel1 = new JPanel();
  XYLayout xYLayout1 = new XYLayout();
  JTextField jTextField1 = new JTextField();
  JButton jButton2 = new JButton();
  JLabel jLabel1 = new JLabel();
  JLabel jLabel3 = new JLabel();
  Border border2;
  String filename;
  private java.applet.AudioClip audioClip;
   java.net.URL url;
   String uname;
  public Dialog1(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public Dialog1() {
    this(null, "", false);
  }
  private void jbInit() throws Exception {
    this.setTitle("登陆");
  //  border1 = new MatteBorder(new ImageIcon(new java.net.URL("file:///C:/face.jpg")));
   // border2 = new MatteBorder(new ImageIcon(new java.net.URL("file:///C:/buding3.jpg")));
    jPanel1.setLayout(xYLayout1);

     filename="../ct/queding.jpg";
    jButton2.setIcon(new ImageIcon(filename));
    jButton2.setText("");
    jButton2.addActionListener(new Dialog1_jButton2_actionAdapter(this));
    jLabel1.setFont(new java.awt.Font("Dialog", 0, 15));
    jLabel1.setForeground(Color.blue);
    jLabel1.setRequestFocusEnabled(true);
    jLabel1.setText("昵称");
     filename="../ct/face-1.jpg";
    jLabel3.setIcon(new ImageIcon(filename));
    jLabel3.setText("");
    jTextField1.setBackground(new Color(46, 171, 225));
    jTextField1.setFont(new java.awt.Font("Dialog", 0, 12));
    jTextField1.setText("");
    jTextField1.addActionListener(new Dialog1_jTextField1_actionAdapter(this));
    jPanel1.setBackground(new Color(46, 171, 225));
    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(jButton2,  new XYConstraints(239, 158, 62, 29));
    jPanel1.add(jLabel1,   new XYConstraints(7, 63, 52, 32));
    jPanel1.add(jTextField1,    new XYConstraints(38, 63, 83, 30));
    jPanel1.add(jLabel3, new XYConstraints(2, 0, 304, 193));

  }

  void jButton2_actionPerformed(ActionEvent e) {
    if(jTextField1.getText().equals(""))
 { JOptionPane.showConfirmDialog(this,"用户名不能为空","警告",JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE);
 }
  else
    {

      uname = jTextField1.getText();
      Dialog1 D = new Dialog1();
      D.show(false);
      Frame1 F = new Frame1();
      F.jLabel8.setText(uname);
      F.setLocation(160, 60);
      F.show(true);

      this.dispose();
    }

  }

  void jButton1_actionPerformed(ActionEvent e) {

  }

  void jTextField1_actionPerformed(ActionEvent e) {
    if(jTextField1.getText().equals(""))
 { JOptionPane.showConfirmDialog(this,"用户名不能为空","警告",JOptionPane.DEFAULT_OPTION,JOptionPane.INFORMATION_MESSAGE);
 }
  else
    {

      uname = jTextField1.getText();
      Dialog1 D = new Dialog1();
      D.show(false);
      Frame1 F = new Frame1();
      F.jLabel8.setText(uname);
      F.setLocation(160, 60);
      F.show(true);
      this.dispose();
    }

  }
}

class Dialog1_jButton2_actionAdapter implements java.awt.event.ActionListener {
  Dialog1 adaptee;

  Dialog1_jButton2_actionAdapter(Dialog1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton2_actionPerformed(e);
  }
}

class Dialog1_jTextField1_actionAdapter implements java.awt.event.ActionListener {
  Dialog1 adaptee;

  Dialog1_jTextField1_actionAdapter(Dialog1 adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jTextField1_actionPerformed(e);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -