62,620
社区成员
发帖
与我相关
我的任务
分享
package test;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import javax.swing.plaf.basic.BasicArrowButton;
import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicTextFieldUI;
import com.qq.tools.Fonts;
import com.sun.awt.AWTUtilities;
public class A extends JFrame implements MouseListener, MouseMotionListener{
/**
*
*/
private static final long serialVersionUID = 1768745106281382962L;
//显示界面背景、包含其他组件
private JPanel centerPanel = null;
//关闭与最小化按钮
JButton closeButton = null;
JButton minimizationbt = null;
//头像
ImageIcon headImage = null;
JPanel forHead = null;
//账号//密码
Font fillfont = new Font("黑体", 1, 17);
@SuppressWarnings("rawtypes")
JComboBox filluser = null;
JPasswordField fillcipher = null;
//复选框
JCheckBox remenmberPassWord = null;
JCheckBox automaticLogin = null;
//注册账号、找回密码
JButton registration = null;
JButton find = null;
//登录按钮
JButton loginButton = null;
//拖动所需
Point oldposition = null;
//自定义的监听器
// protected MouseAdapter mouseAdapter = new MouseAdapter(){
// //实现窗口移动
// @Override
// public void mouseDragged(MouseEvent e) {
// // TODO 自动生成的方法存根
// Point newposition = e.getPoint(); //转换坐标系统
// setLocation(getX()+(newposition.x-oldposition.x), getY()+(newposition.y-oldposition.y));
// }
// //点击窗口时获取坐标
// @Override
// public void mousePressed(MouseEvent e) {
// // TODO 自动生成的方法存根
// oldposition = e.getPoint();
// }
// };
public static void main(String[] args){
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
A login = new A();
login.createUI();
login.setVisible(true);
}
@SuppressWarnings("rawtypes")
public void createUI(){
this.setSize(386, 300);
this.setResizable(false);
this.setLocationRelativeTo(null);
this.addMouseListener(this);
this.addMouseMotionListener(this);
//中部面板
centerPanel = new JPanel();
centerPanel.setOpaque(false);
this.add(centerPanel, "North");
this.add(new JPanel(), "Center");
//账号
filluser = new JComboBox();
filluser.setEditable(true);
this.add(filluser, "South");
}
@Override
public void mouseDragged(MouseEvent e) {
// TODO 自动生成的方法存根
Point newposition = e.getPoint(); //转换坐标系统
setLocation(getX()+(newposition.x-oldposition.x), getY()+(newposition.y-oldposition.y));
}
//点击窗口时获取坐标
@Override
public void mousePressed(MouseEvent e) {
// TODO 自动生成的方法存根
oldposition = e.getPoint();
}
@Override
public void mouseMoved(MouseEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void mouseClicked(MouseEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void mouseReleased(MouseEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void mouseEntered(MouseEvent e) {
// TODO 自动生成的方法存根
}
@Override
public void mouseExited(MouseEvent e) {
// TODO 自动生成的方法存根
}
}
//这是一段测试用的代码你们可以自己试试看、、