QQ登陆界面上的问题 怎样实现鼠标点击在"申请帐号"和"忘了密码"上使字的颜色改变和鼠标变为手型了"申请帐号"是用什么组件做的? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 鼠标onmouseover事件时,对按钮重绘 鼠标变化使用这个方法setCursors();至于颜色改变可以监听MouseListener中得mouseEnter(),和mouseExit()这两个方法。至于QQ界面上得那个组件。用java来做得话可以使JLabel.也可以是JButton。通过DeskTop中得方法可以得到链接得效果。不需要实现MouseListener 补充: 之前其实就你得问题没注意。我专门打开QQ得界面看了下。就使用JLabel,和JButton加上DeskTop中得方法就够了。连设置鼠标得方法都不用 我是用new JButton("申请帐号");在mouseEnter(),和mouseExit()中用setCursors();把鼠标形状改了 但下划线和链接就不会了你能用DeskTop来写个例子吗 private void authorMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_authorMouseClicked // TODO add your handling code here: click = true; if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(new URI("http://www.baidu.com"));//这句话就可以实现你所有需要的了。点击注册了的JLabel就会直接调用浏览器访问百度 } }} /* * Created on Oct 16,2008 * * Copyright by 布谷鸟 */package gui;import org.eclipse.swt.SWT;import org.eclipse.swt.events.MouseAdapter;import org.eclipse.swt.events.MouseEvent;import org.eclipse.swt.events.MouseTrackAdapter;import org.eclipse.swt.graphics.Point;import org.eclipse.swt.widgets.Display;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.Shell;/** * * @Author cuckoo * @Time 16:30 * @Description * reset cursor and font style */public class QQLogin { public static void main(String args[]){ new QQLogin().init(); } private void init(){ _shell = new Shell( _display ); _shell.setSize(400, 300); _shell.setText(" QQ Login "); _applicationLabel = new Label( _shell,SWT.NONE); _applicationLabel.setText("申请帐户"); _applicationLabel.setBounds(10, 10, 100, 20); _applicationLabel.addMouseTrackListener(new MouseTrackAdapter(){ public void mouseEnter(MouseEvent e) { // TODO Auto-generated method stub _applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_RED)); _applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_HAND)); } public void mouseExit(MouseEvent e) { // TODO Auto-generated method stub _applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_BLACK)); _applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_NO)); } }); _applicationLabel.addMouseListener(new MouseAdapter(){ public void mouseDown(MouseEvent e) { // TODO Auto-generated method stub System.out.println(" e.x "+e.x +" e.y "+e.y); Point point = _display.map(_applicationLabel, null, e.x, e.y); System.out.println(" point x "+point.x +" point y "+point.y); } }); _shell.open(); while( !_shell.isDisposed()){ if( !_display.readAndDispatch()){ _display.sleep(); } } _display.dispose(); } private Display _display = Display.getDefault(); private Shell _shell = null ; private Label _applicationLabel = null ;}SWT的------------------------------------------------------Quietly through .... 楼上的给出的是SWT的代码,你也没有达到要求,鼠标进入和离开字的颜色和鼠标样式是变了。但是没有下划线把。其实LZ要的就像网页中的超链接一样的效果。如果你们试过swing中的这个DeskTop类中的方法就会知道它的效果正是超链接的效果 文件显示问题 在父类中访问子类的成员变量 反序列化时遇到异常 关于ResultSet rs为空的问题 一个java自学者的求助 求救:如何让当前窗口最小化? JAVA字符串提取字符的问题 引用第三方包的问题 同一页面的两个APPLET,希望通过一个让另一个自动刷新,都不是图象 eclipse 项目小红叉 构建路径问题 求帮助啊! java中的多线程 super 问题
至于颜色改变可以监听MouseListener中得mouseEnter(),和mouseExit()这两个方法。
至于QQ界面上得那个组件。用java来做得话可以使JLabel.也可以是JButton。通过DeskTop中得方法可以得到链接得效果。不需要实现MouseListener
之前其实就你得问题没注意。我专门打开QQ得界面看了下。就使用JLabel,和JButton加上DeskTop中得方法就够了。连设置鼠标得方法都不用
在mouseEnter(),和mouseExit()中用setCursors();把鼠标形状改了
但下划线和链接就不会了
你能用DeskTop来写个例子吗
// TODO add your handling code here:
click = true;
if (Desktop.isDesktopSupported()) {
try {
Desktop.getDesktop().browse(new URI("http://www.baidu.com"));//这句话就可以实现你所有需要的了。点击注册了的JLabel就会直接调用浏览器访问百度
}
}
}
/*
* Created on Oct 16,2008
*
* Copyright by 布谷鸟
*/
package gui;import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;/**
*
* @Author cuckoo
* @Time 16:30
* @Description
* reset cursor and font style
*/
public class QQLogin {
public static void main(String args[]){
new QQLogin().init();
}
private void init(){
_shell = new Shell( _display );
_shell.setSize(400, 300);
_shell.setText(" QQ Login ");
_applicationLabel = new Label( _shell,SWT.NONE);
_applicationLabel.setText("申请帐户");
_applicationLabel.setBounds(10, 10, 100, 20);
_applicationLabel.addMouseTrackListener(new MouseTrackAdapter(){
public void mouseEnter(MouseEvent e) {
// TODO Auto-generated method stub
_applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_RED));
_applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_HAND));
}
public void mouseExit(MouseEvent e) {
// TODO Auto-generated method stub
_applicationLabel.setForeground( _display.getSystemColor(SWT.COLOR_BLACK));
_applicationLabel.setCursor( _display.getSystemCursor(SWT.CURSOR_NO));
}
});
_applicationLabel.addMouseListener(new MouseAdapter(){
public void mouseDown(MouseEvent e) {
// TODO Auto-generated method stub
System.out.println(" e.x "+e.x +" e.y "+e.y);
Point point = _display.map(_applicationLabel, null, e.x, e.y);
System.out.println(" point x "+point.x +" point y "+point.y);
}
});
_shell.open();
while( !_shell.isDisposed()){
if( !_display.readAndDispatch()){
_display.sleep();
}
}
_display.dispose();
}
private Display _display = Display.getDefault();
private Shell _shell = null ;
private Label _applicationLabel = null ;
}SWT的
------------------------------------------------------
Quietly through ....
其实LZ要的就像网页中的超链接一样的效果。如果你们试过swing中的这个DeskTop类中的方法就会知道它的效果正是超链接的效果